cvs: pecl /apc CHANGELOG apc.dsp apc.h apc_cache.c apc_cache.h apc_compile.c apc_compile.h apc_globals.h apc_lock.h apc_main.c apc_optimizer.c
apc_shm.c apc_sma.c package.xml php_apc.c
| From: | Shane Caraveo | Date: | Sun, 20 Jul 2003 00:07:02 +0000 |
| Subject: | cvs: pecl /apc CHANGELOG apc.dsp apc.h apc_cache.c apc_cache.h apc_compile.c apc_compile.h apc_globals.h apc_lock.h apc_main.c apc_optimizer.c apc_shm.c apc_sma.c package.xml php_apc.c |
||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-375@lists.php.net to get a copy of this message | ||
shane Sat Jul 19 20:07:02 2003 EDT
Added files:
/pecl/apc apc.dsp
Modified files:
/pecl/apc CHANGELOG apc.h apc_cache.c apc_cache.h apc_compile.c
apc_compile.h apc_globals.h apc_lock.h apc_main.c
apc_optimizer.c apc_shm.c apc_sma.c package.xml php_apc.c
Log:
Allow for building on windows, largly untested with some remaining issues:
- tsrm mutexes used for locking, should switch to semaphores (?)
- need to investigate further the shared memory usage, see if we can use mmap also
Index: pecl/apc/CHANGELOG diff -u pecl/apc/CHANGELOG:1.16 pecl/apc/CHANGELOG:1.17 --- pecl/apc/CHANGELOG:1.16 Sat Jun 14 00:29:00 2003 +++ pecl/apc/CHANGELOG Sat Jul 19 20:07:02 2003 @@ -1,3 +1,6 @@ +CVS: +- Win32 support added [smc 2003-07-19] + 2.0: - ground-up rewrite sharing none of the original source code [djc 2003-02-10] Index: pecl/apc/apc.h diff -u pecl/apc/apc.h:3.2 pecl/apc/apc.h:3.3 --- pecl/apc/apc.h:3.2 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc.h Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc.h,v 3.2 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc.h,v 3.3 2003/07/20 00:07:02 shane Exp $ */ #ifndef APC_H #define APC_H @@ -37,7 +37,9 @@ #include <sys/stat.h> #include <unistd.h> +#ifndef PHP_WIN32 #include "config.h" +#endif /* log levels constants (see apc_log) */ enum { APC_DEBUG, APC_NOTICE, APC_WARNING, APC_ERROR }; Index: pecl/apc/apc_cache.c diff -u pecl/apc/apc_cache.c:3.52 pecl/apc/apc_cache.c:3.53 --- pecl/apc/apc_cache.c:3.52 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_cache.c Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_cache.c,v 3.52 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_cache.c,v 3.53 2003/07/20 00:07:02 shane Exp $ */ #include "apc_cache.h" #include "apc_lock.h" @@ -324,7 +324,8 @@ /* {{{ apc_cache_make_key */ int apc_cache_make_key(apc_cache_key_t* key, const char* filename, - const char* include_path) + const char* include_path + TSRMLS_DC) { struct stat buf, *tmp_buf=NULL; @@ -334,7 +335,7 @@ return 0; if(!strcmp(SG(request_info).path_translated, filename)) { - tmp_buf = sapi_get_stat(); /* Apache has already done this stat() for us */ + tmp_buf = sapi_get_stat(TSRMLS_C); /* Apache has already done this stat() for us */ } if(tmp_buf) buf = *tmp_buf; else if (stat(filename, &buf) != 0 && Index: pecl/apc/apc_cache.h diff -u pecl/apc/apc_cache.h:3.13 pecl/apc/apc_cache.h:3.14 --- pecl/apc/apc_cache.h:3.13 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_cache.h Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_cache.h,v 3.13 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_cache.h,v 3.14 2003/07/20 00:07:02 shane Exp $ */ #ifndef APC_CACHE_H #define APC_CACHE_H @@ -127,7 +127,8 @@ */ extern int apc_cache_make_key(apc_cache_key_t* key, const char* filename, - const char* include_path); + const char* include_path + TSRMLS_DC); /* * apc_cache_make_entry creates an apc_cache_entry_t object given a filename Index: pecl/apc/apc_compile.c diff -u pecl/apc/apc_compile.c:3.5 pecl/apc/apc_compile.c:3.6 --- pecl/apc/apc_compile.c:3.5 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_compile.c Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_compile.c,v 3.5 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_compile.c,v 3.6 2003/07/20 00:07:02 shane Exp $ */ #include "apc_compile.h" #include "apc_globals.h" @@ -277,6 +277,8 @@ /* {{{ my_copy_function */ static zend_function* my_copy_function(zend_function* dst, zend_function* src, apc_malloc_t allocate) { + TSRMLS_FETCH(); + assert(src != NULL); CHECK(dst = my_bitwise_copy_function(dst, src, allocate)); @@ -290,7 +292,7 @@ case ZEND_EVAL_CODE: CHECK(apc_copy_op_array(&dst->op_array, &src->op_array, - allocate)); + allocate TSRMLS_CC)); break; default: @@ -474,7 +476,7 @@ /* }}} */ /* {{{ apc_copy_op_array */ -zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_malloc_t allocate) +zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_malloc_t allocate TSRMLS_DC) { int i; @@ -533,7 +535,7 @@ /* }}} */ /* {{{ apc_copy_new_functions */ -apc_function_t* apc_copy_new_functions(int old_count, apc_malloc_t allocate) +apc_function_t* apc_copy_new_functions(int old_count, apc_malloc_t allocate TSRMLS_DC) { apc_function_t* array; int new_count; /* number of new functions in table */ @@ -584,7 +586,7 @@ /* }}} */ /* {{{ apc_copy_new_classes */ -apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_malloc_t allocate) +apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_malloc_t allocate TSRMLS_DC) { apc_class_t* array; int new_count; /* number of new classs in table */ Index: pecl/apc/apc_compile.h diff -u pecl/apc/apc_compile.h:3.2 pecl/apc/apc_compile.h:3.3 --- pecl/apc/apc_compile.h:3.2 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_compile.h Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_compile.h,v 3.2 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_compile.h,v 3.3 2003/07/20 00:07:02 shane Exp $ */ #ifndef APC_COMPILE_H #define APC_COMPILE_H @@ -52,10 +52,10 @@ * These are the top-level copy functions. */ -extern zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_malloc_t allocate); +extern zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_malloc_t allocate TSRMLS_DC); extern zend_class_entry* apc_copy_class_entry(zend_class_entry* dst, zend_class_entry* src, apc_malloc_t allocate); -extern apc_function_t* apc_copy_new_functions(int old_count, apc_malloc_t allocate); -extern apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_malloc_t allocate); +extern apc_function_t* apc_copy_new_functions(int old_count, apc_malloc_t allocate TSRMLS_DC); +extern apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_malloc_t allocate TSRMLS_DC); /* * Deallocation functions corresponding to the copy functions above. Index: pecl/apc/apc_globals.h diff -u pecl/apc/apc_globals.h:3.3 pecl/apc/apc_globals.h:3.4 --- pecl/apc/apc_globals.h:3.3 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_globals.h Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_globals.h,v 3.3 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_globals.h,v 3.4 2003/07/20 00:07:02 shane Exp $ */ #ifndef APC_GLOBALS_H #define APC_GLOBALS_H @@ -31,7 +31,9 @@ int optimization; /* optimizer level (higher = more aggressive) */ int num_files_hint; /* parameter to apc_cache_create */ int gc_ttl; /* parameter to apc_cache_create */ +#if APC_MMAP char *mmap_file_mask; /* mktemp-style file-mask to pass to mmap */ +#endif char** filters; /* array of regex filters that prevent caching */ /* module variables */ Index: pecl/apc/apc_lock.h diff -u pecl/apc/apc_lock.h:3.5 pecl/apc/apc_lock.h:3.6 --- pecl/apc/apc_lock.h:3.5 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_lock.h Sat Jul 19 20:07:02 2003 @@ -18,9 +18,17 @@ #include "apc_sem.h" #include "apc_fcntl.h" +#ifndef PHP_WIN32 #include "config.h" +#endif -#ifdef APC_SEM_LOCKS +#ifdef TSRM_LOCKS +/* quick & dirty: use TSRM mutex locks for now */ +#define apc_lck_create(a,b,c) (int)tsrm_mutex_alloc() +#define apc_lck_destroy(a) tsrm_mutex_free((MUTEX_T)a) +#define apc_lck_lock(a) tsrm_mutex_lock((MUTEX_T)a) +#define apc_lck_unlock(a) tsrm_mutex_unlock((MUTEX_T)a) +#elif defined(APC_SEM_LOCKS) #define apc_lck_create(a,b,c) apc_sem_create(NULL,(b),(c)) #define apc_lck_destroy(a) apc_sem_destroy(a) #define apc_lck_lock(a) apc_sem_lock(a) Index: pecl/apc/apc_main.c diff -u pecl/apc/apc_main.c:3.3 pecl/apc/apc_main.c:3.4 --- pecl/apc/apc_main.c:3.3 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_main.c Sat Jul 19 20:07:02 2003 @@ -14,8 +14,9 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_main.c,v 3.3 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_main.c,v 3.4 2003/07/20 00:07:02 shane Exp $ */ +#include "apc_php.h" #include "apc_main.h" #include "apc.h" #include "apc_cache.h" @@ -28,16 +29,16 @@ /* {{{ module variables */ /* pointer to the original Zend engine compile_file function */ -static ZEND_API zend_op_array* (*old_compile_file) +static zend_op_array* (*old_compile_file) (zend_file_handle*, int TSRMLS_DC); /* pointer to the original Zend engine execute function */ -static ZEND_API void (*old_execute)(zend_op_array* TSRMLS_DC); +static void (*old_execute)(zend_op_array* TSRMLS_DC); /* }}} */ /* {{{ install_function */ -static int install_function(apc_function_t fn) +static int install_function(apc_function_t fn TSRMLS_DC) { int status = zend_hash_add(EG(function_table), @@ -56,7 +57,7 @@ /* }}} */ /* {{{ install_class */ -static int install_class(apc_class_t cl) +static int install_class(apc_class_t cl TSRMLS_DC) { zend_class_entry* class_entry = cl.class_entry; zend_class_entry* parent; @@ -99,7 +100,7 @@ /* }}} */ /* {{{ cached_compile */ -static zend_op_array* cached_compile() +static zend_op_array* cached_compile(TSRMLS_D) { apc_cache_entry_t* cache_entry; int i; @@ -109,13 +110,13 @@ if (cache_entry->functions) { for (i = 0; cache_entry->functions[i].function != NULL; i++) { - install_function(cache_entry->functions[i]); + install_function(cache_entry->functions[i] TSRMLS_CC); } } if (cache_entry->classes) { for (i = 0; cache_entry->classes[i].class_entry != NULL; i++) { - install_class(cache_entry->classes[i]); + install_class(cache_entry->classes[i] TSRMLS_CC); } } @@ -131,6 +132,7 @@ apc_class_t* classes) { apc_cache_entry_t* cache_entry; + TSRMLS_FETCH(); /* Abort if any component could not be allocated */ if (!op_array || !functions || !classes) { @@ -148,7 +150,7 @@ /* {{{ my_compile_file Overrides zend_compile_file */ -static ZEND_API zend_op_array* my_compile_file(zend_file_handle* h, +static zend_op_array* my_compile_file(zend_file_handle* h, int type TSRMLS_DC) { apc_cache_key_t key; @@ -164,7 +166,7 @@ } /* try to create a cache key; if we fail, give up on caching */ - if (!apc_cache_make_key(&key, h->filename, PG(include_path))) { + if (!apc_cache_make_key(&key, h->filename, PG(include_path) TSRMLS_CC)) { return old_compile_file(h, type TSRMLS_CC); } @@ -173,7 +175,7 @@ if (cache_entry != NULL) { zend_llist_add_element(&CG(open_files), h); /* XXX kludge */ apc_stack_push(APCG(cache_stack), cache_entry); - return cached_compile(); + return cached_compile(TSRMLS_C); } /* remember how many functions and classes existed before compilation */ @@ -190,18 +192,18 @@ cache_compile_results( key, h->opened_path, - apc_copy_op_array(NULL, op_array, apc_sma_malloc), - apc_copy_new_functions(num_functions, apc_sma_malloc), - apc_copy_new_classes(op_array, num_classes, apc_sma_malloc)); + apc_copy_op_array(NULL, op_array, apc_sma_malloc TSRMLS_CC), + apc_copy_new_functions(num_functions, apc_sma_malloc TSRMLS_CC), + apc_copy_new_classes(op_array, num_classes, apc_sma_malloc TSRMLS_CC)); return op_array; } /* }}} */ /* {{{ my_execute */ -static ZEND_API void my_execute(zend_op_array* op_array TSRMLS_DC) +static void my_execute(zend_op_array* op_array TSRMLS_DC) { - old_execute(op_array); + old_execute(op_array TSRMLS_CC); if (apc_stack_size(APCG(cache_stack)) > 0) { apc_cache_entry_t* cache_entry = @@ -220,6 +222,7 @@ int apc_module_init() { + TSRMLS_FETCH(); /* apc initialization */ #if APC_MMAP apc_sma_init(APCG(shm_segments), APCG(shm_size)*1024*1024, APCG(mmap_file_mask)); @@ -238,7 +241,10 @@ old_execute = zend_execute; zend_execute = my_execute; +#if 0 + /* startup output is not good for stuff like fastcgi */ apc_log(APC_NOTICE, "APC version %s -- startup complete", apc_version()); +#endif APCG(initialized) = 1; return 0; @@ -246,6 +252,7 @@ int apc_module_shutdown() { + TSRMLS_FETCH(); if (!APCG(initialized)) return 0; @@ -270,6 +277,7 @@ int apc_request_init() { + TSRMLS_FETCH(); apc_stack_clear(APCG(cache_stack)); return 0; } @@ -284,6 +292,7 @@ /* {{{ apc_deactivate */ void apc_deactivate() { + TSRMLS_FETCH(); /* The execution stack was unwound, which prevented us from decrementing * the reference counts on active cache entries in `my_execute`. */ Index: pecl/apc/apc_optimizer.c diff -u pecl/apc/apc_optimizer.c:3.23 pecl/apc/apc_optimizer.c:3.24 --- pecl/apc/apc_optimizer.c:3.23 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_optimizer.c Sat Jul 19 20:07:02 2003 @@ -169,6 +169,7 @@ { zval* result = 0; int (*binary_op)(zval*, zval*, zval* TSRMLS_DC) = 0; + TSRMLS_FETCH(); // TODO: add cases for other deterministic binary ops! // TODO: extend to this work with the few unary ops @@ -202,7 +203,7 @@ if (binary_op) { ALLOC_INIT_ZVAL(result); - binary_op(result, &op->op1.u.constant, &op->op2.u.constant); + binary_op(result, &op->op1.u.constant, &op->op2.u.constant TSRMLS_CC); return result; } Index: pecl/apc/apc_shm.c diff -u pecl/apc/apc_shm.c:3.5 pecl/apc/apc_shm.c:3.6 --- pecl/apc/apc_shm.c:3.5 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_shm.c Sat Jul 19 20:07:02 2003 @@ -14,14 +14,20 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_shm.c,v 3.5 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_shm.c,v 3.6 2003/07/20 00:07:02 shane Exp $ */ #include "apc_shm.h" #include "apc.h" #include <sys/types.h> +#ifdef PHP_WIN32 +/* shm functions are available in TSRM */ +#include <tsrm/tsrm_win32.h> +#define key_t long +#else #include <sys/ipc.h> #include <sys/shm.h> #include <sys/stat.h> +#endif #ifndef SHM_R # define SHM_R 0444 /* read permission */ @@ -37,11 +43,14 @@ key_t key; /* shm key returned by ftok */ key = IPC_PRIVATE; +#ifndef PHP_WIN32 + /* no ftok yet for win32 */ if (pathname != NULL) { if ((key = ftok(pathname, proj)) < 0) { apc_eprint("apc_shm_create: ftok failed:"); } } +#endif oflag = IPC_CREAT | SHM_R | SHM_A; if ((shmid = shmget(key, size, oflag)) < 0) { Index: pecl/apc/apc_sma.c diff -u pecl/apc/apc_sma.c:1.12 pecl/apc/apc_sma.c:1.13 --- pecl/apc/apc_sma.c:1.12 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_sma.c Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_sma.c,v 1.12 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_sma.c,v 1.13 2003/07/20 00:07:02 shane Exp $ */ #include "apc_sma.h" #include "apc.h" @@ -303,7 +303,7 @@ off = sma_allocate(sma_shmaddrs[sma_lastseg], n); if (off != -1) { - void* p = sma_shmaddrs[sma_lastseg] + off; + void* p = (void *)(((unsigned int)(sma_shmaddrs[sma_lastseg])) + off); apc_lck_unlock(sma_lock); return p; } @@ -314,7 +314,7 @@ } off = sma_allocate(sma_shmaddrs[i], n); if (off != -1) { - void* p = sma_shmaddrs[i] + off; + void* p = (void *)(((unsigned int)(sma_shmaddrs[i])) + off); apc_lck_unlock(sma_lock); sma_lastseg = i; return p; @@ -339,8 +339,9 @@ assert(sma_initialized); for (i = 0; i < sma_numseg; i++) { - if (p >= sma_shmaddrs[i] && (p - sma_shmaddrs[i]) < sma_segsize) { - sma_deallocate(sma_shmaddrs[i], p - sma_shmaddrs[i]); + unsigned int d_size = (unsigned int)p - (unsigned int)(sma_shmaddrs[i]); + if (p >= sma_shmaddrs[i] && d_size < sma_segsize) { + sma_deallocate(sma_shmaddrs[i], d_size); apc_lck_unlock(sma_lock); return; } Index: pecl/apc/package.xml diff -u pecl/apc/package.xml:1.2 pecl/apc/package.xml:1.3 --- pecl/apc/package.xml:1.2 Tue Jul 1 00:15:44 2003 +++ pecl/apc/package.xml Sat Jul 19 20:07:02 2003 @@ -23,11 +23,12 @@ <license>PHP</license> <release> <state>stable</state> - <version>2.0</version> + <version>2.0.1</version> <date>2003-07-01</date> <notes> -Complete rework. +Win32 support added. </notes> + </release> <filelist> <file role="doc" name="CHANGELOG" /> <file role="doc" name="INSTALL" /> @@ -35,6 +36,7 @@ <file role="doc" name="NOTICE" /> <file role="src" name="Makefile.in" /> <file role="src" name="apc.c" /> + <file role="src" name="apc.dsp" /> <file role="src" name="apc.h" /> <file role="src" name="apc_cache.c" /> <file role="src" name="apc_cache.h" /> @@ -68,7 +70,16 @@ <file role="src" name="php_apc.c" /> <file role="src" name="php_apc.h" /> </filelist> - </release> + <changelog> + <release> + <state>stable</state> + <version>2.0</version> + <date>2003-07-01</date> + <notes> +Complete rework. + </notes> + </release> + </changelog> </package> <!-- vim:et:ts=1:sw=1 Index: pecl/apc/php_apc.c diff -u pecl/apc/php_apc.c:3.25 pecl/apc/php_apc.c:3.26 --- pecl/apc/php_apc.c:3.25 Sat Jun 28 22:51:39 2003 +++ pecl/apc/php_apc.c Sat Jul 19 20:07:02 2003 @@ -14,7 +14,15 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_apc.c,v 3.25 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: php_apc.c,v 3.26 2003/07/20 00:07:02 shane Exp $ */ + +#ifdef PHP_WIN32 +/* XXX lame hack, for some reason, the ini entries are all messed + up if PHP_EXPORTS is not defined, however, this should *not* + be defined in extensions, and if defined for the project, core_globals_id + is not properly imported (used by the PG macro) */ +#define PHP_EXPORTS +#endif #include "php_apc.h" #include "apc_cache.h" @@ -47,6 +55,7 @@ #ifdef ZTS static void php_apc_shutdown_globals(zend_apc_globals* apc_globals TSRMLS_DC) { + char* p; /* deallocate the ignore patterns */ if (apc_globals->filters != NULL) { for (p = apc_globals->filters[0]; p != NULL; p++) { @@ -96,7 +105,7 @@ #else php_info_print_table_row(2, "MMAP Support", "Disabled"); #endif - php_info_print_table_row(2, "Revision", "$Revision: 3.25 $"); + php_info_print_table_row(2, "Revision", "$Revision: 3.26 $"); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); DISPLAY_INI_ENTRIES(); php_info_print_table_end(); Index: pecl/apc/apc.dsp +++ pecl/apc/apc.dsp
Index: pecl/apc/CHANGELOG diff -u pecl/apc/CHANGELOG:1.16 pecl/apc/CHANGELOG:1.17 --- pecl/apc/CHANGELOG:1.16 Sat Jun 14 00:29:00 2003 +++ pecl/apc/CHANGELOG Sat Jul 19 20:07:02 2003 @@ -1,3 +1,6 @@ +CVS: +- Win32 support added [smc 2003-07-19] + 2.0: - ground-up rewrite sharing none of the original source code [djc 2003-02-10] Index: pecl/apc/apc.h diff -u pecl/apc/apc.h:3.2 pecl/apc/apc.h:3.3 --- pecl/apc/apc.h:3.2 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc.h Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc.h,v 3.2 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc.h,v 3.3 2003/07/20 00:07:02 shane Exp $ */ #ifndef APC_H #define APC_H @@ -37,7 +37,9 @@ #include <sys/stat.h> #include <unistd.h> +#ifndef PHP_WIN32 #include "config.h" +#endif /* log levels constants (see apc_log) */ enum { APC_DEBUG, APC_NOTICE, APC_WARNING, APC_ERROR }; Index: pecl/apc/apc_cache.c diff -u pecl/apc/apc_cache.c:3.52 pecl/apc/apc_cache.c:3.53 --- pecl/apc/apc_cache.c:3.52 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_cache.c Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_cache.c,v 3.52 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_cache.c,v 3.53 2003/07/20 00:07:02 shane Exp $ */ #include "apc_cache.h" #include "apc_lock.h" @@ -324,7 +324,8 @@ /* {{{ apc_cache_make_key */ int apc_cache_make_key(apc_cache_key_t* key, const char* filename, - const char* include_path) + const char* include_path + TSRMLS_DC) { struct stat buf, *tmp_buf=NULL; @@ -334,7 +335,7 @@ return 0; if(!strcmp(SG(request_info).path_translated, filename)) { - tmp_buf = sapi_get_stat(); /* Apache has already done this stat() for us */ + tmp_buf = sapi_get_stat(TSRMLS_C); /* Apache has already done this stat() for us */ } if(tmp_buf) buf = *tmp_buf; else if (stat(filename, &buf) != 0 && Index: pecl/apc/apc_cache.h diff -u pecl/apc/apc_cache.h:3.13 pecl/apc/apc_cache.h:3.14 --- pecl/apc/apc_cache.h:3.13 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_cache.h Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_cache.h,v 3.13 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_cache.h,v 3.14 2003/07/20 00:07:02 shane Exp $ */ #ifndef APC_CACHE_H #define APC_CACHE_H @@ -127,7 +127,8 @@ */ extern int apc_cache_make_key(apc_cache_key_t* key, const char* filename, - const char* include_path); + const char* include_path + TSRMLS_DC); /* * apc_cache_make_entry creates an apc_cache_entry_t object given a filename Index: pecl/apc/apc_compile.c diff -u pecl/apc/apc_compile.c:3.5 pecl/apc/apc_compile.c:3.6 --- pecl/apc/apc_compile.c:3.5 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_compile.c Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_compile.c,v 3.5 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_compile.c,v 3.6 2003/07/20 00:07:02 shane Exp $ */ #include "apc_compile.h" #include "apc_globals.h" @@ -277,6 +277,8 @@ /* {{{ my_copy_function */ static zend_function* my_copy_function(zend_function* dst, zend_function* src, apc_malloc_t allocate) { + TSRMLS_FETCH(); + assert(src != NULL); CHECK(dst = my_bitwise_copy_function(dst, src, allocate)); @@ -290,7 +292,7 @@ case ZEND_EVAL_CODE: CHECK(apc_copy_op_array(&dst->op_array, &src->op_array, - allocate)); + allocate TSRMLS_CC)); break; default: @@ -474,7 +476,7 @@ /* }}} */ /* {{{ apc_copy_op_array */ -zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_malloc_t allocate) +zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_malloc_t allocate TSRMLS_DC) { int i; @@ -533,7 +535,7 @@ /* }}} */ /* {{{ apc_copy_new_functions */ -apc_function_t* apc_copy_new_functions(int old_count, apc_malloc_t allocate) +apc_function_t* apc_copy_new_functions(int old_count, apc_malloc_t allocate TSRMLS_DC) { apc_function_t* array; int new_count; /* number of new functions in table */ @@ -584,7 +586,7 @@ /* }}} */ /* {{{ apc_copy_new_classes */ -apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_malloc_t allocate) +apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_malloc_t allocate TSRMLS_DC) { apc_class_t* array; int new_count; /* number of new classs in table */ Index: pecl/apc/apc_compile.h diff -u pecl/apc/apc_compile.h:3.2 pecl/apc/apc_compile.h:3.3 --- pecl/apc/apc_compile.h:3.2 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_compile.h Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_compile.h,v 3.2 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_compile.h,v 3.3 2003/07/20 00:07:02 shane Exp $ */ #ifndef APC_COMPILE_H #define APC_COMPILE_H @@ -52,10 +52,10 @@ * These are the top-level copy functions. */ -extern zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_malloc_t allocate); +extern zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_malloc_t allocate TSRMLS_DC); extern zend_class_entry* apc_copy_class_entry(zend_class_entry* dst, zend_class_entry* src, apc_malloc_t allocate); -extern apc_function_t* apc_copy_new_functions(int old_count, apc_malloc_t allocate); -extern apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_malloc_t allocate); +extern apc_function_t* apc_copy_new_functions(int old_count, apc_malloc_t allocate TSRMLS_DC); +extern apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_malloc_t allocate TSRMLS_DC); /* * Deallocation functions corresponding to the copy functions above. Index: pecl/apc/apc_globals.h diff -u pecl/apc/apc_globals.h:3.3 pecl/apc/apc_globals.h:3.4 --- pecl/apc/apc_globals.h:3.3 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_globals.h Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_globals.h,v 3.3 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_globals.h,v 3.4 2003/07/20 00:07:02 shane Exp $ */ #ifndef APC_GLOBALS_H #define APC_GLOBALS_H @@ -31,7 +31,9 @@ int optimization; /* optimizer level (higher = more aggressive) */ int num_files_hint; /* parameter to apc_cache_create */ int gc_ttl; /* parameter to apc_cache_create */ +#if APC_MMAP char *mmap_file_mask; /* mktemp-style file-mask to pass to mmap */ +#endif char** filters; /* array of regex filters that prevent caching */ /* module variables */ Index: pecl/apc/apc_lock.h diff -u pecl/apc/apc_lock.h:3.5 pecl/apc/apc_lock.h:3.6 --- pecl/apc/apc_lock.h:3.5 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_lock.h Sat Jul 19 20:07:02 2003 @@ -18,9 +18,17 @@ #include "apc_sem.h" #include "apc_fcntl.h" +#ifndef PHP_WIN32 #include "config.h" +#endif -#ifdef APC_SEM_LOCKS +#ifdef TSRM_LOCKS +/* quick & dirty: use TSRM mutex locks for now */ +#define apc_lck_create(a,b,c) (int)tsrm_mutex_alloc() +#define apc_lck_destroy(a) tsrm_mutex_free((MUTEX_T)a) +#define apc_lck_lock(a) tsrm_mutex_lock((MUTEX_T)a) +#define apc_lck_unlock(a) tsrm_mutex_unlock((MUTEX_T)a) +#elif defined(APC_SEM_LOCKS) #define apc_lck_create(a,b,c) apc_sem_create(NULL,(b),(c)) #define apc_lck_destroy(a) apc_sem_destroy(a) #define apc_lck_lock(a) apc_sem_lock(a) Index: pecl/apc/apc_main.c diff -u pecl/apc/apc_main.c:3.3 pecl/apc/apc_main.c:3.4 --- pecl/apc/apc_main.c:3.3 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_main.c Sat Jul 19 20:07:02 2003 @@ -14,8 +14,9 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_main.c,v 3.3 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_main.c,v 3.4 2003/07/20 00:07:02 shane Exp $ */ +#include "apc_php.h" #include "apc_main.h" #include "apc.h" #include "apc_cache.h" @@ -28,16 +29,16 @@ /* {{{ module variables */ /* pointer to the original Zend engine compile_file function */ -static ZEND_API zend_op_array* (*old_compile_file) +static zend_op_array* (*old_compile_file) (zend_file_handle*, int TSRMLS_DC); /* pointer to the original Zend engine execute function */ -static ZEND_API void (*old_execute)(zend_op_array* TSRMLS_DC); +static void (*old_execute)(zend_op_array* TSRMLS_DC); /* }}} */ /* {{{ install_function */ -static int install_function(apc_function_t fn) +static int install_function(apc_function_t fn TSRMLS_DC) { int status = zend_hash_add(EG(function_table), @@ -56,7 +57,7 @@ /* }}} */ /* {{{ install_class */ -static int install_class(apc_class_t cl) +static int install_class(apc_class_t cl TSRMLS_DC) { zend_class_entry* class_entry = cl.class_entry; zend_class_entry* parent; @@ -99,7 +100,7 @@ /* }}} */ /* {{{ cached_compile */ -static zend_op_array* cached_compile() +static zend_op_array* cached_compile(TSRMLS_D) { apc_cache_entry_t* cache_entry; int i; @@ -109,13 +110,13 @@ if (cache_entry->functions) { for (i = 0; cache_entry->functions[i].function != NULL; i++) { - install_function(cache_entry->functions[i]); + install_function(cache_entry->functions[i] TSRMLS_CC); } } if (cache_entry->classes) { for (i = 0; cache_entry->classes[i].class_entry != NULL; i++) { - install_class(cache_entry->classes[i]); + install_class(cache_entry->classes[i] TSRMLS_CC); } } @@ -131,6 +132,7 @@ apc_class_t* classes) { apc_cache_entry_t* cache_entry; + TSRMLS_FETCH(); /* Abort if any component could not be allocated */ if (!op_array || !functions || !classes) { @@ -148,7 +150,7 @@ /* {{{ my_compile_file Overrides zend_compile_file */ -static ZEND_API zend_op_array* my_compile_file(zend_file_handle* h, +static zend_op_array* my_compile_file(zend_file_handle* h, int type TSRMLS_DC) { apc_cache_key_t key; @@ -164,7 +166,7 @@ } /* try to create a cache key; if we fail, give up on caching */ - if (!apc_cache_make_key(&key, h->filename, PG(include_path))) { + if (!apc_cache_make_key(&key, h->filename, PG(include_path) TSRMLS_CC)) { return old_compile_file(h, type TSRMLS_CC); } @@ -173,7 +175,7 @@ if (cache_entry != NULL) { zend_llist_add_element(&CG(open_files), h); /* XXX kludge */ apc_stack_push(APCG(cache_stack), cache_entry); - return cached_compile(); + return cached_compile(TSRMLS_C); } /* remember how many functions and classes existed before compilation */ @@ -190,18 +192,18 @@ cache_compile_results( key, h->opened_path, - apc_copy_op_array(NULL, op_array, apc_sma_malloc), - apc_copy_new_functions(num_functions, apc_sma_malloc), - apc_copy_new_classes(op_array, num_classes, apc_sma_malloc)); + apc_copy_op_array(NULL, op_array, apc_sma_malloc TSRMLS_CC), + apc_copy_new_functions(num_functions, apc_sma_malloc TSRMLS_CC), + apc_copy_new_classes(op_array, num_classes, apc_sma_malloc TSRMLS_CC)); return op_array; } /* }}} */ /* {{{ my_execute */ -static ZEND_API void my_execute(zend_op_array* op_array TSRMLS_DC) +static void my_execute(zend_op_array* op_array TSRMLS_DC) { - old_execute(op_array); + old_execute(op_array TSRMLS_CC); if (apc_stack_size(APCG(cache_stack)) > 0) { apc_cache_entry_t* cache_entry = @@ -220,6 +222,7 @@ int apc_module_init() { + TSRMLS_FETCH(); /* apc initialization */ #if APC_MMAP apc_sma_init(APCG(shm_segments), APCG(shm_size)*1024*1024, APCG(mmap_file_mask)); @@ -238,7 +241,10 @@ old_execute = zend_execute; zend_execute = my_execute; +#if 0 + /* startup output is not good for stuff like fastcgi */ apc_log(APC_NOTICE, "APC version %s -- startup complete", apc_version()); +#endif APCG(initialized) = 1; return 0; @@ -246,6 +252,7 @@ int apc_module_shutdown() { + TSRMLS_FETCH(); if (!APCG(initialized)) return 0; @@ -270,6 +277,7 @@ int apc_request_init() { + TSRMLS_FETCH(); apc_stack_clear(APCG(cache_stack)); return 0; } @@ -284,6 +292,7 @@ /* {{{ apc_deactivate */ void apc_deactivate() { + TSRMLS_FETCH(); /* The execution stack was unwound, which prevented us from decrementing * the reference counts on active cache entries in `my_execute`. */ Index: pecl/apc/apc_optimizer.c diff -u pecl/apc/apc_optimizer.c:3.23 pecl/apc/apc_optimizer.c:3.24 --- pecl/apc/apc_optimizer.c:3.23 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_optimizer.c Sat Jul 19 20:07:02 2003 @@ -169,6 +169,7 @@ { zval* result = 0; int (*binary_op)(zval*, zval*, zval* TSRMLS_DC) = 0; + TSRMLS_FETCH(); // TODO: add cases for other deterministic binary ops! // TODO: extend to this work with the few unary ops @@ -202,7 +203,7 @@ if (binary_op) { ALLOC_INIT_ZVAL(result); - binary_op(result, &op->op1.u.constant, &op->op2.u.constant); + binary_op(result, &op->op1.u.constant, &op->op2.u.constant TSRMLS_CC); return result; } Index: pecl/apc/apc_shm.c diff -u pecl/apc/apc_shm.c:3.5 pecl/apc/apc_shm.c:3.6 --- pecl/apc/apc_shm.c:3.5 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_shm.c Sat Jul 19 20:07:02 2003 @@ -14,14 +14,20 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_shm.c,v 3.5 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_shm.c,v 3.6 2003/07/20 00:07:02 shane Exp $ */ #include "apc_shm.h" #include "apc.h" #include <sys/types.h> +#ifdef PHP_WIN32 +/* shm functions are available in TSRM */ +#include <tsrm/tsrm_win32.h> +#define key_t long +#else #include <sys/ipc.h> #include <sys/shm.h> #include <sys/stat.h> +#endif #ifndef SHM_R # define SHM_R 0444 /* read permission */ @@ -37,11 +43,14 @@ key_t key; /* shm key returned by ftok */ key = IPC_PRIVATE; +#ifndef PHP_WIN32 + /* no ftok yet for win32 */ if (pathname != NULL) { if ((key = ftok(pathname, proj)) < 0) { apc_eprint("apc_shm_create: ftok failed:"); } } +#endif oflag = IPC_CREAT | SHM_R | SHM_A; if ((shmid = shmget(key, size, oflag)) < 0) { Index: pecl/apc/apc_sma.c diff -u pecl/apc/apc_sma.c:1.12 pecl/apc/apc_sma.c:1.13 --- pecl/apc/apc_sma.c:1.12 Sat Jun 28 22:51:39 2003 +++ pecl/apc/apc_sma.c Sat Jul 19 20:07:02 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_sma.c,v 1.12 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: apc_sma.c,v 1.13 2003/07/20 00:07:02 shane Exp $ */ #include "apc_sma.h" #include "apc.h" @@ -303,7 +303,7 @@ off = sma_allocate(sma_shmaddrs[sma_lastseg], n); if (off != -1) { - void* p = sma_shmaddrs[sma_lastseg] + off; + void* p = (void *)(((unsigned int)(sma_shmaddrs[sma_lastseg])) + off); apc_lck_unlock(sma_lock); return p; } @@ -314,7 +314,7 @@ } off = sma_allocate(sma_shmaddrs[i], n); if (off != -1) { - void* p = sma_shmaddrs[i] + off; + void* p = (void *)(((unsigned int)(sma_shmaddrs[i])) + off); apc_lck_unlock(sma_lock); sma_lastseg = i; return p; @@ -339,8 +339,9 @@ assert(sma_initialized); for (i = 0; i < sma_numseg; i++) { - if (p >= sma_shmaddrs[i] && (p - sma_shmaddrs[i]) < sma_segsize) { - sma_deallocate(sma_shmaddrs[i], p - sma_shmaddrs[i]); + unsigned int d_size = (unsigned int)p - (unsigned int)(sma_shmaddrs[i]); + if (p >= sma_shmaddrs[i] && d_size < sma_segsize) { + sma_deallocate(sma_shmaddrs[i], d_size); apc_lck_unlock(sma_lock); return; } Index: pecl/apc/package.xml diff -u pecl/apc/package.xml:1.2 pecl/apc/package.xml:1.3 --- pecl/apc/package.xml:1.2 Tue Jul 1 00:15:44 2003 +++ pecl/apc/package.xml Sat Jul 19 20:07:02 2003 @@ -23,11 +23,12 @@ <license>PHP</license> <release> <state>stable</state> - <version>2.0</version> + <version>2.0.1</version> <date>2003-07-01</date> <notes> -Complete rework. +Win32 support added. </notes> + </release> <filelist> <file role="doc" name="CHANGELOG" /> <file role="doc" name="INSTALL" /> @@ -35,6 +36,7 @@ <file role="doc" name="NOTICE" /> <file role="src" name="Makefile.in" /> <file role="src" name="apc.c" /> + <file role="src" name="apc.dsp" /> <file role="src" name="apc.h" /> <file role="src" name="apc_cache.c" /> <file role="src" name="apc_cache.h" /> @@ -68,7 +70,16 @@ <file role="src" name="php_apc.c" /> <file role="src" name="php_apc.h" /> </filelist> - </release> + <changelog> + <release> + <state>stable</state> + <version>2.0</version> + <date>2003-07-01</date> + <notes> +Complete rework. + </notes> + </release> + </changelog> </package> <!-- vim:et:ts=1:sw=1 Index: pecl/apc/php_apc.c diff -u pecl/apc/php_apc.c:3.25 pecl/apc/php_apc.c:3.26 --- pecl/apc/php_apc.c:3.25 Sat Jun 28 22:51:39 2003 +++ pecl/apc/php_apc.c Sat Jul 19 20:07:02 2003 @@ -14,7 +14,15 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_apc.c,v 3.25 2003/06/29 02:51:39 gschlossnagle Exp $ */ +/* $Id: php_apc.c,v 3.26 2003/07/20 00:07:02 shane Exp $ */ + +#ifdef PHP_WIN32 +/* XXX lame hack, for some reason, the ini entries are all messed + up if PHP_EXPORTS is not defined, however, this should *not* + be defined in extensions, and if defined for the project, core_globals_id + is not properly imported (used by the PG macro) */ +#define PHP_EXPORTS +#endif #include "php_apc.h" #include "apc_cache.h" @@ -47,6 +55,7 @@ #ifdef ZTS static void php_apc_shutdown_globals(zend_apc_globals* apc_globals TSRMLS_DC) { + char* p; /* deallocate the ignore patterns */ if (apc_globals->filters != NULL) { for (p = apc_globals->filters[0]; p != NULL; p++) { @@ -96,7 +105,7 @@ #else php_info_print_table_row(2, "MMAP Support", "Disabled"); #endif - php_info_print_table_row(2, "Revision", "$Revision: 3.25 $"); + php_info_print_table_row(2, "Revision", "$Revision: 3.26 $"); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); DISPLAY_INI_ENTRIES(); php_info_print_table_end(); Index: pecl/apc/apc.dsp +++ pecl/apc/apc.dsp