]> granicus.if.org Git - php/commitdiff
MFH: various ZTS fixes
authorWez Furlong <wez@php.net>
Fri, 30 Jul 2004 14:24:59 +0000 (14:24 +0000)
committerWez Furlong <wez@php.net>
Fri, 30 Jul 2004 14:24:59 +0000 (14:24 +0000)
ext/standard/basic_functions.c
main/config.w32.h
win32/build/config.w32
win32/pwd.c
win32/time.c
win32/wsyslog.c

index 2a8239795e0c2c1bf9fb150695bfdcf59846fa58..01209f4d6c35aaee3eac833e85985b8c1444273e 100644 (file)
 #include "ext/standard/dns.h"
 #include "ext/standard/php_uuencode.h"
 
+#ifdef PHP_WIN32
+#include "win32/php_win32_globals.h"
+#endif
+
 typedef struct yy_buffer_state *YY_BUFFER_STATE;
 
 #include "zend.h"
@@ -999,8 +1003,14 @@ PHP_MINIT_FUNCTION(basic)
 {
 #ifdef ZTS
        ts_allocate_id(&basic_globals_id, sizeof(php_basic_globals), (ts_allocate_ctor) basic_globals_ctor, (ts_allocate_dtor) basic_globals_dtor);
+#ifdef PHP_WIN32
+       ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor)php_win32_core_globals_ctor, NULL);
+#endif
 #else
        basic_globals_ctor(&basic_globals TSRMLS_CC);
+#ifdef PHP_WIN32
+       php_win32_core_globals_ctor(&php_win32_core_globals TSRMLS_CC);
+#endif
 #endif
 
        REGISTER_LONG_CONSTANT("CONNECTION_ABORTED", PHP_CONNECTION_ABORTED, CONST_CS | CONST_PERSISTENT);
