Changeset 11
- Timestamp:
- 05/24/2006 09:52:48 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 14 modified
-
Makefile.frag (modified) (2 diffs)
-
config.m4 (modified) (6 diffs)
-
config.w32 (added)
-
coverage.c (modified) (4 diffs)
-
lock.c (modified) (7 diffs)
-
mmap.c (modified) (10 diffs)
-
myshm.h (modified) (1 diff)
-
processor/main.m4 (modified) (1 diff)
-
processor/processor.m4 (modified) (6 diffs)
-
processor/string.m4 (modified) (1 diff)
-
processor/struct.m4 (modified) (3 diffs)
-
stack.c (modified) (1 diff)
-
utils.c (modified) (2 diffs)
-
xcache.c (modified) (25 diffs)
-
xcache.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.frag
r6 r11 8 8 9 9 $(XCACHE_INCLUDES_I): $(XCACHE_INCLUDES_SRC) $(srcdir)/xcache.h 10 $(CC) -I. -I$(srcdir) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -E $(XCACHE_INCLUDES_SRC) -o $(XCACHE_INCLUDES_I)10 $(CC) -I. -I$(srcdir) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -E $(XCACHE_INCLUDES_SRC) -o $(XCACHE_INCLUDES_I) 11 11 12 12 $(XCACHE_STRUCT_OUT): $(XCACHE_INCLUDES_I) $(srcdir)/mkstructinfo.awk … … 14 14 15 15 $(XCACHE_PROC_OUT): $(XCACHE_PROC_SRC) $(XCACHE_STRUCT_OUT) $(XCACHE_PROC_SOURCES) 16 m4 -D srcdir="$(srcdir)/" -D builddir="$(builddir)" $(XCACHE_ENABLE_TEST) -E $(XCACHE_PROC_SRC) > $(XCACHE_PROC_OUT).tmp && mv -f $(XCACHE_PROC_OUT).tmp $(XCACHE_PROC_OUT) 16 $(M4) -D srcdir="$(srcdir)" -D builddir="$(builddir)" $(XCACHE_ENABLE_TEST) -E $(XCACHE_PROC_SRC) > $(XCACHE_PROC_OUT).tmp 17 mv -f $(XCACHE_PROC_OUT).tmp $(XCACHE_PROC_OUT) 17 18 18 19 $(XCACHE_PROC_H): $(XCACHE_PROC_OUT) 19 grep -F 'export: ' $(XCACHE_PROC_OUT) | sed -r 's/.*export:(.*):export.*/\1/g' | $(XCACHE_INDENT) > $(XCACHE_PROC_H).tmp && mv -f $(XCACHE_PROC_H).tmp $(XCACHE_PROC_H) 20 $(GREP) -F 'export: ' $(XCACHE_PROC_OUT) | $(SED) -r 's/.*export:(.*):export.*/\1/g' | $(XCACHE_INDENT) > $(XCACHE_PROC_H).tmp 21 mv -f $(XCACHE_PROC_H).tmp $(XCACHE_PROC_H) 20 22 21 23 $(XCACHE_PROC_C): $(XCACHE_PROC_OUT) $(XCACHE_PROC_H) 22 cat $(XCACHE_PROC_OUT) | $(XCACHE_INDENT) > $(XCACHE_PROC_C).tmp && mv -f $(XCACHE_PROC_C).tmp $(XCACHE_PROC_C) 24 $(XCACHE_INDENT) < $(XCACHE_PROC_OUT) > $(XCACHE_PROC_C).tmp 25 mv -f $(XCACHE_PROC_C).tmp $(XCACHE_PROC_C) 23 26 24 27 $(builddir)/processor.lo: $(XCACHE_PROC_C) $(XCACHE_PROC_H) $(srcdir)/processor.c -
trunk/config.m4
r8 r11 1 dnl2 dnl $Id:$3 1 dnl vim:ts=2:sw=2:expandtab 4 2 5 3 AC_DEFUN([XCACHE_OPTION], [ 6 PHP_ARG_ENABLE(xcache-$1, for XC ACHE$1,7 [ --enable-xcache-$2 XC ACHE: $4], no, no)8 if test "$PHP_$3" = "yes"; then4 PHP_ARG_ENABLE(xcache-$1, for XCache $1, 5 [ --enable-xcache-$2 XCache: $4], no, no) 6 if test "$PHP_$3" != "no"; then 9 7 xcache_sources="$xcache_sources $1.c" 10 8 HAVE_$3=1 11 AC_DEFINE([HAVE_$3], 1, [Define for XC ACHE: $4])9 AC_DEFINE([HAVE_$3], 1, [Define for XCache: $4]) 12 10 else 13 11 HAVE_$3= … … 15 13 ])dnl 16 14 17 PHP_ARG_ENABLE(xcache, for XC ACHEsupport,18 [ --enable-xcache Include XC ACHEsupport.])15 PHP_ARG_ENABLE(xcache, for XCache support, 16 [ --enable-xcache Include XCache support.]) 19 17 20 18 if test "$PHP_XCACHE" != "no"; then … … 39 37 PHP_ADD_MAKEFILE_FRAGMENT() 40 38 41 PHP_ARG_ENABLE(xcache-test, for XC ACHEself test,42 [ --enable-xcache-test XC ACHE: Enable self test - FOR DEVELOPERS ONLY!!], no, no)43 if test "$PHP_XCACHE_TEST" = "yes"; then39 PHP_ARG_ENABLE(xcache-test, for XCache self test, 40 [ --enable-xcache-test XCache: Enable self test - FOR DEVELOPERS ONLY!!], no, no) 41 if test "$PHP_XCACHE_TEST" != "no"; then 44 42 XCACHE_ENABLE_TEST=-DXCACHE_ENABLE_TEST 45 AC_DEFINE([HAVE_XCACHE_TEST], 1, [Define to enable XC ACHEself test])43 AC_DEFINE([HAVE_XCACHE_TEST], 1, [Define to enable XCache self test]) 46 44 else 47 45 XCACHE_ENABLE_TEST= … … 49 47 PHP_SUBST([XCACHE_ENABLE_TEST]) 50 48 51 AC_PATH_PROGS(INDENT, [indent cat]) 49 AC_PATH_PROGS([AWK], [gawk awk]) 50 AC_PATH_PROGS([M4], [m4]) 51 AC_PATH_PROGS([GREP], [grep]) 52 AC_PATH_PROGS([SED], [sed]) 53 54 AC_PATH_PROGS([INDENT], [indent cat]) 52 55 case $INDENT in 53 56 */indent[)] … … 64 67 PHP_SUBST([XCACHE_PROC_SOURCES]) 65 68 66 AC_MSG_CHECKING(if you have opcode_spec_def.h for xcache)69 AC_MSG_CHECKING(if you have opcode_spec_def.h for XCache) 67 70 if test -e "$ac_srcdir/opcode_spec_def.h" ; then 68 AC_DEFINE([HAVE_XCACHE_OPCODE_SPEC_DEF], 1, [Define if you have opcode_spec_def.h for xcache])71 AC_DEFINE([HAVE_XCACHE_OPCODE_SPEC_DEF], 1, [Define if you have opcode_spec_def.h for XCache]) 69 72 AC_MSG_RESULT(yes) 70 73 else … … 74 77 AC_MSG_ERROR([cannot build with $1, $ac_srcdir/opcode_spec_def.h required]) 75 78 ]) 76 if test "$ HAVE_XCACHE_DISASSEMBLER" = "1" ; then79 if test "$PHP_XCACHE_DISASSEMBLER" != "no" ; then 77 80 ERROR(disassembler) 78 81 fi -
trunk/coverage.c
r1 r11 5 5 # include <sys/file.h> 6 6 #endif 7 #include <sys/types.h> 8 #include <sys/stat.h> 9 #include <fcntl.h> 10 7 11 #include "stack.h" 8 12 #include "xcache_globals.h" … … 305 309 zend_uint size; 306 310 coverage_t cov; 307 int i;311 zend_uint i; 308 312 309 313 if (op_array->type != ZEND_USER_FUNCTION) { … … 312 316 313 317 size = xc_coverage_get_op_array_size_no_tail(op_array); 314 cov = xc_coverage_get(op_array->filename );315 for (i = 0; i < size; i ++) {318 cov = xc_coverage_get(op_array->filename TSRMLS_CC); 319 for (i = 0; i < size; i ++) { 316 320 switch (op_array->opcodes[i].opcode) { 317 321 case ZEND_EXT_STMT: … … 351 355 void xc_coverage_handle_ext_stmt(zend_op_array *op_array, zend_uchar op) /* {{{ */ 352 356 { 357 TSRMLS_FETCH(); 358 353 359 if (XG(coveragedumper) && XG(coverages)) { 354 TSRMLS_FETCH();355 360 int size = xc_coverage_get_op_array_size_no_tail(op_array); 356 361 int oplineno = (*EG(opline_ptr)) - op_array->opcodes; 357 362 if (oplineno < size) { 358 xc_coverage_add_hits(xc_coverage_get(op_array->filename ), (*EG(opline_ptr))->lineno, 1 TSRMLS_CC);363 xc_coverage_add_hits(xc_coverage_get(op_array->filename TSRMLS_CC), (*EG(opline_ptr))->lineno, 1 TSRMLS_CC); 359 364 } 360 365 } -
trunk/lock.c
r1 r11 6 6 #ifndef ZEND_WIN32 7 7 typedef int HANDLE; 8 # define CloseHandle(h) close(h) 8 9 #endif 9 10 #include "lock.h" … … 18 19 # include <fcntl.h> 19 20 # include <errno.h> 21 # define LCK_WR F_WRLCK 22 # define LCK_RD F_RDLCK 23 # define LCK_UN F_UNLCK 24 # define LCK_NB 0 20 25 static inline int dolock(xc_lock_t *lck, int type) /* {{{ */ 21 26 { … … 35 40 } 36 41 /* }}} */ 37 #define LCK_WR F_WRLCK38 #define LCK_RD F_RDLCK39 #define LCK_UN F_UNLCK40 #define LCK_NB 041 42 #else 42 43 … … 46 47 # include <sys/types.h> 47 48 # include <sys/stat.h> 48 # define errno GetLastError() 49 # ifndef errno 50 # define errno GetLastError() 51 # endif 52 # define getuid() 0 53 # define LCK_WR LOCKFILE_EXCLUSIVE_LOCK 54 # define LCK_RD 0 55 # define LCK_UN 0 56 # define LCK_NB LOCKFILE_FAIL_IMMEDIATELY 49 57 static inline int dolock(xc_lock_t *lck, int type) /* {{{ */ 50 58 { … … 52 60 53 61 if (type == LCK_UN) { 54 return UnlockFileEx((HANDLE) fd, 0, 1, 0, &offset);62 return UnlockFileEx((HANDLE)lck->fd, 0, 1, 0, &offset); 55 63 } 56 64 else { 57 return LockFileEx((HANDLE) fd, type, 0, 1, 0, &offset);65 return LockFileEx((HANDLE)lck->fd, type, 0, 1, 0, &offset); 58 66 } 59 67 } 60 68 /* }}} */ 61 #define LCK_WR LOCKFILE_EXCLUSIVE_LOCK62 #define LCK_RD 063 #define LCK_UN 064 #define LCK_NB LOCKFILE_FAIL_IMMEDIATELY65 69 #endif 66 70 … … 68 72 { 69 73 HANDLE fd; 70 char myname[sizeof("/tmp/.xcache.lock") - 1 + 20];74 char myname[sizeof("/tmp/.xcache.lock") - 1 + 100]; 71 75 72 76 if (pathname == NULL) { 73 77 static int i = 0; 74 snprintf(myname, sizeof(myname) - 1, "/tmp/.xcache.%d.%d. lock", (int) getuid(), i ++);78 snprintf(myname, sizeof(myname) - 1, "/tmp/.xcache.%d.%d.%d.lock", (int) getuid(), i ++, rand()); 75 79 pathname = myname; 76 80 } 77 81 78 fd = open(pathname, O_RDWR|O_CREAT, 0666);82 fd = (HANDLE) open(pathname, O_RDWR|O_CREAT, 0666); 79 83 80 84 if (fd > 0) { … … 99 103 void xc_fcntl_destroy(xc_lock_t *lck) /* {{{ */ 100 104 { 101 close(lck->fd);105 CloseHandle(lck->fd); 102 106 #ifdef __CYGWIN__ 103 107 unlink(lck->pathname); -
trunk/mmap.c
r1 r11 7 7 #include <string.h> 8 8 #include <stdlib.h> 9 9 10 /* mmap */ 10 #include <unistd.h> 11 #ifdef ZEND_WIN32 12 # define ftruncate chsize 13 # define getuid() 0 14 # define XcacheCreateFileMapping(size, perm, name) \ 15 CreateFileMapping(INVALID_HANDLE_VALUE, NULL, perm, (sizeof(xc_shmsize_t) > 4) ? size >> 32 : 0, size & 0xffffffff, name) 16 # define XCACHE_MAP_FAILED NULL 17 # define munmap(p, s) UnmapViewOfFile(p) 18 #else 19 # include <unistd.h> 20 # define XCACHE_MAP_FAILED MAP_FAILED 21 #endif 22 11 23 #include <sys/types.h> 12 24 #include <sys/stat.h> 13 25 #include <fcntl.h> 26 27 #ifndef ZEND_WIN32 14 28 #include <sys/mman.h> 29 #endif 15 30 16 31 #include "php.h" … … 27 42 long diff; 28 43 xc_shmsize_t size; 44 char *name; 45 #ifdef ZEND_WIN32 46 HANDLE hmap; 47 HANDLE hmap_ro; 48 #endif 29 49 }; 30 50 51 #undef NDEBUG 31 52 #ifdef ALLOC_DEBUG 32 # undef NDEBUG33 53 # define inline 34 54 #else … … 38 58 /* }}} */ 39 59 #define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0) 60 #define PTR_ADD(ptr, v) (((char *) (ptr)) + (v)) 61 #define PTR_SUB(ptr, v) (((char *) (ptr)) - (v)) 40 62 41 63 int xc_shm_can_readonly(xc_shm_t *shm) /* {{{ */ … … 58 80 if (shm->diff) { 59 81 assert(xc_shm_is_readonly(p)); 60 p = p - shm->diff;82 p = PTR_SUB(p, -shm->diff); 61 83 } 62 84 assert(xc_shm_is_readwrite(p)); … … 68 90 assert(xc_shm_is_readwrite(p)); 69 91 if (shm->diff) { 70 p = p + shm->diff;92 p = PTR_ADD(p, shm->diff); 71 93 assert(xc_shm_is_readonly(p)); 72 94 } … … 90 112 */ 91 113 } 114 #ifdef ZEND_WIN32 115 if (shm->hmap) { 116 CloseHandle(shm->hmap); 117 } 118 if (shm->hmap_ro) { 119 CloseHandle(shm->hmap_ro); 120 } 121 #endif 122 123 if (shm->name) { 124 #ifdef __CYGWIN__ 125 unlink(shm->name); 126 #endif 127 free(shm->name); 128 } 92 129 /* 93 130 shm->size = NULL; … … 102 139 { 103 140 xc_shm_t *shm = NULL; 104 int fd ;141 int fd = -1; 105 142 int ro_ok; 106 143 volatile void *romem; 107 int created = 0;144 char tmpname[sizeof("/tmp/xcache") - 1 + 100]; 108 145 109 146 CHECK(shm = calloc(1, sizeof(xc_shm_t)), "shm OOM"); 110 147 shm->size = size; 148 111 149 if (path == NULL || !path[0]) { 112 path = "/tmp/xcache"; 113 } 114 fd = open(path, O_RDWR, S_IRUSR | S_IWUSR); 150 static int inc = 0; 151 snprintf(tmpname, sizeof(tmpname) - 1, "/tmp/xcache.%d.%d.%d", (int) getuid(), inc ++, rand()); 152 path = tmpname; 153 } 154 155 shm->name = strdup(path); 156 157 #ifndef ZEND_WIN32 158 # define XCACHE_MMAP_PERMISSION (S_IRUSR | S_IWUSR) 159 fd = open(shm->name, O_RDWR, XCACHE_MMAP_PERMISSION); 115 160 if (fd == -1) { 116 created = 1; 117 fd = open(path, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); 161 fd = open(shm->name, O_CREAT | O_RDWR, XCACHE_MMAP_PERMISSION); 118 162 if (fd == -1) { 119 if (created) {120 unlink(path);121 }122 163 goto err; 123 164 } 124 165 } 125 166 ftruncate(fd, size); 126 167 #endif 168 169 #ifdef ZEND_WIN32 170 shm->hmap = XcacheCreateFileMapping(size, PAGE_READWRITE, shm->name); 171 shm->ptr = (LPSTR) MapViewOfFile(shm->hmap, FILE_MAP_WRITE, 0, 0, 0); 172 #else 127 173 shm->ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 128 if (shm->ptr == MAP_FAILED) { 174 #endif 175 176 if (shm->ptr == XCACHE_MAP_FAILED) { 129 177 shm->ptr = NULL; 130 close(fd);131 if (created) {132 unlink(path);133 }134 178 goto err; 135 179 } … … 137 181 ro_ok = 0; 138 182 if (readonly_protection) { 183 #ifdef ZEND_WIN32 184 shm->hmap_ro = XcacheCreateFileMapping(size, PAGE_READONLY, shm->name); 185 shm->ptr_ro = (LPSTR) MapViewOfFile(shm->hmap_ro, FILE_MAP_READ, 0, 0, 0); 186 #else 139 187 shm->ptr_ro = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); 188 #endif 140 189 romem = shm->ptr_ro; 141 190 142 191 /* {{{ check if ptr_ro works */ 143 192 do { 144 if (shm->ptr_ro == MAP_FAILED || shm->ptr_ro == shm->ptr) {193 if (shm->ptr_ro == XCACHE_MAP_FAILED || shm->ptr_ro == shm->ptr) { 145 194 break; 146 195 } … … 158 207 159 208 if (ro_ok) { 160 shm->diff = shm->ptr_ro - shm->ptr;209 shm->diff = PTR_SUB(shm->ptr_ro, (char *) shm->ptr); 161 210 assert(abs(shm->diff) >= size); 162 211 } 163 212 else { 164 if (shm->ptr_ro != MAP_FAILED) {213 if (shm->ptr_ro != XCACHE_MAP_FAILED) { 165 214 munmap(shm->ptr_ro, size); 166 215 } … … 171 220 172 221 close(fd); 173 if (created) { 174 unlink(path);175 } 222 #ifndef __CYGWIN__ 223 unlink(shm->name); 224 #endif 176 225 177 226 return shm; 178 227 179 228 err: 229 if (fd != -1) { 230 close(fd); 231 } 180 232 if (shm) { 181 233 xc_shm_destroy(shm); -
trunk/myshm.h
r1 r11 1 1 typedef struct _xc_shm_t xc_shm_t; 2 typedef unsigned int xc_shmsize_t;2 typedef size_t xc_shmsize_t; 3 3 4 4 int xc_shm_can_readonly(xc_shm_t *shm); -
trunk/processor/main.m4
r4 r11 15 15 dnl }}} 16 16 dnl {{{ ALLOC(1:dst, 2:type, 3:count=1, 4:clean=false, 5:forcetype=$2) 17 dnl don't use typeof(dst) as we need the compiler warning18 17 define(`ALLOC', ` 19 18 pushdef(`COUNT', `ifelse(`$3', `', `1', `$3')') -
trunk/processor/processor.m4
r4 r11 365 365 DISPATCH(int, op_type) 366 366 367 #ifdef IS_CV 368 # define XCACHE_IS_CV IS_CV 369 #else 370 /* compatible with zend optimizer */ 371 # define XCACHE_IS_CV 16 372 #endif 367 373 assert(src->op_type == IS_CONST || 368 374 src->op_type == IS_VAR || 369 #ifdef IS_CV 370 src->op_type == IS_CV || 371 #else 372 src->op_type == 16 || /* zend optimizer */ 373 #endif 375 src->op_type == XCACHE_IS_CV || 374 376 src->op_type == IS_TMP_VAR || 375 377 src->op_type == IS_UNUSED); 378 #undef XCACHE_IS_CV 376 379 dnl dirty dispatch 377 380 DISABLECHECK(` … … 463 466 do { 464 467 dnl RESTORE is done above! 468 zend_uint ii; 465 469 int i; 466 470 … … 481 485 /* useless */ 482 486 COPY(prototype) 483 STRUCT_ARRAY (num_args, zend_arg_info, arg_info)487 STRUCT_ARRAY_I(num_args, zend_arg_info, arg_info) 484 488 DISPATCH(zend_uint, num_args) 485 489 DISPATCH(zend_uint, required_num_args) … … 490 494 IFCOPY(`memcpy(dst->arg_types, src->arg_types, sizeof(src->arg_types[0]) * (src->arg_types[0]+1));') 491 495 IFDASM(`do { 496 zend_uint ii; 492 497 int i; 493 498 zval *zv; … … 528 533 processor->active_opcodes_src = src->opcodes; 529 534 ')') 530 STRUCT_ARRAY (last, zend_op, opcodes)535 STRUCT_ARRAY_I(last, zend_op, opcodes) 531 536 popdef(`AFTER_ALLOC') 532 537 DISPATCH(zend_uint, last) … … 546 551 DISPATCH(zend_uint, T) 547 552 548 STRUCT_ARRAY (last_brk_cont, zend_brk_cont_element, brk_cont_array)553 STRUCT_ARRAY_I(last_brk_cont, zend_brk_cont_element, brk_cont_array) 549 554 DISPATCH(zend_uint, last_brk_cont) 550 555 DISPATCH(zend_uint, current_brk_cont) -
trunk/processor/string.m4
r1 r11 36 36 ') 37 37 IFCALC(`xc_calc_string_n(processor, ISTYPE, (void *) $2, `$3' IFASSERT(`, __LINE__'));') 38 IFSTORE(`$1 = ( typeof($1)) xc_store_string_n(processor, ISTYPE, (char *) $2, `$3' IFASSERT(`, __LINE__'));')38 IFSTORE(`$1 = (STRTYPE *) xc_store_string_n(processor, ISTYPE, (char *) $2, `$3' IFASSERT(`, __LINE__'));') 39 39 IFRESTORE(` 40 ALLOC(`$1', ` typeof($1[0])', `sizeof(STRTYPE) * ($3)')40 ALLOC(`$1', `STRTYPE', `sizeof(STRTYPE) * ($3)') 41 41 memcpy($1, $2, sizeof(STRTYPE) * ($3)); 42 42 ') 43 FIXPOINTER_EX(` typeof($1[0])', `$1')43 FIXPOINTER_EX(`STRTYPE', `$1') 44 44 IFDASM(` 45 45 ifelse(STRTYPE,UChar, ` -
trunk/processor/struct.m4
r4 r11 39 39 IFRESTORE(`assert(xc_is_shm(src));') 40 40 IFCALCSTORE(`assert(!xc_is_shm(src));') 41 do { 41 42 ') 42 43 43 44 ifdef(`USEMEMCPY', `IFCOPY(` 44 45 memcpy(dst, src, sizeof($1)); 46 do { 45 47 ')') 46 48 … … 84 86 /* }}} */ 85 87 ')') 88 ifdef(`USEMEMCPY', `IFCOPY(` 89 } while (0); 90 ')') 86 91 IFASSERT(` 92 } while (0); 87 93 undefine(`ELEMENTS_DONE') 88 94 ') … … 144 150 ') 145 151 dnl }}} 152 dnl {{{ STRUCT_ARRAY_I(1:count, 2:type, 3:elm, 4:name=type) 153 define(`STRUCT_ARRAY_I', ` 154 pushdef(`i', `ii') 155 STRUCT_ARRAY(`$1', `$2', `$3', `$4') 156 popdef(`i') 157 ') 158 dnl }}} 146 159 dnl {{{ STRUCT_ARRAY(1:count, 2:type, 3:elm, 4:name=type) 147 160 define(`STRUCT_ARRAY', ` -
trunk/stack.c
r1 r11 51 51 void xc_stack_reverse(S stack) 52 52 { 53 typeof(stack->cnt)i, j;53 int i, j; 54 54 void *tmp; 55 55 -
trunk/utils.c
r8 r11 234 234 { 235 235 zend_op *opline; 236 int i;236 zend_uint i; 237 237 238 238 opline = op_array->opcodes; … … 282 282 ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, zend_uchar type, void *key, uint len TSRMLS_DC) /* {{{ */ 283 283 { 284 zend_class_entry *cep = CestToCePtr(*cest); 284 285 ZESW(void *stored_ce_ptr, ); 285 zend_class_entry *cep = CestToCePtr(*cest);286 286 287 287 if (zend_u_hash_add(CG(class_table), type, key, len, -
trunk/xcache.c
r9 r11 27 27 #include "opcode_spec.h" 28 28 29 #undef NDEBUG 29 30 #ifdef DEBUG 30 # undef NDEBUG31 31 # undef inline 32 32 # define inline … … 340 340 for (i = 0, c = cache->hentry->size; i < c; i ++) { 341 341 for (e = cache->entries[i]; e; e = e->next) { 342 xc_fillentry_dmz(e, 0, list );342 xc_fillentry_dmz(e, 0, list TSRMLS_CC); 343 343 } 344 344 } … … 348 348 array_init(list); 349 349 for (e = cache->deletes; e; e = e->next) { 350 xc_fillentry_dmz(e, 1, list );350 xc_fillentry_dmz(e, 1, list TSRMLS_CC); 351 351 } 352 352 add_assoc_zval(return_value, "deleted_list", list); … … 402 402 int i; 403 403 xc_cache_t *cache; 404 typeof(cache->deletes) p, *last; 404 typedef xc_entry_t *xc_delete_t; 405 xc_delete_t p, *last; 405 406 406 407 for (i = 0; i < size; i ++) { … … 408 409 ENTER_LOCK(cache) { 409 410 if (cache->deletes) { 410 last = ( typeof(last)) &cache->deletes;411 last = (xc_delete_t *) &cache->deletes; 411 412 for (p = *last; p; p = p->next) { 412 413 if (t - p->dtime > 3600) { … … 433 434 } 434 435 /* }}} */ 435 static inline void xc_entry_unholds_real(xc_stack_t *holds, xc_cache_t **caches, int cachecount ) /* {{{ */436 static inline void xc_entry_unholds_real(xc_stack_t *holds, xc_cache_t **caches, int cachecount TSRMLS_DC) /* {{{ */ 436 437 { 437 438 int i; … … 457 458 static void xc_entry_unholds(TSRMLS_D) /* {{{ */ 458 459 { 459 xc_entry_unholds_real(XG(php_holds), xc_php_caches, xc_php_hcache.size );460 xc_entry_unholds_real(XG(var_holds), xc_var_caches, xc_var_hcache.size );461 } 462 /* }}} */ 463 static int xc_stat(const char *filename, const char *include_path, struct stat *pbuf ) /* {{{ */460 xc_entry_unholds_real(XG(php_holds), xc_php_caches, xc_php_hcache.size TSRMLS_CC); 461 xc_entry_unholds_real(XG(var_holds), xc_var_caches, xc_var_hcache.size TSRMLS_CC); 462 } 463 /* }}} */ 464 static int xc_stat(const char *filename, const char *include_path, struct stat *pbuf TSRMLS_DC) /* {{{ */ 464 465 { 465 466 char filepath[1024]; … … 472 473 memcpy(paths, include_path, size); 473 474 474 for (path = strtok_r(paths, tokens, &tokbuf); path; path =strtok_r(NULL, tokens, &tokbuf)) {475 for (path = php_strtok_r(paths, tokens, &tokbuf); path; path = php_strtok_r(NULL, tokens, &tokbuf)) { 475 476 if (strlen(path) + strlen(filename) + 1 > 1024) { 476 477 continue; … … 536 537 } 537 538 else { 538 if (xc_stat(filename, PG(include_path), pbuf ) != 0) {539 if (xc_stat(filename, PG(include_path), pbuf TSRMLS_CC) != 0) { 539 540 return 0; 540 541 } … … 825 826 static int xc_init_constant(int module_number TSRMLS_DC) /* {{{ */ 826 827 { 827 struct {828 typedef struct { 828 829 const char *prefix; 829 830 int (*getsize)(); 830 831 const char *(*get)(zend_uchar i); 831 } nameinfos[] = { 832 } xc_meminfo_t; 833 xc_meminfo_t nameinfos[] = { 832 834 { "", xc_get_op_type_count, xc_get_op_type }, 833 835 { "", xc_get_data_type_count, xc_get_data_type }, … … 836 838 { NULL, NULL, NULL } 837 839 }; 838 typeof(nameinfos[0])* p;840 xc_meminfo_t* p; 839 841 int i; 840 842 char const_name[96]; … … 861 863 } 862 864 /* }}} */ 863 static xc_shm_t *xc_cache_destroy(xc_cache_t **caches, xc_hash_t *hcache TSRMLS_DC) /* {{{ */865 static xc_shm_t *xc_cache_destroy(xc_cache_t **caches, xc_hash_t *hcache) /* {{{ */ 864 866 { 865 867 int i; … … 891 893 } 892 894 /* }}} */ 893 static xc_cache_t **xc_cache_init(xc_shm_t *shm, char *ptr, xc_hash_t *hcache, xc_hash_t *hentry, xc_shmsize_t shmsize TSRMLS_DC) /* {{{ */895 static xc_cache_t **xc_cache_init(xc_shm_t *shm, char *ptr, xc_hash_t *hcache, xc_hash_t *hentry, xc_shmsize_t shmsize) /* {{{ */ 894 896 { 895 897 xc_cache_t **caches = NULL, *cache; 896 898 xc_mem_t *mem; 897 899 int i; 900 898 901 xc_memsize_t memsize = shmsize / hcache->size; 899 902 … … 948 951 static int xc_init(int module_number TSRMLS_DC) /* {{{ */ 949 952 { 950 xc_php_caches = xc_var_caches = NULL;951 953 xc_shm_t *shm; 952 954 char *ptr; 955 956 xc_php_caches = xc_var_caches = NULL; 953 957 954 958 if (xc_php_size || xc_var_size) { … … 1057 1061 /* }}} */ 1058 1062 1059 #define NEED_INITIZED() do { \1060 if (!xc_initized) { \1061 php_error_docref(NULL TSRMLS_CC, E_WARNING, "XCache is not initized"); \1062 RETURN_FALSE; \1063 } \1064 } while (0)1065 1066 1063 /* user functions */ 1067 1064 /* {{{ xcache_op */ … … 1069 1066 static void xcache_op(xcache_op_type optype, INTERNAL_FUNCTION_PARAMETERS) 1070 1067 { 1071 NEED_INITIZED();1072 1068 long type; 1073 1069 int size; 1074 1070 xc_cache_t **caches, *cache; 1075 1071 long id = 0; 1072 1073 if (!xc_initized) { 1074 php_error_docref(NULL TSRMLS_CC, E_WARNING, "XCache is not initized"); 1075 RETURN_FALSE; 1076 } 1076 1077 1077 1078 if (optype == XC_OP_COUNT) { … … 1239 1240 } 1240 1241 else { 1241 xc_entry_remove_dmz(stored_xce );1242 xc_entry_remove_dmz(stored_xce TSRMLS_CC); 1242 1243 } 1243 1244 } … … 1266 1267 stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC); 1267 1268 if (stored_xce) { 1268 xc_entry_remove_dmz(stored_xce );1269 xc_entry_remove_dmz(stored_xce TSRMLS_CC); 1269 1270 } 1270 1271 var.value = value; 1271 1272 var.etime = ttl ? XG(request_time) + ttl : TIME_MAX; 1272 RETVAL_BOOL(xc_entry_store_dmz(&xce ) != NULL ? 1 : 0);1273 RETVAL_BOOL(xc_entry_store_dmz(&xce TSRMLS_CC) != NULL ? 1 : 0); 1273 1274 } LEAVE_LOCK(xce.cache); 1274 1275 } … … 1297 1298 } 1298 1299 else { 1299 xc_entry_remove_dmz(stored_xce );1300 xc_entry_remove_dmz(stored_xce TSRMLS_CC); 1300 1301 } 1301 1302 } … … 1322 1323 stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC); 1323 1324 if (stored_xce) { 1324 xc_entry_remove_dmz(stored_xce );1325 xc_entry_remove_dmz(stored_xce TSRMLS_CC); 1325 1326 RETVAL_TRUE; 1326 1327 } … … 1359 1360 fprintf(stderr, "incdec: expired\n"); 1360 1361 #endif 1361 xc_entry_remove_dmz(stored_xce );1362 xc_entry_remove_dmz(stored_xce TSRMLS_CC); 1362 1363 stored_xce = NULL; 1363 1364 } … … 1399 1400 xce.ctime = stored_xce->ctime; 1400 1401 xce.hits = stored_xce->hits; 1401 xc_entry_remove_dmz(stored_xce );1402 } 1403 xc_entry_store_dmz(&xce );1402 xc_entry_remove_dmz(stored_xce TSRMLS_CC); 1403 } 1404 xc_entry_store_dmz(&xce TSRMLS_CC); 1404 1405 1405 1406 } LEAVE_LOCK(xce.cache); … … 1492 1493 } 1493 1494 if (spec >= 0 && spec < count) { 1494 name = getter( spec);1495 name = getter((zend_uchar) spec); 1495 1496 if (name) { 1496 1497 /* RETURN_STRING */ … … 1540 1541 } 1541 1542 if (spec <= xc_get_opcode_spec_count()) { 1542 opspec = xc_get_opcode_spec( spec);1543 opspec = xc_get_opcode_spec((zend_uchar) spec); 1543 1544 if (opspec) { 1544 1545 array_init(return_value); … … 1886 1887 #endif 1887 1888 { 1889 TSRMLS_FETCH(); 1890 1888 1891 xc_request_shutdown(TSRMLS_C); 1889 1892 return SUCCESS; -
trunk/xcache.h
r2 r11 52 52 #define BUCKET_KEY_TYPE(b) (UNISW(0, (b)->key.type)) 53 53 #ifdef IS_UNICODE 54 # define BUCKET_HEAD_SIZE(b) XtOffsetOf( typeof(b[0]), key)55 #else 56 # define BUCKET_HEAD_SIZE(b) XtOffsetOf( typeof(b[0]), arKey)54 # define BUCKET_HEAD_SIZE(b) XtOffsetOf(Bucket, key) 55 #else 56 # define BUCKET_HEAD_SIZE(b) XtOffsetOf(Bucket, arKey) 57 57 #endif 58 58 #define BUCKET_SIZE(b) (BUCKET_HEAD_SIZE(b) + BUCKET_KEY_SIZE(b)) … … 117 117 /* {{{ xc_cache_t */ 118 118 typedef struct _xc_entry_t xc_entry_t; 119 typedef volatilestruct {119 typedef struct { 120 120 int cacheid; 121 121 xc_hash_t *hcache; /* hash to cacheid */ 122 122 123 zend_boolcompiling;123 time_t compiling; 124 124 zend_ulong misses; 125 125 zend_ulong hits;

