cvs: pecl /apd apd.dsp php_apd.c win32compat.c win32compat.h
| From: | Shane Caraveo | Date: | Wed, 02 Jul 2003 06:37:36 +0000 |
| Subject: | cvs: pecl /apd apd.dsp php_apd.c win32compat.c win32compat.h | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-351@lists.php.net to get a copy of this message | ||
shane Wed Jul 2 02:37:36 2003 EDT
Modified files:
/pecl/apd apd.dsp php_apd.c win32compat.c win32compat.h
Log:
get this puppy working on windows
- implement times() on win32
Index: pecl/apd/apd.dsp diff -u pecl/apd/apd.dsp:1.3 pecl/apd/apd.dsp:1.4 --- pecl/apd/apd.dsp:1.3 Mon Dec 30 15:18:56 2002 +++ pecl/apd/apd.dsp Wed Jul 2 02:37:36 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 Index: pecl/apd/php_apd.c diff -u pecl/apd/php_apd.c:1.53 pecl/apd/php_apd.c:1.54 --- pecl/apd/php_apd.c:1.53 Tue May 13 15:17:27 2003 +++ pecl/apd/php_apd.c Wed Jul 2 02:37:36 2003 @@ -1222,6 +1222,8 @@ apd_pprof_fprintf("#Pprof [APD] v0.9\n"); #ifdef _SC_CLK_TCK apd_pprof_fprintf("hz=%d\n", sysconf(_SC_CLK_TCK)); +#elif defined(CLOCKS_PER_SEC) /* 1000 on windows */ + apd_pprof_fprintf("hz=%d\n", CLOCKS_PER_SEC); #endif apd_pprof_fprintf("caller=%s\n",zend_get_executed_filename(TSRMLS_C)); apd_pprof_fprintf("\nEND_HEADER\n"); @@ -1296,7 +1298,7 @@ int address_len; int sock_domain; - int sock_port; + unsigned short sock_port; int bitmask; int connect_result; Index: pecl/apd/win32compat.c diff -u pecl/apd/win32compat.c:1.3 pecl/apd/win32compat.c:1.4 --- pecl/apd/win32compat.c:1.3 Mon Dec 30 15:18:56 2002 +++ pecl/apd/win32compat.c Wed Jul 2 02:37:36 2003 @@ -15,7 +15,7 @@ * * *****************************************************************************/ -/* $Id: win32compat.c,v 1.3 2002/12/30 20:18:56 fmk Exp $ */ +/* $Id: win32compat.c,v 1.4 2003/07/02 06:37:36 shane Exp $ */ #include "win32compat.h" @@ -26,19 +26,26 @@ * 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 +130,43 @@ 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(); +} Index: pecl/apd/win32compat.h diff -u pecl/apd/win32compat.h:1.3 pecl/apd/win32compat.h:1.4 --- pecl/apd/win32compat.h:1.3 Mon Dec 30 15:18:56 2002 +++ pecl/apd/win32compat.h Wed Jul 2 02:37:36 2003 @@ -15,15 +15,20 @@ * * *****************************************************************************/ -/* $Id: win32compat.h,v 1.3 2002/12/30 20:18:56 fmk Exp $ */ +/* $Id: win32compat.h,v 1.4 2003/07/02 06:37:36 shane Exp $ */ /* Include stuff ************************************************************ */ +#define WIN32_LEAN_AND_MEAN +#include <windows.h> #include <winsock.h> #include <time.h> /* Struct stuff ************************************************************* */ typedef long clock_t; +#ifndef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC 1000 +#endif struct tms {
Index: pecl/apd/apd.dsp diff -u pecl/apd/apd.dsp:1.3 pecl/apd/apd.dsp:1.4 --- pecl/apd/apd.dsp:1.3 Mon Dec 30 15:18:56 2002 +++ pecl/apd/apd.dsp Wed Jul 2 02:37:36 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 Index: pecl/apd/php_apd.c diff -u pecl/apd/php_apd.c:1.53 pecl/apd/php_apd.c:1.54 --- pecl/apd/php_apd.c:1.53 Tue May 13 15:17:27 2003 +++ pecl/apd/php_apd.c Wed Jul 2 02:37:36 2003 @@ -1222,6 +1222,8 @@ apd_pprof_fprintf("#Pprof [APD] v0.9\n"); #ifdef _SC_CLK_TCK apd_pprof_fprintf("hz=%d\n", sysconf(_SC_CLK_TCK)); +#elif defined(CLOCKS_PER_SEC) /* 1000 on windows */ + apd_pprof_fprintf("hz=%d\n", CLOCKS_PER_SEC); #endif apd_pprof_fprintf("caller=%s\n",zend_get_executed_filename(TSRMLS_C)); apd_pprof_fprintf("\nEND_HEADER\n"); @@ -1296,7 +1298,7 @@ int address_len; int sock_domain; - int sock_port; + unsigned short sock_port; int bitmask; int connect_result; Index: pecl/apd/win32compat.c diff -u pecl/apd/win32compat.c:1.3 pecl/apd/win32compat.c:1.4 --- pecl/apd/win32compat.c:1.3 Mon Dec 30 15:18:56 2002 +++ pecl/apd/win32compat.c Wed Jul 2 02:37:36 2003 @@ -15,7 +15,7 @@ * * *****************************************************************************/ -/* $Id: win32compat.c,v 1.3 2002/12/30 20:18:56 fmk Exp $ */ +/* $Id: win32compat.c,v 1.4 2003/07/02 06:37:36 shane Exp $ */ #include "win32compat.h" @@ -26,19 +26,26 @@ * 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 +130,43 @@ 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(); +} Index: pecl/apd/win32compat.h diff -u pecl/apd/win32compat.h:1.3 pecl/apd/win32compat.h:1.4 --- pecl/apd/win32compat.h:1.3 Mon Dec 30 15:18:56 2002 +++ pecl/apd/win32compat.h Wed Jul 2 02:37:36 2003 @@ -15,15 +15,20 @@ * * *****************************************************************************/ -/* $Id: win32compat.h,v 1.3 2002/12/30 20:18:56 fmk Exp $ */ +/* $Id: win32compat.h,v 1.4 2003/07/02 06:37:36 shane Exp $ */ /* Include stuff ************************************************************ */ +#define WIN32_LEAN_AND_MEAN +#include <windows.h> #include <winsock.h> #include <time.h> /* Struct stuff ************************************************************* */ typedef long clock_t; +#ifndef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC 1000 +#endif struct tms {