cvs: pear /PECL/apd .cvsignore README apd.dsp apd_lib.h php_apd.c php_apd.h win32compat.c win32compat.h

From: Date: Mon, 30 Dec 2002 20:18:57 +0000
Subject: cvs: pear /PECL/apd .cvsignore README apd.dsp apd_lib.h php_apd.c php_apd.h win32compat.c win32compat.h
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8016@lists.php.net to get a copy of this message
fmk Mon Dec 30 15:18:57 2002 EDT Added files: /pear/PECL/apd .cvsignore Modified files: /pear/PECL/apd apd.dsp apd_lib.h php_apd.c php_apd.h README win32compat.c win32compat.h Log: Make APD compile under win32. The implementation of times() is not complete!

Index: pear/PECL/apd/apd.dsp diff -u pear/PECL/apd/apd.dsp:1.2 pear/PECL/apd/apd.dsp:1.3 --- pear/PECL/apd/apd.dsp:1.2 Tue Nov 20 14:59:27 2001 +++ pear/PECL/apd/apd.dsp Mon Dec 30 15:18:56 2002 @@ -1,140 +1,140 @@ -# Microsoft Developer Studio Project File - Name="apd" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=apd - Win32 Debug_TS -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "apd.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "apd.mak" CFG="apd - Win32 Debug_TS" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "apd - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "apd - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "apd - Win32 Release_TS" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release_TS" -# PROP BASE Intermediate_Dir "Release_TS" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_TS" -# PROP Intermediate_Dir "Release_TS" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APD_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D "WIN32" /D "PHP_EXPORTS" /D "COMPILE_DL_APD" /D ZTS=1 /D HAVE_APD=1 /D ZEND_DEBUG=0 /D "NDEBUG" /D "_WINDOWS" /D "ZEND_WIN32" /D "PHP_WIN32" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "NDEBUG" -# ADD RSC /l 0x407 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 php4ts.lib Ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_apd.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" - -!ELSEIF "$(CFG)" == "apd - Win32 Debug_TS" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug_TS" -# PROP BASE Intermediate_Dir "Debug_TS" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug_TS" -# PROP Intermediate_Dir "Debug_TS" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APD_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_APD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_APD=1 /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "_DEBUG" -# ADD RSC /l 0x407 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 php4ts_debug.lib Ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS\php_apd.dll" /pdbtype:sept /libpath:"..\..\Debug_TS" - -!ENDIF - -# Begin Target - -# Name "apd - Win32 Release_TS" -# Name "apd - Win32 Debug_TS" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\apd_lib.c -# End Source File -# Begin Source File - -SOURCE=.\apd_stack.c -# End Source File -# Begin Source File - -SOURCE=.\opcode.c -# End Source File -# Begin Source File - -SOURCE=.\php_apd.c -# End Source File -# Begin Source File - -SOURCE=.\win32compat.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\apd_lib.h -# End Source File -# Begin Source File - -SOURCE=.\apd_stack.h -# End Source File -# Begin Source File - -SOURCE=.\opcode.h -# End Source File -# Begin Source File - -SOURCE=.\php_apd.h -# End Source File -# Begin Source File - -SOURCE=.\win32compat.h -# End Source File -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="apd" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=apd - Win32 Debug_TS +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "apd.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "apd.mak" CFG="apd - Win32 Debug_TS" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "apd - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "apd - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "apd - Win32 Release_TS" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_TS" +# PROP BASE Intermediate_Dir "Release_TS" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_TS" +# PROP Intermediate_Dir "Release_TS" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APD_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\php4" /I "..\..\..\php4\main" /I "..\..\..\php4\Zend" /I "..\..\..\php4\TSRM" /I "..\..\..\php4\win32" /D "WIN32" /D "PHP_EXPORTS" /D "COMPILE_DL_APD" /D ZTS=1 /D HAVE_APD=1 /D ZEND_DEBUG=0 /D "NDEBUG" /D "_WINDOWS" /D "ZEND_WIN32" /D "PHP_WIN32" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 php4ts.lib Ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS\php_apd.dll" /libpath:"..\..\..\php4\Release_TS" /libpath:"..\..\..\php4\Release_TS_Inline" + +!ELSEIF "$(CFG)" == "apd - Win32 Debug_TS" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_TS" +# PROP BASE Intermediate_Dir "Debug_TS" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_TS" +# PROP Intermediate_Dir "Debug_TS" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APD_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\php4" /I "..\..\..\php4\main" /I "..\..\..\php4\Zend" /I "..\..\..\php4\TSRM" /I "..\..\..\php4\win32" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_APD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_APD=1 /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 php4ts_debug.lib Ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS\php_apd.dll" /pdbtype:sept /libpath:"..\..\..\php4Debug_TS" + +!ENDIF + +# Begin Target + +# Name "apd - Win32 Release_TS" +# Name "apd - Win32 Debug_TS" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\apd_lib.c +# End Source File +# Begin Source File + +SOURCE=.\apd_stack.c +# End Source File +# Begin Source File + +SOURCE=.\opcode.c +# End Source File +# Begin Source File + +SOURCE=.\php_apd.c +# End Source File +# Begin Source File + +SOURCE=.\win32compat.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\apd_lib.h +# End Source File +# Begin Source File + +SOURCE=.\apd_stack.h +# End Source File +# Begin Source File + +SOURCE=.\opcode.h +# End Source File +# Begin Source File + +SOURCE=.\php_apd.h +# End Source File +# Begin Source File + +SOURCE=.\win32compat.h +# End Source File +# End Group +# End Target +# End Project Index: pear/PECL/apd/apd_lib.h diff -u pear/PECL/apd/apd_lib.h:1.7 pear/PECL/apd/apd_lib.h:1.8 --- pear/PECL/apd/apd_lib.h:1.7 Thu Aug 1 11:16:58 2002 +++ pear/PECL/apd/apd_lib.h Mon Dec 30 15:18:56 2002 @@ -21,7 +21,9 @@ #define INCLUDED_APD_LIB #include <stdlib.h> +#ifndef PHP_WIN32 #include <sys/time.h> +#endif #include "zend.h" /* wrappers for memory allocation routines */ Index: pear/PECL/apd/php_apd.c diff -u pear/PECL/apd/php_apd.c:1.48 pear/PECL/apd/php_apd.c:1.49 --- pear/PECL/apd/php_apd.c:1.48 Tue Nov 26 20:27:29 2002 +++ pear/PECL/apd/php_apd.c Mon Dec 30 15:18:56 2002 @@ -17,6 +17,16 @@ +----------------------------------------------------------------------+ */ +#ifdef PHP_WIN32 +#include "win32compat.h" +# define APD_IS_INVALID_SOCKET(a) (a == INVALID_SOCKET) +#else +#include <sys/time.h> +#include <sys/times.h> +#include <unistd.h> +# define APD_IS_INVALID_SOCKET(a) (a < 0) +#endif + #include "php_apd.h" #include "apd_lib.h" #include "opcode.h" @@ -28,18 +38,8 @@ #include <assert.h> #include <stdarg.h> #include <sys/types.h> -#include <sys/times.h> #include <sys/stat.h> -#ifdef PHP_WIN32 -#include "win32compat.h" -# define APD_IS_INVALID_SOCKET(a) (a == INVALID_SOCKET) -#else -#include <sys/time.h> -#include <unistd.h> -# define APD_IS_INVALID_SOCKET(a) (a < 0) -#endif - #ifndef SUN_LEN #define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) #endif @@ -246,7 +246,7 @@ return v ? estrdup("true") : estrdup("false"); } -CallStackEntry *mkCallStackEntry(char *func, char *filename, int linenum, int type) +CallStackEntry *mkCallStackEntry(const char *func, const char *filename, int linenum, int type) { CallStackEntry* entry; entry = (CallStackEntry*) emalloc(sizeof(CallStackEntry)); @@ -424,9 +424,9 @@ static void traceFunctionEntry( HashTable * func_table, const char* fname, - int type, - const char *filename, - int linenum) + int type, + const char *filename, + int linenum) { CallStack* stack; CallStackEntry* entry; @@ -699,7 +699,7 @@ int argCount; apd_stack_t* argStack; zval **object_ptr_ptr; - fname = apd_get_active_function_name(EG(current_execute_data), op_array); + fname = apd_get_active_function_name(EG(current_execute_data), op_array TSRMLS_CC); traceFunctionEntry( EG(function_table), fname, ZEND_USER_FUNCTION, zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C)); @@ -718,7 +718,7 @@ int argCount; apd_stack_t* argStack; zval **object_ptr_ptr; - fname = apd_get_active_function_name(EG(current_execute_data), EG(current_execute_data)->op_array); + fname = apd_get_active_function_name(EG(current_execute_data), EG(current_execute_data)->op_array TSRMLS_CC); traceFunctionEntry( EG(function_table), fname, ZEND_INTERNAL_FUNCTION, zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C)); @@ -1176,31 +1176,32 @@ apd_dump_session_start(); } -void apd_pprof_header(TSRMLS_DC) { - summary_t *summaryStats; - char *fname = "main"; - char *filename; - int linenum, *filenum; - filename = zend_get_executed_filename(TSRMLS_C); - linenum = zend_get_executed_lineno(TSRMLS_C); - apd_pprof_fprintf("#Pprof [APD] v0.9\n"); - apd_pprof_fprintf("hz=%d\n", sysconf(_SC_CLK_TCK)); +void apd_pprof_header(TSRMLS_D) { + summary_t *summaryStats; + char *fname = "main"; + char *filename; + int linenum, *filenum; + filename = zend_get_executed_filename(TSRMLS_C); + linenum = zend_get_executed_lineno(TSRMLS_C); + apd_pprof_fprintf("#Pprof [APD] v0.9\n"); +#ifdef _SC_CLK_TCK + apd_pprof_fprintf("hz=%d\n", sysconf(_SC_CLK_TCK)); +#endif apd_pprof_fprintf("caller=%s\n",zend_get_executed_filename(TSRMLS_C)); - apd_pprof_fprintf("\nEND_HEADER\n"); - summaryStats = (summary_t *) emalloc(sizeof(summary_t)); - summaryStats->calls = 1; - summaryStats->index = 1; - summaryStats->totalTime = 0; - APD_GLOBALS(index) = 1; - zend_hash_add(APD_GLOBALS(summary), fname, strlen(fname) + 1, summaryStats, sizeof(summary_t), NULL); - filenum = (int *) emalloc(sizeof(int)); - *filenum = ++APD_GLOBALS(file_index); - apd_pprof_fprintf("! %d %s\n", *filenum, filename); - zend_hash_add(APD_GLOBALS(file_summary), (char *) filename, - strlen(filename) + 1, filenum, sizeof(int), NULL); - apd_pprof_fprintf("& %d %s %d\n", summaryStats->index, fname, ZEND_USER_FUNCTION); - apd_pprof_fprintf("+ %d %d %d\n", summaryStats->index, *filenum, linenum); - + apd_pprof_fprintf("\nEND_HEADER\n"); + summaryStats = (summary_t *) emalloc(sizeof(summary_t)); + summaryStats->calls = 1; + summaryStats->index = 1; + summaryStats->totalTime = 0; + APD_GLOBALS(index) = 1; + zend_hash_add(APD_GLOBALS(summary), fname, strlen(fname) + 1, summaryStats, sizeof(summary_t), NULL); + filenum = (int *) emalloc(sizeof(int)); + *filenum = ++APD_GLOBALS(file_index); + apd_pprof_fprintf("! %d %s\n", *filenum, filename); + zend_hash_add(APD_GLOBALS(file_summary), (char *) filename, + strlen(filename) + 1, filenum, sizeof(int), NULL); + apd_pprof_fprintf("& %d %s %d\n", summaryStats->index, fname, ZEND_USER_FUNCTION); + apd_pprof_fprintf("+ %d %d %d\n", summaryStats->index, *filenum, linenum); } PHP_FUNCTION(apd_set_pprof_trace) @@ -1211,7 +1212,6 @@ char *dumpdir; char *path; zval **z_dumpdir; - TSRMLS_FETCH(); if(ZEND_NUM_ARGS() > 1 ) { Index: pear/PECL/apd/php_apd.h diff -u pear/PECL/apd/php_apd.h:1.17 pear/PECL/apd/php_apd.h:1.18 --- pear/PECL/apd/php_apd.h:1.17 Fri Dec 6 03:38:13 2002 +++ pear/PECL/apd/php_apd.h Mon Dec 30 15:18:56 2002 @@ -48,7 +48,7 @@ #include <unistd.h> #else /* windows */ /* these are from ext/socket -- probably worth just copying the files into apd? */ -# include <winsock.h> +# include "win32compat.h" # include "php_sockets.h" # include "php_sockets_win.h" # define IS_INVALID_SOCKET(a) (a->bsd_socket == INVALID_SOCKET) Index: pear/PECL/apd/README diff -u pear/PECL/apd/README:1.13 pear/PECL/apd/README:1.14 --- pear/PECL/apd/README:1.13 Tue Nov 26 20:35:27 2002 +++ pear/PECL/apd/README Mon Dec 30 15:18:56 2002 @@ -1,287 +1,287 @@ -PHP-APD ------------------------------------------------------------------------------ * - - Welcome to Version 2 of this README. If you have read the README - before, you may want to read it again. There may be new stuff, - particularly regarding how to use the new pprof tracing. - -Buid/Installation process: ------------------------------------------------------------------------------ * - - Make sure you have installed the CGI version of PHP and it is available - in your current path along with the phpize script. - - Change into the source directory (either created from the downloaded TAR - archive or from checking out CVS) an run the following commands: - - phpize (not necessary if configure exists) - ./configure - make install - - - This automatically should install the 'php_apd' zend module into your - - <PHP INSTALL PATH>/lib/php/<ZEND VERSION><-OPTIONAL_DEBUG>/ - - directory. It isn't mandatory to have it there, in fact you can install - it anywhere you care. - - - In your INI file, add the following lines: - - zend_extension = /absolute/path/to/php_apd.so - apd.dumpdir = /absolute/path/to/trace/directory - - Depending on your PHP build, the zend_extension directive can be one - of the following: - - zend_extension (non ZTS, non debug build) - zend_extension_ts ( ZTS, non debug build) - zend_extension_debug (non ZTS, debug build) - zend_extension_debug_ts ( ZTS, debug build) - - zend_extension_debug = /absolute/path/to/php_apd.so - - apd.dumpdir: - - This can either be an absolute path or a relative path. Relative - means always relative to your where from you run your executeable. - - - *** NOTE ****************************************************************** - * - * If you're running the CGI version of PHP, you will need to add the '-e' - * flag to enable extended information for apd to work properly: - * - * php -e -f script.php - * - *************************************************************************** - - -Win32ism ------------------------------------------------------------------------------ * - - To build APD under windows you need a working PHP compilation - environment as described on http://php.net/ (basically, it requires - you to have MSVC, win32build.zip and bison/flex and some know how - about how to get it to work). Also make sure that adp.dsp has DOS - line endings! If it has unix line endings, MSVC will complain about it. - - You can use normal Windows path values for your PHP.INI settings: - - zend_extension_debug_ts = c:\phpdev\php_apd.dll - apd.dumpdir = c:\phpdev\traces - - -How to use PHP-APD in your scripts with pprof (new style) ------------------------------------------------------------------------------ * - - This section describes the new way that profiling works under apd. The - old method, which generates a non-machine parseable indented output is - still available (see below), but is debing deprecated in favor of this, - the pprof output style, which dumps a machine-readable file and provides - a tool for interpreting the trace. This allows for much greater specificity - in the output, allows different sorts of summary generation, and a good - deal of conrol over the call-tree output. - - To set pprof tracing, just add the following line to the top of your - phpp script: - - apd_set_pprof_trace(); - - This will generate a pprof.<pid> file in your apd.dumpdir. The format - of this file is as follows: - -! 1 simple.php -& 1 main 2 -+ 1 1 2 -- 2 -& 3 hello 2 -+ 3 1 9 -- 3 -& 4 yell 2 -+ 4 1 9 -& 5 strtoupper 1 -+ 5 1 4 -- 5 -- 4 -- 1 - - -! assigns a numeric index to a file so we can easily reference that file later. -& declares a new function and it's index for the trace. -+ shows a function being entered and the file index and line number it was called on. -- shows a function being exited. -@ shows a time elapsed in the form - @ process_user_clock_t process_system_clock_t process_real_clock_t - -The syntax of the file is largely for informational purposes, it's not designed -for human consumption. To extract human-readable information from the trace, use -the pprofp utility, bundled with APD. The options to apd are: - -pprofp <flags> <trace file> - Sort options - -a Sort by alphabetic names of subroutines. - -l Sort by number of calls to subroutines - -r Sort by real time spent in subroutines. - -R Sort by real time spent in subroutines (inclusive of child calls). - -s Sort by system time spent in subroutines. - -S Sort by system time spent in subroutines (inclusive of child calls). - -u Sort by user time spent in subroutines. - -U Sort by user time spent in subroutines (inclusive of child calls). - -v Sort by average amount of time spent in subroutines. - -z Sort by user+system time spent in subroutines. (default) - - Display options - -c Display Real time elapsed alongside call tree. - -i Suppress reporting for php builtin functions - -O <cnt> Specifies maximum number of subroutines to display. (default 15) - -t Display compressed call tree. - -T Display uncompressed call tree - -Thus, to get basic output on the trace, we would do - -pprofp -u /tmp/pprof.<pid> - -and we get something like: - -10:33:29(george@ballista)[~/pear/PECL/apd]> pprofp -u /tmp/pprof.23424 - -Trace for /data/storage/mirrors/www.php.net/index.php -Total Elapsed Time = 0.09 -Total System Time = 0.00 -Total User Time = 0.06 - - - Real User System secs/ cumm -%Time (excl/cumm) (excl/cumm) (excl/cumm) Calls call s/call Name ------------------------------------------------------------------------- - 33.3 0.02 0.02 0.02 0.02 0.00 0.00 7 0.0029 0.00 require_once - 33.3 0.01 0.01 0.02 0.02 0.00 0.00 55 0.0004 0.00 sprintf - 33.3 0.00 0.00 0.02 0.02 0.00 0.00 144 0.0001 0.00 feof - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 htmlspecialchars - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 substr - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 make_submit - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 7 0.0000 0.00 printf - 0.0 0.02 0.02 0.00 0.00 0.00 0.00 6 0.0000 0.00 printf - 0.0 0.02 0.02 0.00 0.00 0.00 0.00 6 0.0000 0.00 getimagesize - 0.0 0.00 0.01 0.00 0.02 0.00 0.00 17 0.0000 0.00 print_link - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 10 0.0000 0.00 delim - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 7 0.0000 0.00 spacer - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 9 0.0000 0.00 hdelim - 0.0 0.00 0.02 0.00 0.01 0.00 0.00 2 0.0000 0.01 download_link - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 mirror_provider_url - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 mirror_provider - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 strftime - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 have_stats - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 commonfooter - 0.0 0.00 0.00 0.00 0.00 0.00 0.00 2 0.0000 0.00 strrchr - 0.0 0.01 0.01 0.00 0.00 0.00 0.00 2 0.0000 0.00 filesize - -This sorts output based on the usertime spent in subroutines, and ommits a call tree. If -we added a -t - -10:38:30(george@ballista)[~/pear/PECL/apd]> pprofp -u -t /tmp/pprof.23424 - -... - -We would also get a call graph for the function. Which is often very long. - - - - -How to use PHP-APD in your scripts (old style) ------------------------------------------------------------------------------ * - - In your PHP script, add the following line: - - apd_set_session_trace(N); - - where N is an integer which is formed by masking together the following - values: - - FUNCTION_TRACE 1 - ARGS_TRACE 2 - ASSIGNMENT_TRACE 4 - STATEMENT_TRACE 8 - MEMORY_TRACE 16 - TIMING_TRACE 32 - SUMMARY_TRACE 64 - - I would seriously not recommend using MEMORY_TRACE. It is very slow and - does not appear to be accurate (great, huh?) also ASSIGNMENT_TRACE is not - implemented. So, to turn on all functional traces (TIMING, FUNCTIONS, ARGS - SUMMARY (like strace -c)) use: - - apd_set_session_trace(99); - - - Now run your script. - - - The dump output will be writting to: - - <apd.dumpdir>/apd_dump_<pid> - - The output itself will look something like: - -16:37:51(george@wasabi)[~/src/apd]> cat /tmp/apd_dump_31994 - - -APD - Advanced PHP Debugger Trace File ---------------------------------------------------------------------------- -Process Pid (31994) -Trace Begun at Fri Aug 10 16:37:45 2001 ---------------------------------------------------------------------------- -( 0.000000): apd_set_session_trace called at somewhere -( 0.001482): apd_set_session_trace() returned. Elapsed (997475865.364909) -( 0.001563): getcwd() /opt/apache/htdocs/a.php:4 -( 0.001628): getcwd() returned. Elapsed (0.000065) -( 0.001819): require() /opt/apache/htdocs/a.php:6 - ++ argv[0] $(??) = /tmp/a.php -( 0.002231): getcwd() /tmp/a.php:3 -( 0.002290): getcwd() returned. Elapsed (0.000059) -( 0.002375): include_once() /tmp/a.php:4 - ++ argv[0] $(??) = /tmp/aa.php -( 0.003276): include_once() returned. Elapsed (0.000901) -( 0.003334): require() returned. Elapsed (0.001515) -( 0.003381): require_once() /opt/apache/htdocs/a.php:7 - ++ argv[0] $(??) = /tmp/aa.php -( 0.003515): require_once() returned. Elapsed (0.000134) -( 0.003564): include() /opt/apache/htdocs/a.php:8 - ++ argv[0] $(??) = /tmp/b.php -( 0.003792): include() returned. Elapsed (0.000228) -( 0.018341): RSHUTDOWN called - end of trace ---------------------------------------------------------------------------- -Process Pid (31994) -Trace Ended at Fri Aug 10 16:37:45 2001 ---------------------------------------------------------------------------- - - -Implemented Debugging Functions ------------------------------------------------------------------------------ * - - array apd_callstack() - Returns the current call stack as an array (very cool). - - apd_cluck([string warning[,string line delimiter]) - Behaves like perl's Carp::cluck. Throw a warning and a callstack. - The default line delimiter is "<BR />\n". - - apd_croak([string error[, string line delimiter]]) - Behaves like perl's Carp::croak. Throw an error, a callstack and then - exit. The default line delimiter is "<BR />\n". - - array apd_dump_regular_resources() - Return all current regular resources as an array. - - array apd_dump_persistent_resources() - Return all persistent resources as an array. - - override_function(string func_name, string func_args, string func_code): - Syntax similar to create_function(). Overrides built-in functions - (replaces them in the symbol table). - - rename_function(string orig_name, string new_name) - Renames orig_name to new_name in the global function_table. Useful - for temporarly overriding builtin functions. +PHP-APD +----------------------------------------------------------------------------- * + + Welcome to Version 2 of this README. If you have read the README + before, you may want to read it again. There may be new stuff, + particularly regarding how to use the new pprof tracing. + +Buid/Installation process: +----------------------------------------------------------------------------- * + + Make sure you have installed the CGI version of PHP and it is available + in your current path along with the phpize script. + + Change into the source directory (either created from the downloaded TAR + archive or from checking out CVS) an run the following commands: + + phpize (not necessary if configure exists) + ./configure + make install + + + This automatically should install the 'php_apd' zend module into your + + <PHP INSTALL PATH>/lib/php/<ZEND VERSION><-OPTIONAL_DEBUG>/ + + directory. It isn't mandatory to have it there, in fact you can install + it anywhere you care. + + + In your INI file, add the following lines: + + zend_extension = /absolute/path/to/php_apd.so + apd.dumpdir = /absolute/path/to/trace/directory + + Depending on your PHP build, the zend_extension directive can be one + of the following: + + zend_extension (non ZTS, non debug build) + zend_extension_ts ( ZTS, non debug build) + zend_extension_debug (non ZTS, debug build) + zend_extension_debug_ts ( ZTS, debug build) + + zend_extension_debug = /absolute/path/to/php_apd.so + + apd.dumpdir: + + This can either be an absolute path or a relative path. Relative + means always relative to your where from you run your executeable. + + + *** NOTE ****************************************************************** + * + * If you're running the CGI version of PHP, you will need to add the '-e' + * flag to enable extended information for apd to work properly: + * + * php -e -f script.php + * + *************************************************************************** + + +Win32ism +----------------------------------------------------------------------------- * + + To build APD under windows you need a working PHP compilation + environment as described on http://php.net/ (basically, it requires + you to have MSVC, win32build.zip and bison/flex and some know how + about how to get it to work). Also make sure that adp.dsp has DOS + line endings! If it has unix line endings, MSVC will complain about it. + + You can use normal Windows path values for your PHP.INI settings: + + zend_extension_debug_ts = c:\phpdev\php_apd.dll + apd.dumpdir = c:\phpdev\traces + + +How to use PHP-APD in your scripts with pprof (new style) +----------------------------------------------------------------------------- * + + This section describes the new way that profiling works under apd. The + old method, which generates a non-machine parseable indented output is + still available (see below), but is debing deprecated in favor of this, + the pprof output style, which dumps a machine-readable file and provides + a tool for interpreting the trace. This allows for much greater specificity + in the output, allows different sorts of summary generation, and a good + deal of conrol over the call-tree output. + + To set pprof tracing, just add the following line to the top of your + phpp script: + + apd_set_pprof_trace(); + + This will generate a pprof.<pid> file in your apd.dumpdir. The format + of this file is as follows: + +! 1 simple.php +& 1 main 2 ++ 1 1 2 +- 2 +& 3 hello 2 ++ 3 1 9 +- 3 +& 4 yell 2 ++ 4 1 9 +& 5 strtoupper 1 ++ 5 1 4 +- 5 +- 4 +- 1 + + +! assigns a numeric index to a file so we can easily reference that file later. +& declares a new function and it's index for the trace. ++ shows a function being entered and the file index and line number it was called on. +- shows a function being exited. +@ shows a time elapsed in the form + @ process_user_clock_t process_system_clock_t process_real_clock_t + +The syntax of the file is largely for informational purposes, it's not designed +for human consumption. To extract human-readable information from the trace, use +the pprofp utility, bundled with APD. The options to apd are: + +pprofp <flags> <trace file> + Sort options + -a Sort by alphabetic names of subroutines. + -l Sort by number of calls to subroutines + -r Sort by real time spent in subroutines. + -R Sort by real time spent in subroutines (inclusive of child calls). + -s Sort by system time spent in subroutines. + -S Sort by system time spent in subroutines (inclusive of child calls). + -u Sort by user time spent in subroutines. + -U Sort by user time spent in subroutines (inclusive of child calls). + -v Sort by average amount of time spent in subroutines. + -z Sort by user+system time spent in subroutines. (default) + + Display options + -c Display Real time elapsed alongside call tree. + -i Suppress reporting for php builtin functions + -O <cnt> Specifies maximum number of subroutines to display. (default 15) + -t Display compressed call tree. + -T Display uncompressed call tree + +Thus, to get basic output on the trace, we would do + +pprofp -u /tmp/pprof.<pid> + +and we get something like: + +10:33:29(george@ballista)[~/pear/PECL/apd]> pprofp -u /tmp/pprof.23424 + +Trace for /data/storage/mirrors/www.php.net/index.php +Total Elapsed Time = 0.09 +Total System Time = 0.00 +Total User Time = 0.06 + + + Real User System secs/ cumm +%Time (excl/cumm) (excl/cumm) (excl/cumm) Calls call s/call Name +------------------------------------------------------------------------ + 33.3 0.02 0.02 0.02 0.02 0.00 0.00 7 0.0029 0.00 require_once + 33.3 0.01 0.01 0.02 0.02 0.00 0.00 55 0.0004 0.00 sprintf + 33.3 0.00 0.00 0.02 0.02 0.00 0.00 144 0.0001 0.00 feof + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 htmlspecialchars + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 substr + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 make_submit + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 7 0.0000 0.00 printf + 0.0 0.02 0.02 0.00 0.00 0.00 0.00 6 0.0000 0.00 printf + 0.0 0.02 0.02 0.00 0.00 0.00 0.00 6 0.0000 0.00 getimagesize + 0.0 0.00 0.01 0.00 0.02 0.00 0.00 17 0.0000 0.00 print_link + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 10 0.0000 0.00 delim + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 7 0.0000 0.00 spacer + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 9 0.0000 0.00 hdelim + 0.0 0.00 0.02 0.00 0.01 0.00 0.00 2 0.0000 0.01 download_link + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 mirror_provider_url + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 mirror_provider + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 strftime + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 have_stats + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.00 commonfooter + 0.0 0.00 0.00 0.00 0.00 0.00 0.00 2 0.0000 0.00 strrchr + 0.0 0.01 0.01 0.00 0.00 0.00 0.00 2 0.0000 0.00 filesize + +This sorts output based on the usertime spent in subroutines, and ommits a call tree. If +we added a -t + +10:38:30(george@ballista)[~/pear/PECL/apd]> pprofp -u -t /tmp/pprof.23424 + +... + +We would also get a call graph for the function. Which is often very long. + + + + +How to use PHP-APD in your scripts (old style) +----------------------------------------------------------------------------- * + + In your PHP script, add the following line: + + apd_set_session_trace(N); + + where N is an integer which is formed by masking together the following + values: + + FUNCTION_TRACE 1 + ARGS_TRACE 2 + ASSIGNMENT_TRACE 4 + STATEMENT_TRACE 8 + MEMORY_TRACE 16 + TIMING_TRACE 32 + SUMMARY_TRACE 64 + + I would seriously not recommend using MEMORY_TRACE. It is very slow and + does not appear to be accurate (great, huh?) also ASSIGNMENT_TRACE is not + implemented. So, to turn on all functional traces (TIMING, FUNCTIONS, ARGS + SUMMARY (like strace -c)) use: + + apd_set_session_trace(99); + + + Now run your script. + + + The dump output will be writting to: + + <apd.dumpdir>/apd_dump_<pid> + + The output itself will look something like: + +16:37:51(george@wasabi)[~/src/apd]> cat /tmp/apd_dump_31994 + + +APD - Advanced PHP Debugger Trace File +--------------------------------------------------------------------------- +Process Pid (31994) +Trace Begun at Fri Aug 10 16:37:45 2001 +--------------------------------------------------------------------------- +( 0.000000): apd_set_session_trace called at somewhere +( 0.001482): apd_set_session_trace() returned. Elapsed (997475865.364909) +( 0.001563): getcwd() /opt/apache/htdocs/a.php:4 +( 0.001628): getcwd() returned. Elapsed (0.000065) +( 0.001819): require() /opt/apache/htdocs/a.php:6 + ++ argv[0] $(??) = /tmp/a.php +( 0.002231): getcwd() /tmp/a.php:3 +( 0.002290): getcwd() returned. Elapsed (0.000059) +( 0.002375): include_once() /tmp/a.php:4 + ++ argv[0] $(??) = /tmp/aa.php +( 0.003276): include_once() returned. Elapsed (0.000901) +( 0.003334): require() returned. Elapsed (0.001515) +( 0.003381): require_once() /opt/apache/htdocs/a.php:7 + ++ argv[0] $(??) = /tmp/aa.php +( 0.003515): require_once() returned. Elapsed (0.000134) +( 0.003564): include() /opt/apache/htdocs/a.php:8 + ++ argv[0] $(??) = /tmp/b.php +( 0.003792): include() returned. Elapsed (0.000228) +( 0.018341): RSHUTDOWN called - end of trace +--------------------------------------------------------------------------- +Process Pid (31994) +Trace Ended at Fri Aug 10 16:37:45 2001 +--------------------------------------------------------------------------- + + +Implemented Debugging Functions +----------------------------------------------------------------------------- * + + array apd_callstack() + Returns the current call stack as an array (very cool). + + apd_cluck([string warning[,string line delimiter]) + Behaves like perl's Carp::cluck. Throw a warning and a callstack. + The default line delimiter is "<BR />\n". + + apd_croak([string error[, string line delimiter]]) + Behaves like perl's Carp::croak. Throw an error, a callstack and then + exit. The default line delimiter is "<BR />\n". + + array apd_dump_regular_resources() + Return all current regular resources as an array. + + array apd_dump_persistent_resources() + Return all persistent resources as an array. + + override_function(string func_name, string func_args, string func_code): + Syntax similar to create_function(). Overrides built-in functions + (replaces them in the symbol table). + + rename_function(string orig_name, string new_name) + Renames orig_name to new_name in the global function_table. Useful + for temporarly overriding builtin functions. Index: pear/PECL/apd/win32compat.c diff -u pear/PECL/apd/win32compat.c:1.2 pear/PECL/apd/win32compat.c:1.3 --- pear/PECL/apd/win32compat.c:1.2 Tue Nov 20 14:59:27 2001 +++ pear/PECL/apd/win32compat.c Mon Dec 30 15:18:56 2002 @@ -1,121 +1,129 @@ -#include "win32compat.h" - - -/***************************************************************************** - * * - * DH_TIME.C * - * * - * Freely redistributable and modifiable. Use at your own risk. * - * * - * Copyright 1994 The Downhill Project * - * * - * Modified by Shane Caraveo for use with PHP * - * * - * Modified by Markus Fischer for the APD project * - * * - *****************************************************************************/ - -/* $Id: win32compat.c,v 1.2 2001/11/20 19:59:27 george Exp $ */ - - /** - * - * 04-Feb-2001 - * - Added patch by "Vanhanen, Reijo" <Reijo.Vanhanen@helsoft.fi> - * Improves accuracy of msec - */ - -int getfilesystemtime(struct timeval *time_Info) -{ -FILETIME ft; -__int64 ff; - - GetSystemTimeAsFileTime(&ft); /* 100 ns blocks since 01-Jan-1641 */ - /* resolution seems to be 0.01 sec */ - ff = *(__int64*)(&ft); - time_Info->tv_sec = (int)(ff/(__int64)10000000-(__int64)11644473600); - time_Info->tv_usec = (int)(ff % 10000000)/10; - return 0; -} - -int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info) -{ - - static struct timeval starttime = {0, 0}; - static __int64 lasttime = 0; - static __int64 freq = 0; - __int64 timer; - LARGE_INTEGER li; - BOOL b; - double dt; - - /* Get the time, if they want it */ - if (time_Info != NULL) { - if (starttime.tv_sec == 0) { - b = QueryPerformanceFrequency(&li); - if (!b) { - starttime.tv_sec = -1; - } - else { - freq = li.QuadPart; - b = QueryPerformanceCounter(&li); - if (!b) { - starttime.tv_sec = -1; - } - else { - getfilesystemtime(&starttime); - timer = li.QuadPart; - dt = (double)timer/freq; - starttime.tv_usec -= (int)((dt-(int)dt)*1000000); - if (starttime.tv_usec < 0) { - starttime.tv_usec += 1000000; - --starttime.tv_sec; - } - starttime.tv_sec -= (int)dt; - } - } - } - if (starttime.tv_sec > 0) { - b = QueryPerformanceCounter(&li); - if (!b) { - starttime.tv_sec = -1; - } - else { - timer = li.QuadPart; - if (timer < lasttime) { - getfilesystemtime(time_Info); - dt = (double)timer/freq; - starttime = *time_Info; - starttime.tv_usec -= (int)((dt-(int)dt)*1000000); - if (starttime.tv_usec < 0) { - starttime.tv_usec += 1000000; - --starttime.tv_sec; - } - starttime.tv_sec -= (int)dt; - } - else { - lasttime = timer; - dt = (double)timer/freq; - time_Info->tv_sec = starttime.tv_sec + (int)dt; - time_Info->tv_usec = starttime.tv_usec + (int)((dt-(int)dt)*1000000); - if (time_Info->tv_usec > 1000000) { - time_Info->tv_usec -= 1000000; - ++time_Info->tv_sec; - } - } - } - } - if (starttime.tv_sec < 0) { - getfilesystemtime(time_Info); - } - - } - /* Get the timezone, if they want it - if (timezone_Info != NULL) { - _tzset(); - timezone_Info->tz_minuteswest = _timezone; - timezone_Info->tz_dsttime = _daylight; - } - And return */ - return 0; -} - +#include "win32compat.h" + + +/***************************************************************************** + * * + * DH_TIME.C * + * * + * Freely redistributable and modifiable. Use at your own risk. * + * * + * Copyright 1994 The Downhill Project * + * * + * Modified by Shane Caraveo for use with PHP * + * * + * Modified by Markus Fischer for the APD project * + * * + *****************************************************************************/ + +/* $Id: win32compat.c,v 1.3 2002/12/30 20:18:56 fmk Exp $ */ + +#include "win32compat.h" + + /** + * + * 04-Feb-2001 + * - Added patch by "Vanhanen, Reijo" <Reijo.Vanhanen@helsoft.fi> + * Improves accuracy of msec + */ + +int getfilesystemtime(struct timeval *time_Info) +{ +FILETIME ft; +__int64 ff; + + GetSystemTimeAsFileTime(&ft); /* 100 ns blocks since 01-Jan-1641 */ + /* resolution seems to be 0.01 sec */ + ff = *(__int64*)(&ft); + time_Info->tv_sec = (int)(ff/(__int64)10000000-(__int64)11644473600); + time_Info->tv_usec = (int)(ff % 10000000)/10; + return 0; +} + +int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info) +{ + + static struct timeval starttime = {0, 0}; + static __int64 lasttime = 0; + static __int64 freq = 0; + __int64 timer; + LARGE_INTEGER li; + BOOL b; + double dt; + + /* Get the time, if they want it */ + if (time_Info != NULL) { + if (starttime.tv_sec == 0) { + b = QueryPerformanceFrequency(&li); + if (!b) { + starttime.tv_sec = -1; + } + else { + freq = li.QuadPart; + b = QueryPerformanceCounter(&li); + if (!b) { + starttime.tv_sec = -1; + } + else { + getfilesystemtime(&starttime); + timer = li.QuadPart; + dt = (double)timer/freq; + starttime.tv_usec -= (int)((dt-(int)dt)*1000000); + if (starttime.tv_usec < 0) { + starttime.tv_usec += 1000000; + --starttime.tv_sec; + } + starttime.tv_sec -= (int)dt; + } + } + } + if (starttime.tv_sec > 0) { + b = QueryPerformanceCounter(&li); + if (!b) { + starttime.tv_sec = -1; + } + else { + timer = li.QuadPart; + if (timer < lasttime) { + getfilesystemtime(time_Info); + dt = (double)timer/freq; + starttime = *time_Info; + starttime.tv_usec -= (int)((dt-(int)dt)*1000000); + if (starttime.tv_usec < 0) { + starttime.tv_usec += 1000000; + --starttime.tv_sec; + } + starttime.tv_sec -= (int)dt; + } + else { + lasttime = timer; + dt = (double)timer/freq; + time_Info->tv_sec = starttime.tv_sec + (int)dt; + time_Info->tv_usec = starttime.tv_usec + (int)((dt-(int)dt)*1000000); + if (time_Info->tv_usec > 1000000) { + time_Info->tv_usec -= 1000000; + ++time_Info->tv_sec; + } + } + } + } + if (starttime.tv_sec < 0) { + getfilesystemtime(time_Info); + } + + } + /* Get the timezone, if they want it + if (timezone_Info != NULL) { + _tzset(); + timezone_Info->tz_minuteswest = _timezone; + timezone_Info->tz_dsttime = _daylight; + } + And return */ + return 0; +} + +clock_t times (struct tms *__buffer) +{ + if (__buffer) { + __buffer->tms_utime = clock(); + } +} \ No newline at end of file Index: pear/PECL/apd/win32compat.h diff -u pear/PECL/apd/win32compat.h:1.2 pear/PECL/apd/win32compat.h:1.3 --- pear/PECL/apd/win32compat.h:1.2 Tue Nov 20 14:59:27 2001 +++ pear/PECL/apd/win32compat.h Mon Dec 30 15:18:56 2002 @@ -1,35 +1,42 @@ -#ifndef __WIN32COMPAT_H_ -#define __WIN32COMPAT_H_ - -/***************************************************************************** - * * - * win32compat * - * * - * Freely redistributable and modifiable. Use at your own risk. * - * * - * Copyright 1994 The Downhill Project * - * * - * Modified by Shane Caraveo for PHP * - * * - * Modified by Markus Fischer for the APD project * - * * - *****************************************************************************/ - -/* $Id: win32compat.h,v 1.2 2001/11/20 19:59:27 george Exp $ */ - - -/* Include stuff ************************************************************ */ -#include <winsock.h> -#include <time.h> - -/* Struct stuff ************************************************************* */ -struct timezone { - int tz_minuteswest; - int tz_dsttime; -}; - - -/* Prototype stuff ********************************************************** */ -extern int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info); - +#ifndef __WIN32COMPAT_H_ +#define __WIN32COMPAT_H_ + +/***************************************************************************** + * * + * win32compat * + * * + * Freely redistributable and modifiable. Use at your own risk. * + * * + * Copyright 1994 The Downhill Project * + * * + * Modified by Shane Caraveo for PHP * + * * + * Modified by Markus Fischer for the APD project * + * * + *****************************************************************************/ + +/* $Id: win32compat.h,v 1.3 2002/12/30 20:18:56 fmk Exp $ */ + + +/* Include stuff ************************************************************ */ +#include <winsock.h> +#include <time.h> + +/* Struct stuff ************************************************************* */ +typedef long clock_t; + +struct tms +{ + clock_t tms_utime; /* User CPU time. */ + clock_t tms_stime; /* System CPU time. */ + + clock_t tms_cutime; /* User CPU time of dead children. */ + clock_t tms_cstime; /* System CPU time of dead children. */ +}; + + +/* Prototype stuff ********************************************************** */ +extern int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info); +extern clock_t times (struct tms *__buffer); + #endif Index: pear/PECL/apd/.cvsignore +++ pear/PECL/apd/.cvsignore *.plg *.opt *.ncb Release_TS Debug_TS
« previous php.pear.cvs (#8016) next »