cvs: pecl(ZEND_ENGINE_2) /apd apd.dsp apd_summary.c php_apd.c php_apd.h win32compat.c win32compat.h

From: Date: Wed, 02 Jul 2003 06:39:06 +0000
Subject: cvs: pecl(ZEND_ENGINE_2) /apd apd.dsp apd_summary.c php_apd.c php_apd.h win32compat.c win32compat.h
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-352@lists.php.net to get a copy of this message
shane Wed Jul 2 02:39:06 2003 EDT Modified files: (Branch: ZEND_ENGINE_2) /pecl/apd apd.dsp apd_summary.c php_apd.c php_apd.h win32compat.c win32compat.h Log: get this puppy working on windows - implement times() on win32 - implement getrusage() on win32 - change basename to php_basename (to support win32) - fix missing function name (correct???)

Index: pecl/apd/apd.dsp diff -u pecl/apd/apd.dsp:1.3 pecl/apd/apd.dsp:1.3.2.1 --- pecl/apd/apd.dsp:1.3 Mon Dec 30 15:18:56 2002 +++ pecl/apd/apd.dsp Wed Jul 2 02:39:06 2003 @@ -43,7 +43,7 @@ # 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 CPP /nologo /MD /W3 /GX /O2 /I "..\..\\" /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\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" @@ -53,7 +53,7 @@ # 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" +# 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" @@ -70,7 +70,7 @@ # 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 CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\\" /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\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" @@ -80,7 +80,7 @@ # 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" +# 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 @@ -93,11 +93,15 @@ # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File +SOURCE=.\apd_array.c +# End Source File +# Begin Source File + SOURCE=.\apd_lib.c # End Source File # Begin Source File -SOURCE=.\apd_stack.c +SOURCE=.\apd_summary.c # End Source File # Begin Source File @@ -117,11 +121,11 @@ # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File -SOURCE=.\apd_lib.h +SOURCE=.\apd_array.h # End Source File # Begin Source File -SOURCE=.\apd_stack.h +SOURCE=.\apd_lib.h # End Source File # Begin Source File @@ -130,6 +134,14 @@ # Begin Source File SOURCE=.\php_apd.h +# End Source File +# Begin Source File + +SOURCE=.\php_sockets.h +# End Source File +# Begin Source File + +SOURCE=.\php_sockets_win.h # End Source File # Begin Source File Index: pecl/apd/apd_summary.c diff -u pecl/apd/apd_summary.c:1.1.2.1 pecl/apd/apd_summary.c:1.1.2.2 --- pecl/apd/apd_summary.c:1.1.2.1 Sun Jun 22 19:05:11 2003 +++ pecl/apd/apd_summary.c Wed Jul 2 02:39:06 2003 @@ -269,6 +269,8 @@ apd_file_entry_t *file_entry; char *shortname; apd_coverage_t coverage; + char *ret; + int ret_len; TSRMLS_FETCH(); memset(&coverage, 0, sizeof(apd_coverage_t)); @@ -289,10 +291,10 @@ while (fcall) { function_entry = fcall->entry; file_entry = apd_array_get(&APD_GLOBALS(summary).files, fcall->file); - + php_basename(file_entry->filename, strlen(file_entry->filename), NULL, 0, &ret, &ret_len); php_printf("<tr>\n"); php_printf("<td>%s</td>\n", function_entry->name); - php_printf("<td><abbr title=\"%s\">%s</abbr></td>\n", file_entry->filename, basename(file_entry->filename)); + php_printf("<td><abbr title=\"%s\">%s</abbr></td>\n", file_entry->filename, ret); php_printf("<td>%d</td>\n", fcall->line); php_printf("<td>%d</td>\n", fcall->calls); php_printf("<td>%4.2f</td>\n", (double) fcall->usertime / 1000000); @@ -301,6 +303,7 @@ php_printf("</tr>\n"); fcall = fcall->next; + efree(ret); } php_printf("</table>\n"); Index: pecl/apd/php_apd.c diff -u pecl/apd/php_apd.c:1.52.2.19 pecl/apd/php_apd.c:1.52.2.20 --- pecl/apd/php_apd.c:1.52.2.19 Sun Jun 22 19:05:11 2003 +++ pecl/apd/php_apd.c Wed Jul 2 02:39:06 2003 @@ -18,6 +18,7 @@ +----------------------------------------------------------------------+ */ +#include "php_apd.h" #ifdef PHP_WIN32 #include "win32compat.h" # define APD_IS_INVALID_SOCKET(a) (a == INVALID_SOCKET) @@ -29,7 +30,6 @@ # define APD_IS_INVALID_SOCKET(a) (a < 0) #endif -#include "php_apd.h" #include "apd_lib.h" #include "opcode.h" #include "zend_API.h" @@ -547,7 +547,7 @@ trace_function_entry(EG(function_table), fname, ZEND_INTERNAL_FUNCTION, zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C)); - execute_internal(execute_data_ptr, return_value_used TSRMLS_DC); + execute_internal(execute_data_ptr, return_value_used TSRMLS_CC); trace_function_exit(fname); efree(fname); apd_interactive(); @@ -896,7 +896,7 @@ break; } } - apd_dump_session_start(); + apd_summary_output_header(); RETURN_TRUE; } Index: pecl/apd/php_apd.h diff -u pecl/apd/php_apd.h:1.19.2.10 pecl/apd/php_apd.h:1.19.2.11 --- pecl/apd/php_apd.h:1.19.2.10 Sun Jun 22 19:05:12 2003 +++ pecl/apd/php_apd.h Wed Jul 2 02:39:06 2003 @@ -31,6 +31,7 @@ #include "php_ini.h" #include "php_globals.h" +#include "ext/standard/php_string.h" #include "apd_array.h" #include "zend.h" Index: pecl/apd/win32compat.c diff -u pecl/apd/win32compat.c:1.3 pecl/apd/win32compat.c:1.3.2.1 --- pecl/apd/win32compat.c:1.3 Mon Dec 30 15:18:56 2002 +++ pecl/apd/win32compat.c Wed Jul 2 02:39:06 2003 @@ -1,6 +1,3 @@ -#include "win32compat.h" - - /***************************************************************************** * * * DH_TIME.C * @@ -15,7 +12,7 @@ * * *****************************************************************************/ -/* $Id: win32compat.c,v 1.3 2002/12/30 20:18:56 fmk Exp $ */ +/* $Id: win32compat.c,v 1.3.2.1 2003/07/02 06:39:06 shane Exp $ */ #include "win32compat.h" @@ -25,20 +22,26 @@ * - Added patch by "Vanhanen, Reijo" <Reijo.Vanhanen@helsoft.fi> * Improves accuracy of msec */ - -int getfilesystemtime(struct timeval *time_Info) +int FiletimeToTimeval(FILETIME ft, struct timeval *time_Info) { -FILETIME ft; -__int64 ff; + __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 getfilesystemtime(struct timeval *time_Info) +{ + FILETIME ft; + + GetSystemTimeAsFileTime(&ft); /* 100 ns blocks since 01-Jan-1641 */ + /* resolution seems to be 0.01 sec */ + return FiletimeToTimeval(ft,time_Info); +} + int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info) { @@ -123,7 +126,78 @@ clock_t times (struct tms *__buffer) { - if (__buffer) { - __buffer->tms_utime = clock(); - } -} \ No newline at end of file + HANDLE cp; + FILETIME CreationTime, ExitTime, KernelTime, UserTime; + struct timeval time_Info; + /* If times fails, a -1 is returned and errno is set to indicate the error. */ + if (!__buffer) return -1; + cp = GetCurrentProcess(); + + GetProcessTimes(cp, &CreationTime, &ExitTime, &KernelTime, &UserTime); + /* + tms_utime is the CPU time used while executing instructions in the user + space of the calling process. + */ + FiletimeToTimeval(UserTime,&time_Info); + __buffer->tms_utime = (time_Info.tv_sec + (time_Info.tv_usec / 10000000)) * CLOCKS_PER_SEC; + /* + tms_stime is the CPU time used by the system on behalf of the calling + process. + */ + FiletimeToTimeval(KernelTime,&time_Info); + __buffer->tms_stime = (time_Info.tv_sec + (time_Info.tv_usec / 10000000)) * CLOCKS_PER_SEC; + + /* Note: Windows has such a thing as a process tree, which could + possibly be used to derive these values, but since we dont use them, + no need to bother now. */ + /* + tms_cutime is the sum of the tms_utime and the tms_cutime of the child + processes. + */ + __buffer->tms_cutime = 0; + /* + tms_cstime is the sum of the tms_stime and the tms_cstime of the child + processes. + */ + __buffer->tms_cstime = 0; + /* + Upon successful completion, times returns the elapsed real time, in clock + ticks, from an arbitrary point in the past (e.g., system start-up time). + */ + return GetTickCount(); +} + +int getrusage(int processes, struct rusage *rusage) +{ + HANDLE cp; + FILETIME CreationTime, ExitTime, KernelTime, UserTime; + /* If times fails, a -1 is returned and errno is set to indicate the error. */ + + if (rusage == (struct rusage *) NULL) { + errno = EFAULT; + return -1; + } + + memset(rusage, 0, sizeof(rusage)); + cp = GetCurrentProcess(); + GetProcessTimes(cp, &CreationTime, &ExitTime, &KernelTime, &UserTime); + + switch (processes) { + case RUSAGE_SELF: + FiletimeToTimeval(UserTime,&rusage->ru_utime); + FiletimeToTimeval(KernelTime,&rusage->ru_stime); + break; + /* + XXX no support for children times yet + case RUSAGE_CHILDREN: + u = tms.tms_cutime; + s = tms.tms_cstime; + break; + */ + default: + errno = EINVAL; + return -1; + } + return 0; +} + Index: pecl/apd/win32compat.h diff -u pecl/apd/win32compat.h:1.3 pecl/apd/win32compat.h:1.3.2.1 --- pecl/apd/win32compat.h:1.3 Mon Dec 30 15:18:56 2002 +++ pecl/apd/win32compat.h Wed Jul 2 02:39:06 2003 @@ -15,15 +15,20 @@ * * *****************************************************************************/ -/* $Id: win32compat.h,v 1.3 2002/12/30 20:18:56 fmk Exp $ */ +/* $Id: win32compat.h,v 1.3.2.1 2003/07/02 06:39:06 shane Exp $ */ /* Include stuff ************************************************************ */ -#include <winsock.h> +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include <winsock2.h> #include <time.h> /* Struct stuff ************************************************************* */ typedef long clock_t; +#ifndef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC 1000 +#endif struct tms { @@ -34,9 +39,35 @@ clock_t tms_cstime; /* System CPU time of dead children. */ }; +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN 1 + +struct rusage +{ + /* This data type stores various resource usage statistics. It has the + following members, and possibly others: */ + + struct timeval ru_utime; /* Time spent executing user instructions. */ + struct timeval ru_stime; /*Time spent in operating system code on behalf of processes. */ + long int ru_maxrss; /* The maximum resident set size used, in kilobytes. That is, the maximum number of kilobytes of physical memory that processes used simultaneously. */ + long int ru_ixrss; /* An integral value expressed in kilobytes times ticks of execution, which indicates the amount of memory used by text that was shared with other processes. */ + long int ru_idrss; /* An integral value expressed the same way, which is the amount of unshared memory used for data. */ + long int ru_isrss; /* An integral value expressed the same way, which is the amount of unshared memory used for stack space. */ + long int ru_minflt; /* The number of page faults which were serviced without requiring any I/O. */ + long int ru_majflt; /* The number of page faults which were serviced by doing I/O. */ + long int ru_nswap; /* The number of times processes was swapped entirely out of main memory. */ + long int ru_inblock; /* The number of times the file system had to read from the disk on behalf of processes. */ + long int ru_oublock; /* The number of times the file system had to write to the disk on behalf of processes. */ + long int ru_msgsnd; /* Number of IPC messages sent. */ + long int ru_msgrcv; /* Number of IPC messages received. */ + long int ru_nsignals; /* Number of signals received. */ + long int ru_nvcsw; /* The number of times processes voluntarily invoked a context switch (usually to wait for some service). */ + long int ru_nivcsw; /* The number of times an involuntary context switch took place (because a time slice expired, or another process of higher priority was scheduled). */ +}; /* Prototype stuff ********************************************************** */ extern int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info); -extern clock_t times (struct tms *__buffer); +extern clock_t times(struct tms *__buffer); +extern int getrusage(int processes, struct rusage *rusage); #endif
« previous php.pecl.cvs (#352) next »