Changeset 11 in svn


Ignore:
Timestamp:
2006-05-24T07:52:48Z (9 years ago)
Author:
Xuefer
Message:

make it build on windows vc compiler

Location:
trunk
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.frag

    r6 r11  
    88
    99$(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)
    1111
    1212$(XCACHE_STRUCT_OUT): $(XCACHE_INCLUDES_I) $(srcdir)/mkstructinfo.awk
     
    1414
    1515$(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)
    1718
    1819$(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)
    2022
    2123$(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)
    2326
    2427$(builddir)/processor.lo: $(XCACHE_PROC_C) $(XCACHE_PROC_H) $(srcdir)/processor.c
  • trunk/config.m4

    r8 r11  
    1 dnl
    2 dnl $Id:$
    31dnl vim:ts=2:sw=2:expandtab
    42
    53AC_DEFUN([XCACHE_OPTION], [
    6   PHP_ARG_ENABLE(xcache-$1, for XCACHE $1,
    7   [  --enable-xcache-$2    XCACHE: $4], no, no)
    8   if test "$PHP_$3" = "yes"; then
     4  PHP_ARG_ENABLE(xcache-$1, for XCache $1,
     5  [  --enable-xcache-$2    XCache: $4], no, no)
     6  if test "$PHP_$3" != "no"; then
    97    xcache_sources="$xcache_sources $1.c"
    108    HAVE_$3=1
    11     AC_DEFINE([HAVE_$3], 1, [Define for XCACHE: $4])
     9    AC_DEFINE([HAVE_$3], 1, [Define for XCache: $4])
    1210  else
    1311    HAVE_$3=
     
    1513])dnl
    1614
    17 PHP_ARG_ENABLE(xcache, for XCACHE support,
    18 [  --enable-xcache         Include XCACHE support.])
     15PHP_ARG_ENABLE(xcache, for XCache support,
     16[  --enable-xcache         Include XCache support.])
    1917
    2018if test "$PHP_XCACHE" != "no"; then
     
    3937  PHP_ADD_MAKEFILE_FRAGMENT()
    4038
    41   PHP_ARG_ENABLE(xcache-test, for XCACHE self test,
    42   [  --enable-xcache-test            XCACHE: Enable self test - FOR DEVELOPERS ONLY!!], no, no)
    43   if test "$PHP_XCACHE_TEST" = "yes"; then
     39  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
    4442    XCACHE_ENABLE_TEST=-DXCACHE_ENABLE_TEST
    45     AC_DEFINE([HAVE_XCACHE_TEST], 1, [Define to enable XCACHE self test])
     43    AC_DEFINE([HAVE_XCACHE_TEST], 1, [Define to enable XCache self test])
    4644  else
    4745    XCACHE_ENABLE_TEST=
     
    4947  PHP_SUBST([XCACHE_ENABLE_TEST])
    5048
    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])
    5255  case $INDENT in
    5356  */indent[)]
     
    6467  PHP_SUBST([XCACHE_PROC_SOURCES])
    6568
    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)
    6770  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])
    6972    AC_MSG_RESULT(yes)
    7073  else
     
    7477      AC_MSG_ERROR([cannot build with $1, $ac_srcdir/opcode_spec_def.h required])
    7578    ])
    76     if test "$HAVE_XCACHE_DISASSEMBLER" = "1" ; then
     79    if test "$PHP_XCACHE_DISASSEMBLER" != "no" ; then
    7780      ERROR(disassembler)
    7881    fi
  • trunk/coverage.c

    r1 r11  
    55#   include <sys/file.h>
    66#endif
     7#include <sys/types.h>
     8#include <sys/stat.h>
     9#include <fcntl.h>
     10
    711#include "stack.h"
    812#include "xcache_globals.h"
     
    305309    zend_uint size;
    306310    coverage_t cov;
    307     int i;
     311    zend_uint i;
    308312
    309313    if (op_array->type != ZEND_USER_FUNCTION) {
     
    312316
    313317    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 ++) {
    316320        switch (op_array->opcodes[i].opcode) {
    317321            case ZEND_EXT_STMT:
     
    351355void xc_coverage_handle_ext_stmt(zend_op_array *op_array, zend_uchar op) /* {{{ */
    352356{
     357    TSRMLS_FETCH();
     358
    353359    if (XG(coveragedumper) && XG(coverages)) {
    354         TSRMLS_FETCH();
    355360        int size = xc_coverage_get_op_array_size_no_tail(op_array);
    356361        int oplineno = (*EG(opline_ptr)) - op_array->opcodes;
    357362        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);
    359364        }
    360365    }
  • trunk/lock.c

    r1 r11  
    66#ifndef ZEND_WIN32
    77typedef int HANDLE;
     8#   define CloseHandle(h) close(h)
    89#endif
    910#include "lock.h"
     
    1819#   include <fcntl.h>
    1920#   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
    2025static inline int dolock(xc_lock_t *lck, int type) /* {{{ */
    2126{
     
    3540}
    3641/* }}} */
    37 #define LCK_WR F_WRLCK
    38 #define LCK_RD F_RDLCK
    39 #define LCK_UN F_UNLCK
    40 #define LCK_NB 0
    4142#else
    4243
     
    4647#   include <sys/types.h>
    4748#   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
    4957static inline int dolock(xc_lock_t *lck, int type) /* {{{ */
    5058{
     
    5260
    5361    if (type == LCK_UN) {
    54         return UnlockFileEx((HANDLE)fd, 0, 1, 0, &offset);
     62        return UnlockFileEx((HANDLE)lck->fd, 0, 1, 0, &offset);
    5563    }
    5664    else {
    57         return LockFileEx((HANDLE)fd, type, 0, 1, 0, &offset);
     65        return LockFileEx((HANDLE)lck->fd, type, 0, 1, 0, &offset);
    5866    }
    5967}
    6068/* }}} */
    61 #define LCK_WR LOCKFILE_EXCLUSIVE_LOCK
    62 #define LCK_RD 0
    63 #define LCK_UN 0
    64 #define LCK_NB LOCKFILE_FAIL_IMMEDIATELY
    6569#endif
    6670
     
    6872{
    6973    HANDLE fd;
    70     char myname[sizeof("/tmp/.xcache.lock") - 1 + 20];
     74    char myname[sizeof("/tmp/.xcache.lock") - 1 + 100];
    7175
    7276    if (pathname == NULL) {
    7377        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());
    7579        pathname = myname;
    7680    }
    7781
    78     fd = open(pathname, O_RDWR|O_CREAT, 0666);
     82    fd = (HANDLE) open(pathname, O_RDWR|O_CREAT, 0666);
    7983
    8084    if (fd > 0) {
     
    99103void xc_fcntl_destroy(xc_lock_t *lck) /* {{{ */
    100104{   
    101     close(lck->fd);
     105    CloseHandle(lck->fd);
    102106#ifdef __CYGWIN__
    103107    unlink(lck->pathname);
  • trunk/mmap.c

    r1 r11  
    77#include <string.h>
    88#include <stdlib.h>
     9
    910/* 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
    1123#include <sys/types.h>
    1224#include <sys/stat.h>
    1325#include <fcntl.h>
     26
     27#ifndef ZEND_WIN32
    1428#include <sys/mman.h>
     29#endif
    1530
    1631#include "php.h"
     
    2742    long  diff;
    2843    xc_shmsize_t size;
     44    char *name;
     45#ifdef ZEND_WIN32
     46    HANDLE hmap;
     47    HANDLE hmap_ro;
     48#endif
    2949};
    3050
     51#undef NDEBUG
    3152#ifdef ALLOC_DEBUG
    32 #   undef NDEBUG
    3353#   define inline
    3454#else
     
    3858/* }}} */
    3959#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))
    4062
    4163int xc_shm_can_readonly(xc_shm_t *shm) /* {{{ */
     
    5880    if (shm->diff) {
    5981        assert(xc_shm_is_readonly(p));
    60         p = p - shm->diff;
     82        p = PTR_SUB(p, -shm->diff);
    6183    }
    6284    assert(xc_shm_is_readwrite(p));
     
    6890    assert(xc_shm_is_readwrite(p));
    6991    if (shm->diff) {
    70         p = p + shm->diff;
     92        p = PTR_ADD(p, shm->diff);
    7193        assert(xc_shm_is_readonly(p));
    7294    }
     
    90112        */
    91113    }
     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    }
    92129    /*
    93130    shm->size = NULL;
     
    102139{
    103140    xc_shm_t *shm = NULL;
    104     int fd;
     141    int fd = -1;
    105142    int ro_ok;
    106143    volatile void *romem;
    107     int created = 0;
     144    char tmpname[sizeof("/tmp/xcache") - 1 + 100];
    108145
    109146    CHECK(shm = calloc(1, sizeof(xc_shm_t)), "shm OOM");
    110147    shm->size = size;
     148
    111149    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);
    115160    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);
    118162        if (fd == -1) {
    119             if (created) {
    120                 unlink(path);
    121             }
    122163            goto err;
    123164        }
    124165    }
    125166    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
    127173    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) {
    129177        shm->ptr = NULL;
    130         close(fd);
    131         if (created) {
    132             unlink(path);
    133         }
    134178        goto err;
    135179    }
     
    137181    ro_ok = 0;
    138182    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
    139187        shm->ptr_ro = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
     188#endif
    140189        romem = shm->ptr_ro;
    141190
    142191        /* {{{ check if ptr_ro works */
    143192        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) {
    145194                break;
    146195            }
     
    158207
    159208    if (ro_ok) {
    160         shm->diff = shm->ptr_ro - shm->ptr;
     209        shm->diff = PTR_SUB(shm->ptr_ro, (char *) shm->ptr);
    161210        assert(abs(shm->diff) >= size);
    162211    }
    163212    else {
    164         if (shm->ptr_ro != MAP_FAILED) {
     213        if (shm->ptr_ro != XCACHE_MAP_FAILED) {
    165214            munmap(shm->ptr_ro, size);
    166215        }
     
    171220
    172221    close(fd);
    173     if (created) {
    174         unlink(path);
    175     }
     222#ifndef __CYGWIN__
     223    unlink(shm->name);
     224#endif
    176225
    177226    return shm;
    178227
    179228err:
     229    if (fd != -1) {
     230        close(fd);
     231    }
    180232    if (shm) {
    181233        xc_shm_destroy(shm);
  • trunk/myshm.h

    r1 r11  
    11typedef struct _xc_shm_t xc_shm_t;
    2 typedef unsigned int xc_shmsize_t;
     2typedef size_t xc_shmsize_t;
    33
    44int xc_shm_can_readonly(xc_shm_t *shm);
  • trunk/processor/main.m4

    r4 r11  
    1515dnl }}}
    1616dnl {{{ 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 warning
    1817define(`ALLOC', `
    1918    pushdef(`COUNT', `ifelse(`$3', `', `1', `$3')')
  • trunk/processor/processor.m4

    r4 r11  
    365365    DISPATCH(int, op_type)
    366366
     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
    367373    assert(src->op_type == IS_CONST ||
    368374        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 ||
    374376        src->op_type == IS_TMP_VAR ||
    375377        src->op_type == IS_UNUSED);
     378#undef XCACHE_IS_CV
    376379    dnl dirty dispatch
    377380    DISABLECHECK(`
     
    463466    do {
    464467    dnl RESTORE is done above!
     468    zend_uint ii;
    465469    int i;
    466470
     
    481485    /* useless */
    482486    COPY(prototype)
    483     STRUCT_ARRAY(num_args, zend_arg_info, arg_info)
     487    STRUCT_ARRAY_I(num_args, zend_arg_info, arg_info)
    484488    DISPATCH(zend_uint, num_args)
    485489    DISPATCH(zend_uint, required_num_args)
     
    490494        IFCOPY(`memcpy(dst->arg_types, src->arg_types, sizeof(src->arg_types[0]) * (src->arg_types[0]+1));')
    491495        IFDASM(`do {
     496            zend_uint ii;
    492497            int i;
    493498            zval *zv;
     
    528533        processor->active_opcodes_src = src->opcodes;
    529534    ')')
    530     STRUCT_ARRAY(last, zend_op, opcodes)
     535    STRUCT_ARRAY_I(last, zend_op, opcodes)
    531536    popdef(`AFTER_ALLOC')
    532537    DISPATCH(zend_uint, last)
     
    546551    DISPATCH(zend_uint, T)
    547552
    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)
    549554    DISPATCH(zend_uint, last_brk_cont)
    550555    DISPATCH(zend_uint, current_brk_cont)
  • trunk/processor/string.m4

    r1 r11  
    3636        ')
    3737        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__'));')
    3939        IFRESTORE(`
    40             ALLOC(`$1', `typeof($1[0])', `sizeof(STRTYPE) * ($3)')
     40            ALLOC(`$1', `STRTYPE', `sizeof(STRTYPE) * ($3)')
    4141            memcpy($1, $2, sizeof(STRTYPE) * ($3));
    4242        ')
    43         FIXPOINTER_EX(`typeof($1[0])', `$1')
     43        FIXPOINTER_EX(`STRTYPE', `$1')
    4444        IFDASM(`
    4545                ifelse(STRTYPE,UChar, `
  • trunk/processor/struct.m4

    r4 r11  
    3939            IFRESTORE(`assert(xc_is_shm(src));')
    4040            IFCALCSTORE(`assert(!xc_is_shm(src));')
     41            do {
    4142        ')
    4243
    4344        ifdef(`USEMEMCPY', `IFCOPY(`
    4445            memcpy(dst, src, sizeof($1));
     46            do {
    4547        ')')
    4648
     
    8486                /* }}} */
    8587        ')')
     88        ifdef(`USEMEMCPY', `IFCOPY(`
     89            } while (0);
     90        ')')
    8691        IFASSERT(`
     92            } while (0);
    8793            undefine(`ELEMENTS_DONE')
    8894        ')
     
    144150')
    145151dnl }}}
     152dnl {{{ STRUCT_ARRAY_I(1:count, 2:type, 3:elm, 4:name=type)
     153define(`STRUCT_ARRAY_I', `
     154pushdef(`i', `ii')
     155STRUCT_ARRAY(`$1', `$2', `$3', `$4')
     156popdef(`i')
     157')
     158dnl }}}
    146159dnl {{{ STRUCT_ARRAY(1:count, 2:type, 3:elm, 4:name=type)
    147160define(`STRUCT_ARRAY', `
  • trunk/stack.c

    r1 r11  
    5151void xc_stack_reverse(S stack)
    5252{
    53     typeof(stack->cnt) i, j;
     53    int i, j;
    5454    void *tmp;
    5555
  • trunk/utils.c

    r8 r11  
    234234{
    235235    zend_op *opline;
    236     int i;
     236    zend_uint i;
    237237
    238238    opline = op_array->opcodes;
     
    282282ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, zend_uchar type, void *key, uint len TSRMLS_DC) /* {{{ */
    283283{
     284    zend_class_entry *cep = CestToCePtr(*cest);
    284285    ZESW(void *stored_ce_ptr, );
    285     zend_class_entry *cep = CestToCePtr(*cest);
    286286
    287287    if (zend_u_hash_add(CG(class_table), type, key, len,
  • trunk/xcache.c

    r9 r11  
    2727#include "opcode_spec.h"
    2828
     29#undef NDEBUG
    2930#ifdef DEBUG
    30 #   undef NDEBUG
    3131#   undef inline
    3232#   define inline
     
    340340    for (i = 0, c = cache->hentry->size; i < c; i ++) {
    341341        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);
    343343        }
    344344    }
     
    348348    array_init(list);
    349349    for (e = cache->deletes; e; e = e->next) {
    350         xc_fillentry_dmz(e, 1, list);
     350        xc_fillentry_dmz(e, 1, list TSRMLS_CC);
    351351    }
    352352    add_assoc_zval(return_value, "deleted_list", list);
     
    402402    int i;
    403403    xc_cache_t *cache;
    404     typeof(cache->deletes) p, *last;
     404    typedef xc_entry_t *xc_delete_t;
     405    xc_delete_t p, *last;
    405406
    406407    for (i = 0; i < size; i ++) {
     
    408409        ENTER_LOCK(cache) {
    409410            if (cache->deletes) {
    410                 last = (typeof(last)) &cache->deletes;
     411                last = (xc_delete_t *) &cache->deletes;
    411412                for (p = *last; p; p = p->next) {
    412413                    if (t - p->dtime > 3600) {
     
    433434}
    434435/* }}} */
    435 static inline void xc_entry_unholds_real(xc_stack_t *holds, xc_cache_t **caches, int cachecount) /* {{{ */
     436static inline void xc_entry_unholds_real(xc_stack_t *holds, xc_cache_t **caches, int cachecount TSRMLS_DC) /* {{{ */
    436437{
    437438    int i;
     
    457458static void xc_entry_unholds(TSRMLS_D) /* {{{ */
    458459{
    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/* }}} */
     464static int xc_stat(const char *filename, const char *include_path, struct stat *pbuf TSRMLS_DC) /* {{{ */
    464465{
    465466    char filepath[1024];
     
    472473    memcpy(paths, include_path, size);
    473474
    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)) {
    475476        if (strlen(path) + strlen(filename) + 1 > 1024) {
    476477            continue;
     
    536537        }
    537538        else {
    538             if (xc_stat(filename, PG(include_path), pbuf) != 0) {   
     539            if (xc_stat(filename, PG(include_path), pbuf TSRMLS_CC) != 0) {   
    539540                return 0;
    540541            }
     
    825826static int xc_init_constant(int module_number TSRMLS_DC) /* {{{ */
    826827{
    827     struct {
     828    typedef struct {
    828829        const char *prefix;
    829830        int (*getsize)();
    830831        const char *(*get)(zend_uchar i);
    831     } nameinfos[] = {
     832    } xc_meminfo_t;
     833    xc_meminfo_t nameinfos[] = {
    832834        { "",        xc_get_op_type_count,   xc_get_op_type   },
    833835        { "",        xc_get_data_type_count, xc_get_data_type },
     
    836838        { NULL, NULL, NULL }
    837839    };
    838     typeof(nameinfos[0])* p;
     840    xc_meminfo_t* p;
    839841    int i;
    840842    char const_name[96];
     
    861863}
    862864/* }}} */
    863 static xc_shm_t *xc_cache_destroy(xc_cache_t **caches, xc_hash_t *hcache TSRMLS_DC) /* {{{ */
     865static xc_shm_t *xc_cache_destroy(xc_cache_t **caches, xc_hash_t *hcache) /* {{{ */
    864866{
    865867    int i;
     
    891893}
    892894/* }}} */
    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) /* {{{ */
     895static xc_cache_t **xc_cache_init(xc_shm_t *shm, char *ptr, xc_hash_t *hcache, xc_hash_t *hentry, xc_shmsize_t shmsize) /* {{{ */
    894896{
    895897    xc_cache_t **caches = NULL, *cache;
    896898    xc_mem_t *mem;
    897899    int i;
     900
    898901    xc_memsize_t memsize = shmsize / hcache->size;
    899902
     
    948951static int xc_init(int module_number TSRMLS_DC) /* {{{ */
    949952{
    950     xc_php_caches = xc_var_caches = NULL;
    951953    xc_shm_t *shm;
    952954    char *ptr;
     955
     956    xc_php_caches = xc_var_caches = NULL;
    953957
    954958    if (xc_php_size || xc_var_size) {
     
    10571061/* }}} */
    10581062
    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 
    10661063/* user functions */
    10671064/* {{{ xcache_op */
     
    10691066static void xcache_op(xcache_op_type optype, INTERNAL_FUNCTION_PARAMETERS)
    10701067{
    1071     NEED_INITIZED();
    10721068    long type;
    10731069    int size;
    10741070    xc_cache_t **caches, *cache;
    10751071    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    }
    10761077
    10771078    if (optype == XC_OP_COUNT) {
     
    12391240            }
    12401241            else {
    1241                 xc_entry_remove_dmz(stored_xce);
     1242                xc_entry_remove_dmz(stored_xce TSRMLS_CC);
    12421243            }
    12431244        }
     
    12661267        stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC);
    12671268        if (stored_xce) {
    1268             xc_entry_remove_dmz(stored_xce);
     1269            xc_entry_remove_dmz(stored_xce TSRMLS_CC);
    12691270        }
    12701271        var.value = value;
    12711272        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);
    12731274    } LEAVE_LOCK(xce.cache);
    12741275}
     
    12971298            }
    12981299            else {
    1299                 xc_entry_remove_dmz(stored_xce);
     1300                xc_entry_remove_dmz(stored_xce TSRMLS_CC);
    13001301            }
    13011302        }
     
    13221323        stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC);
    13231324        if (stored_xce) {
    1324             xc_entry_remove_dmz(stored_xce);
     1325            xc_entry_remove_dmz(stored_xce TSRMLS_CC);
    13251326            RETVAL_TRUE;
    13261327        }
     
    13591360                fprintf(stderr, "incdec: expired\n");
    13601361#endif
    1361                 xc_entry_remove_dmz(stored_xce);
     1362                xc_entry_remove_dmz(stored_xce TSRMLS_CC);
    13621363                stored_xce = NULL;
    13631364            }
     
    13991400            xce.ctime = stored_xce->ctime;
    14001401            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);
    14041405
    14051406    } LEAVE_LOCK(xce.cache);
     
    14921493    }
    14931494    if (spec >= 0 && spec < count) {
    1494         name = getter(spec);
     1495        name = getter((zend_uchar) spec);
    14951496        if (name) {
    14961497            /* RETURN_STRING */
     
    15401541    }
    15411542    if (spec <= xc_get_opcode_spec_count()) {
    1542         opspec = xc_get_opcode_spec(spec);
     1543        opspec = xc_get_opcode_spec((zend_uchar) spec);
    15431544        if (opspec) {
    15441545            array_init(return_value);
     
    18861887#endif
    18871888{
     1889    TSRMLS_FETCH();
     1890
    18881891    xc_request_shutdown(TSRMLS_C);
    18891892    return SUCCESS;
  • trunk/xcache.h

    r2 r11  
    5252#define BUCKET_KEY_TYPE(b) (UNISW(0, (b)->key.type))
    5353#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)
    5757#endif
    5858#define BUCKET_SIZE(b) (BUCKET_HEAD_SIZE(b) + BUCKET_KEY_SIZE(b))
     
    117117/* {{{ xc_cache_t */
    118118typedef struct _xc_entry_t xc_entry_t;
    119 typedef volatile struct {
     119typedef struct {
    120120    int cacheid;
    121121    xc_hash_t  *hcache; /* hash to cacheid */
    122122
    123     zend_bool  compiling;
     123    time_t     compiling;
    124124    zend_ulong misses;
    125125    zend_ulong hits;
Note: See TracChangeset for help on using the changeset viewer.