@@ -1099,6 +1109,9 @@ PHP_MSHUTDOWN_FUNCTION(basic)
 {
 #ifdef ZTS
        ts_free_id(basic_globals_id);
+#ifdef PHP_WIN32
+       ts_free_id(php_win32_core_globals_id);
+#endif
 #else
        basic_globals_dtor(&basic_globals TSRMLS_CC);
 #endif
@@ -1208,6 +1221,9 @@ PHP_RSHUTDOWN_FUNCTION(basic)
        PHP_RSHUTDOWN(assert)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
        PHP_RSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
        PHP_RSHUTDOWN(streams)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+#ifdef PHP_WIN32
+       PHP_RSHUTDOWN(win32_core_globals)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+#endif
 
        if (BG(user_tick_functions)) {
                zend_llist_destroy(BG(user_tick_functions));
index 6bfe3879a67f9c161a502741b6a56b8019dff232..8c2336553c0501ab87d6ed6f64422c1e0aa64bdc 100644 (file)
@@ -1,26 +1,20 @@
 /*
-       Build Configuration for Win32.
-       This has only been tested with MS VisualC++ 6 (and later).
-
+       Build Configuration Template for Win32.
        $Id$
 */
 
 /* Default PHP / PEAR directories */
-#define CONFIGURATION_FILE_PATH "php.ini"
-#define PEAR_INSTALLDIR "c:\\php5\\pear"
-#define PHP_BINDIR "c:\\php5"
 #define PHP_CONFIG_FILE_PATH (getenv("SystemRoot"))?getenv("SystemRoot"):""
-#define PHP_CONFIG_FILE_SCAN_DIR ""
-#define PHP_DATADIR "c:\\php5"
-#define PHP_EXTENSION_DIR "c:\\php5"
-#define PHP_INCLUDE_PATH       ".;c:\\php5\\pear"
-#define PHP_LIBDIR "c:\\php5"
-#define PHP_LOCALSTATEDIR "c:\\php5"
-#define PHP_PREFIX "c:\\php5"
-#define PHP_SYSCONFDIR "c:\\php5"
-
-/* Enable / Disable BCMATH extension (default: enabled) */
-#define HAVE_BCMATH 1
+#define CONFIGURATION_FILE_PATH "php.ini"
+#define PEAR_INSTALLDIR "C:\\php5\\pear"
+#define PHP_BINDIR "C:\\php5"
+#define PHP_DATADIR "C:\\php5"
+#define PHP_EXTENSION_DIR "C:\\php5"
+#define PHP_INCLUDE_PATH       ".;C:\\php5\\pear"
+#define PHP_LIBDIR "C:\\php5"
+#define PHP_LOCALSTATEDIR "C:\\php5"
+#define PHP_PREFIX "C:\\php5"
+#define PHP_SYSCONFDIR "C:\\php5"
 
 /* Enable / Disable crypt() function (default: enabled) */
 #define HAVE_CRYPT 1
 #define PHP_MD5_CRYPT 1
 #define PHP_BLOWFISH_CRYPT 0
 
-/* Enable / Disable CALENDAR extension (default: enabled) */
-#define HAVE_CALENDAR 1
-
-/* Enable / Disable CTYPE extension (default: enabled) */
-#define HAVE_CTYPE 1
-
-/* Enable / Disable FTP extension (default: enabled) */
-#define HAVE_FTP 1
-
-/* Enable / Disable MBSTRING extension (default: disabled) */
-/* #define HAVE_MBSTRING 0 */ 
-/* #define HAVE_MBREGEX  0 */ 
-/* #define HAVE_MBSTR_CN 0 */ 
-/* #define HAVE_MBSTR_JA 0 */ 
-/* #define HAVE_MBSTR_KR 0 */
-/* #define HAVE_MBSTR_RU 0 */
-/* #define HAVE_MBSTR_TW 0 */ 
-
-/* If you have the .Net SDK in your include path, define this
- * to compile .Net support into your COM extension. */
-#define HAVE_MSCOREE_H 0
-
-/* Enable / Disable ODBC extension (default: enabled) */
-#define HAVE_UODBC 1
-
-/* Enable / Disable PCRE extension (default: enabled) */
-#define HAVE_BUNDLED_PCRE      1
-#define HAVE_PCRE 1
-
-/* Enable / Disable SESSION extension (default: enabled) */
-#define HAVE_PHP_SESSION 1
-
-/* Enable / Disable TOKENIZER extension (default: enabled) */
-#define HAVE_TOKENIZER 1
-
-/* Enable / Disable WDDX extension (default: enabled) */
-#define HAVE_WDDX 1
-
-/* Enable / Disable XML extensions (default: enabled) */
-#define HAVE_LIBXML 1
-#define HAVE_DOM 1
-#define HAVE_SIMPLEXML 1
-#define HAVE_XML 1
-
-/* Enable / Disable ZLIB extension (default: enabled) */
-#define HAVE_ZLIB 1
-
-/* Enable / Disable SQLite extension (default: enabled) */
-#define HAVE_SQLITE 1
-
 /* PHP Runtime Configuration */
-#define FORCE_CGI_REDIRECT 1
 #define PHP_URL_FOPEN 1
 #define PHP_SAFE_MODE 0
 #define MAGIC_QUOTES 0
 #define USE_CONFIG_FILE 1
 #define DEFAULT_SHORT_OPEN_TAG "1"
-#define ENABLE_PATHINFO_CHECK 1
 
 /* Platform-Specific Configuration. Should not be changed. */
 #define PHP_SIGCHILD 0
 #define HAVE_LOCALECONV 1
 #define HAVE_LOCALE_H 1
 #ifndef HAVE_LIBBIND
-#define HAVE_SETVBUF 1
+# define HAVE_SETVBUF 1
 #endif
 #define HAVE_SHUTDOWN 1
 #define HAVE_SNPRINTF 1
 #define HAVE_GLOB
 #define PHP_SHLIB_SUFFIX "dll"
 #define HAVE_SQLDATASOURCES
-#define POSIX_MALLOC_THRESHOLD 10
-
-
-/*
- * defining HAVE_SOCKLEN_T prevents PHP from building with the latest platform SDK...
- * #define HAVE_SOCKLEN_T
- */
 
 /* Win32 supports strcoll */
 #define HAVE_STRCOLL 1
 #define PHP_CAN_SUPPORT_PROC_OPEN 1
 
 #define HAVE_MBLEN
+
+#undef HAVE_ATOF_ACCEPTS_NAN
+#undef HAVE_ATOF_ACCEPTS_INF
+#define HAVE_HUGE_VAL_NAN 1
+
+/* values determined by configure.js */
+
+/* undefined */
+#define CONFIGURE_COMMAND "cscript /nologo configure.js "
+
+/* undefined */
+#define HAVE_ARPA_NAMESER_H 1
+
+/* undefined */
+#define HAVE_WSPIAPI_H 1
+
+/* undefined */
+#define HAVE_GETADDRINFO 1
+
+/* undefined */
+#define HAVE_GAI_STRERROR 1
+
+/* undefined */
+#define HAVE_IPV6 1
+
+/* undefined */
+#define MEMORY_LIMIT 0
+
+/* undefined */
+#define HAVE_NEWAPIS_H 1
+
+/* CGI redirect mode */
+#define FORCE_CGI_REDIRECT 1
+
+/* Pathinfo check */
+#define ENABLE_PATHINFO_CHECK 1
+
+/* undefined */
+#define PHP_FASTCGI 1
+
+/* Have BCMATH library */
+#define HAVE_BCMATH 1
+
+/* Have calendar */
+#define HAVE_CALENDAR 1
+
+/* Have COM_DOTNET support */
+#define HAVE_COM_DOTNET 1
+
+/* undefined */
+#define HAVE_MSCOREE_H 1
+
+/* Have ctype */
+#define HAVE_CTYPE 1
+
+/* Have FTP support */
+#define HAVE_FTP 1
+
+/* undefined */
+#define HAVE_GD_H 1
+
+/* GD support */
+#define HAVE_LIBGD 1
+
+/* undefined */
+#define HAVE_ICONV_H 1
+
+/* Define if iconv extension is enabled */
+#define HAVE_ICONV 1
+
+/* Define if libiconv is available */
+#define HAVE_LIBICONV 1
+
+/* Which iconv implementation to use */
+#define PHP_ICONV_IMPL "\"libiconv\""
+
+/* Whether iconv supports errno or not */
+#define ICONV_SUPPORTS_ERRNO 1
+
+/* undefined */
+#define HAVE_LIBXML_PARSER_H 1
+
+/* LibXML support */
+#define HAVE_LIBXML 1
+
+/* ODBC support */
+#define HAVE_UODBC 1
+
+/* Using bundled PCRE library */
+#define HAVE_BUNDLED_PCRE 1
+
+/* Have PCRE library */
+#define HAVE_PCRE 1
+
+/* Session support */
+#define HAVE_PHP_SESSION 1
+
+/* undefined */
+#define HAVE_SPL 1
+
+/* SQLite support */
+#define HAVE_SQLITE 1
+
+/* undefined */
+#define PHP_CONFIG_FILE_SCAN_DIR ""
+
+/* Tokenizer support */
+#define HAVE_TOKENIZER 1
+
+/* ZLIB support */
+#define HAVE_ZLIB 1
+
+/* undefined */
+#define HAVE_ZLIB_H 1
+
+/* DOM support */
+#define HAVE_DOM 1
+
+/* Simple XML support */
+#define HAVE_SIMPLEXML 1
+
+/* WDDX support */
+#define HAVE_WDDX 1
+
+/* XML support */
+#define HAVE_XML 1
index 2dfe853c6f9e0c18928f16b93a632a2f3a3e528f..2fc451aa9ed6798ddd2bb7fa3f00a0a05749e911 100644 (file)
@@ -194,7 +194,7 @@ ADD_SOURCES("main/streams", "streams.c cast.c memory.c filter.c plain_wrapper.c
        userspace.c transports.c xp_socket.c mmap.c");
 
 ADD_SOURCES("win32", "crypt_win32.c flock.c glob.c md5crypt.c pwd.c readdir.c \
-       registry.c select.c sendmail.c time.c wfile.c winutil.c wsyslog.c");
+       registry.c select.c sendmail.c time.c wfile.c winutil.c wsyslog.c globals.c");
 
 ADD_SOURCES("regex", "regcomp.c regerror.c regexec.c regfree.c");
 
index 2c76480cead6a30e50d6cd156e90cc56e874fb31..311e2c6380b7e7f41d552ec1822836f33cfca533 100644 (file)
 #include <lmapibuf.h>
 #include "pwd.h"
 #include "grp.h"
-
-#ifndef THREAD_SAFE
-static struct passwd pwd;
-#endif
+#include "php_win32_globals.h"
 
 static char *home_dir = ".";
 static char *login_shell = "not command.com!";
@@ -44,21 +41,26 @@ getpwnam(char *name)
 char *
 getlogin()
 {
-       static char name[256];
+       char name[256];
        DWORD max_len = 256;
+       TSRMLS_FETCH();
 
+       STR_FREE(PW32G(login_name));    
        GetUserName(name, &max_len);
-       return name;
+       name[max_len] = '\0';
+       PW32G(login_name) = strdup(name);
+       return PW32G(login_name);
 }
 
 struct passwd *
 getpwuid(int user_id)
 {
-       pwd.pw_name = getlogin();
-       pwd.pw_dir = home_dir;
-       pwd.pw_shell = login_shell;
-       pwd.pw_uid = 0;
+       TSRMLS_FETCH();
+       PW32G(pwd).pw_name = getlogin();
+       PW32G(pwd).pw_dir = home_dir;
+       PW32G(pwd).pw_shell = login_shell;
+       PW32G(pwd).pw_uid = 0;
 
-       return &pwd;
+       return &PW32G(pwd);
 }
 
index 9a3e004a4d5c404bbf654f05d603160834c58eda..693f07418536ed0a6273208d4cddaa49d112d249 100644 (file)
@@ -33,6 +33,7 @@
 #include <winbase.h>
 #include <mmsystem.h>
 #include <errno.h>
+#include "php_win32_globals.h"
 
 int getfilesystemtime(struct timeval *time_Info) 
 {
@@ -51,64 +52,61 @@ __int64 ff;
 
 PHPAPI 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;
+       TSRMLS_FETCH();
 
        /* Get the time, if they want it */
        if (time_Info != NULL) {
-               if (starttime.tv_sec == 0) {
+               if (PW32G(starttime).tv_sec == 0) {
             b = QueryPerformanceFrequency(&li);
             if (!b) {
-                starttime.tv_sec = -1;
+                PW32G(starttime).tv_sec = -1;
             }
             else {
-                freq = li.QuadPart;
+                PW32G(freq) = li.QuadPart;
                 b = QueryPerformanceCounter(&li);
                 if (!b) {
-                    starttime.tv_sec = -1;
+                    PW32G(starttime).tv_sec = -1;
                 }
                 else {
-                    getfilesystemtime(&starttime);
+                    getfilesystemtime(&PW32G(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;
+                    dt = (double)timer/PW32G(freq);
+                    PW32G(starttime).tv_usec -= (int)((dt-(int)dt)*1000000);
+                    if (PW32G(starttime).tv_usec < 0) {
+                        PW32G(starttime).tv_usec += 1000000;
+                        --PW32G(starttime).tv_sec;
                     }
-                    starttime.tv_sec -= (int)dt;
+                    PW32G(starttime).tv_sec -= (int)dt;
                 }
             }
         }
-        if (starttime.tv_sec > 0) {
+        if (PW32G(starttime).tv_sec > 0) {
             b = QueryPerformanceCounter(&li);
             if (!b) {
-                starttime.tv_sec = -1;
+                PW32G(starttime).tv_sec = -1;
             }
             else {
                 timer = li.QuadPart;
-                if (timer < lasttime) {
+                if (timer < PW32G(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;
+                    dt = (double)timer/PW32G(freq);
+                    PW32G(starttime) = *time_Info;
+                    PW32G(starttime).tv_usec -= (int)((dt-(int)dt)*1000000);
+                    if (PW32G(starttime).tv_usec < 0) {
+                        PW32G(starttime).tv_usec += 1000000;
+                        --PW32G(starttime).tv_sec;
                     }
-                    starttime.tv_sec -= (int)dt;
+                    PW32G(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);
+                    PW32G(lasttime) = timer;
+                    dt = (double)timer/PW32G(freq);
+                    time_Info->tv_sec = PW32G(starttime).tv_sec + (int)dt;
+                    time_Info->tv_usec = PW32G(starttime).tv_usec + (int)((dt-(int)dt)*1000000);
                     if (time_Info->tv_usec > 1000000) {
                         time_Info->tv_usec -= 1000000;
                         ++time_Info->tv_sec;
@@ -116,7 +114,7 @@ PHPAPI int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Inf
                 }
             }
         }
-        if (starttime.tv_sec < 0) {
+        if (PW32G(starttime).tv_sec < 0) {
             getfilesystemtime(time_Info);
         }
 
@@ -144,6 +142,7 @@ void usleep(unsigned int useconds)
        CloseHandle(timer);
 }
 
+#if 0 /* looks pretty ropey in here */
 #ifdef HAVE_SETITIMER
 
 
@@ -225,3 +224,5 @@ PHPAPI int setitimer(int which, const struct itimerval *value, struct itimerval
 }
 
 #endif
+#endif
+
index 7db5156011cb59aae81a2766144ef3934aa117ab..ca1e45b9ca4f029fc8e1f1616b124c0b74a8b944 100644 (file)
 #include <fcntl.h>
 #include <process.h>
 
-#ifndef THREAD_SAFE
-static char *loghdr;                   /* log file header string */
-static HANDLE loghdl = NULL;   /* handle of event source */
-#endif
+#include "php_win32_globals.h"
 
 void closelog(void)
 {
-       DeregisterEventSource(loghdl);
-       efree(loghdr);
+       TSRMLS_FETCH();
+       DeregisterEventSource(PW32G(log_source));
+       STR_FREE(PW32G(log_header));
+       PW32G(log_header) = NULL;
 }
 
 /* Emulator for BSD syslog() routine
@@ -77,12 +76,14 @@ void syslog(int priority, const char *message, ...)
 {
        va_list args;
        LPTSTR strs[2];
-       char tmp[1024];                         /* callers must be careful not to pop this */
        unsigned short etype;
-       
+       char *tmp = NULL;
+       TSRMLS_FETCH();
+
        /* default event source */
-               if (!loghdl)
-               openlog("c-client", LOG_PID, LOG_MAIL);
+       if (!PW32G(log_source))
+               openlog("php", LOG_PID, LOG_SYSLOG);
+
        switch (priority) {                     /* translate UNIX type into NT type */
                case LOG_ALERT:
                        etype = EVENTLOG_ERROR_TYPE;
@@ -94,12 +95,13 @@ void syslog(int priority, const char *message, ...)
                        etype = EVENTLOG_WARNING_TYPE;
        }
        va_start(args, message);        /* initialize vararg mechanism */
-       vsprintf(tmp, message, args);   /* build message */
-       strs[0] = loghdr;       /* write header */
+       vspprintf(&tmp, 0, message, args);      /* build message */
+       strs[0] = PW32G(log_header);    /* write header */
        strs[1] = tmp;                          /* then the message */
        /* report the event */
-       ReportEvent(loghdl, etype, (unsigned short) priority, 2000, NULL, 2, 0, strs, NULL);
+       ReportEvent(PW32G(log_source), etype, (unsigned short) priority, 2000, NULL, 2, 0, strs, NULL);
        va_end(args);
+       efree(tmp);
 }
 
 
@@ -111,12 +113,14 @@ void syslog(int priority, const char *message, ...)
 
 void openlog(const char *ident, int logopt, int facility)
 {
-       char tmp[1024];
+       TSRMLS_FETCH();
 
-       if (loghdl) {
+       if (PW32G(log_source)) {
                closelog();
        }
-       loghdl = RegisterEventSource(NULL, ident);
-       sprintf(tmp, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid());
-       loghdr = estrdup(tmp);  /* save header for later */
+
+       STR_FREE(PW32G(log_header));
+
+       PW32G(log_source) = RegisterEventSource(NULL, ident);
+       spprintf(&PW32G(log_header), 0, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid());
 }