Changeset 1026


Ignore:
Timestamp:
2012-07-22T08:26:35+02:00 (3 years ago)
Author:
moo
Message:

refactor: split extension init to sub module. TODO: compatibility regression

Location:
trunk
Files:
4 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r979 r1026  
    1414 * closes #73: warn for improper PHP_FCGI_CHILDREN setting fcgi mode (>=PHP_5_3)
    1515 * closes #174: updated api for clear all cache
     16 * uses extension to load XCache. load via zend_extension is unsupported
    1617
    17182.0.1 2012-07-14
  • trunk/Makefile.frag.deps

    r1018 r1026  
    11$(XCACHE_INCLUDES_I) $(builddir)/includes.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h
    22$(builddir)/mod_assembler/xc_assembler.lo:
    3 $(builddir)/mod_coverager/xc_coverager.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(srcdir)/mod_coverager/xc_coverager.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h
     3$(builddir)/mod_coverager/xc_coverager.lo: $(srcdir)/mod_coverager/xc_coverager.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
    44$(builddir)/mod_decoder/xc_decoder.lo:
    55$(builddir)/mod_disassembler/xc_disassembler.lo: $(srcdir)/mod_disassembler/xc_disassembler.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_compatibility.h $(XCACHE_PROC_H)
    66$(builddir)/mod_encoder/xc_encoder.lo:
    7 $(builddir)/mod_optimizer/xc_optimizer.lo: $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
     7$(builddir)/mod_optimizer/xc_optimizer.lo: $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
    88$(builddir)/util/xc_stack.lo: $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_stack.h
    99$(builddir)/util/xc_trace.lo: $(srcdir)/util/xc_trace.h
    10 $(builddir)/xcache.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(XCACHE_PROC_H) $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_vector.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_foreachcoresig.h
     10$(builddir)/xcache.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(XCACHE_PROC_H) $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_vector.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_foreachcoresig.h
    1111$(builddir)/xcache/xc_compatibility.lo: $(srcdir)/xcache/xc_compatibility.h
    1212$(builddir)/xcache/xc_const_string.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_const_string_opcodes_php5.4.h
     13$(builddir)/xcache/xc_extension.lo: $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_trace.h
     14$(builddir)/xcache/xc_ini.lo: $(srcdir)/xcache/xc_ini.h
    1315$(builddir)/xcache/xc_lock.lo: $(srcdir)/xcache/xc_lock.h
    1416$(builddir)/xcache/xc_malloc.lo: $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_align.h
  • trunk/NEWS

    r979 r1026  
    44 * adds warning for misconfiguration
    55 * auto disable caching on crash
     6 * uses extension to load XCache. load via zend_extension is unsupported
    67
    782.0.1 2012-07-14
  • trunk/config.m4

    r1011 r1026  
    3232done
    3333  for i in \
     34xc_compatibility.c \
    3435xc_const_string.c \
    35 xc_compatibility.c \
     36xc_extension.c \
     37xc_ini.c \
    3638xc_lock.c \
    3739xc_mem.c \
  • trunk/config.w32

    r1011 r1026  
    1919
    2020    ADD_SOURCES(configure_module_dirname + "/xcache", " \
     21xc_compatibility.c \
    2122xc_const_string.c \
    22 xc_compatibility.c \
     23xc_extension.c \
     24xc_ini.c \
    2325xc_lock.c \
    2426xc_mem.c \
  • trunk/mod_cacher/htdocs/xcache.php

    r976 r1026  
    355355    phpinfo(INFO_MODULES);
    356356    $moduleinfo = ob_get_clean();
    357     if (preg_match('!XCache</a></h2>(.*?)<h2>!is', $moduleinfo, $m)) {
    358         $moduleinfo = $m[1];
     357    if (preg_match_all('!XCache[^<]*</a></h2>(.*?)<h2>!is', $moduleinfo, $m)) {
     358        $moduleinfo = implode('', $m[1]);
    359359    }
    360360    else {
  • trunk/mod_coverager/xc_coverager.c

    r1008 r1026  
    22#define XCACHE_DEBUG
    33#endif
     4
     5#include "xc_coverager.h"
    46
    57#include <stdio.h>
     
    1315#include <fcntl.h>
    1416
     17#include "xcache/xc_extension.h"
     18#include "xcache/xc_ini.h"
     19#include "xcache/xc_utils.h"
    1520#include "util/xc_stack.h"
    1621#include "util/xc_trace.h"
    1722#include "xcache_globals.h"
    18 #include "xc_coverager.h"
    19 #include "xcache/xc_utils.h"
     23
     24#include "ext/standard/info.h"
    2025
    2126typedef HashTable *coverager_t;
     
    3439}
    3540/* }}} */
    36 void xcache_mkdirs_ex(char *root, int rootlen, char *path, int pathlen TSRMLS_DC) /* {{{ */
     41static void xcache_mkdirs_ex(char *root, int rootlen, char *path, int pathlen TSRMLS_DC) /* {{{ */
    3742{
    3843    char *fullpath;
     
    248253/* }}} */
    249254
    250 void xc_coverager_request_init(TSRMLS_D) /* {{{ */
     255static PHP_RINIT_FUNCTION(xcache_coverager) /* {{{ */
    251256{
    252257    if (XG(coverager)) {
     
    261266        XG(coverage_enabled) = 0;
    262267    }
     268    return SUCCESS;
    263269}
    264270/* }}} */
     
    335341}
    336342/* }}} */
    337 void xc_coverager_request_shutdown(TSRMLS_D) /* {{{ */
     343static PHP_RSHUTDOWN_FUNCTION(xcache_coverager) /* {{{ */
    338344{
    339345    if (XG(coverager)) {
     
    341347        xc_coverager_cleanup(TSRMLS_C);
    342348    }
     349    return SUCCESS;
    343350}
    344351/* }}} */
     
    457464
    458465/* hits */
    459 void xc_coverager_handle_ext_stmt(zend_op_array *op_array, zend_uchar op) /* {{{ */
     466static void xc_coverager_handle_ext_stmt(zend_op_array *op_array, zend_uchar op) /* {{{ */
    460467{
    461468    TSRMLS_FETCH();
     
    471478/* }}} */
    472479
    473 /* MINIT/MSHUTDOWN */
    474 int xc_coverager_module_init(int module_number TSRMLS_DC) /* {{{ */
     480/* user api */
     481/* {{{ proto array xcache_coverager_decode(string data)
     482 * decode specified data which is saved by auto dumper to array
     483 */
     484PHP_FUNCTION(xcache_coverager_decode)
     485{
     486    char *str;
     487    int len;
     488    long *p;
     489
     490    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &len) == FAILURE) {
     491        return;
     492    }
     493
     494    array_init(return_value);
     495
     496    p = (long*) str;
     497    len -= sizeof(long);
     498    if (len < 0) {
     499        return;
     500    }
     501    if (*p++ != PCOV_HEADER_MAGIC) {
     502        TRACE("%s", "wrong magic in xcache_coverager_decode");
     503        return;
     504    }
     505
     506    for (; len >= (int) sizeof(long) * 2; len -= sizeof(long) * 2, p += 2) {
     507        add_index_long(return_value, p[0], p[1] < 0 ? 0 : p[1]);
     508    }
     509}
     510/* }}} */
     511/* {{{ proto void xcache_coverager_start([bool clean = true])
     512 * starts coverager data collecting
     513 */
     514PHP_FUNCTION(xcache_coverager_start)
     515{
     516    zend_bool clean = 1;
     517
     518    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clean) == FAILURE) {
     519        return;
     520    }
     521
     522    if (clean) {
     523        xc_coverager_clean(TSRMLS_C);
     524    }
     525
     526    if (XG(coverager)) {
     527        xc_coverager_enable(TSRMLS_C);
     528    }
     529    else {
     530        php_error(E_WARNING, "You can only start coverager after you set 'xcache.coverager' to 'On' in ini");
     531    }
     532}
     533/* }}} */
     534/* {{{ proto void xcache_coverager_stop([bool clean = false])
     535 * stop coverager data collecting
     536 */
     537PHP_FUNCTION(xcache_coverager_stop)
     538{
     539    zend_bool clean = 0;
     540
     541    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clean) == FAILURE) {
     542        return;
     543    }
     544
     545    xc_coverager_disable(TSRMLS_C);
     546    if (clean) {
     547        xc_coverager_clean(TSRMLS_C);
     548    }
     549}
     550/* }}} */
     551/* {{{ proto array xcache_coverager_get([bool clean = false])
     552 * get coverager data collected
     553 */
     554PHP_FUNCTION(xcache_coverager_get)
     555{
     556    zend_bool clean = 0;
     557    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clean) == FAILURE) {
     558        return;
     559    }
     560
     561    xc_coverager_dump(return_value TSRMLS_CC);
     562    if (clean) {
     563        xc_coverager_clean(TSRMLS_C);
     564    }
     565}
     566/* }}} */
     567static zend_function_entry xcache_coverager_functions[] = /* {{{ */
     568{
     569    PHP_FE(xcache_coverager_decode,  NULL)
     570    PHP_FE(xcache_coverager_start,   NULL)
     571    PHP_FE(xcache_coverager_stop,    NULL)
     572    PHP_FE(xcache_coverager_get,     NULL)
     573    PHP_FE_END
     574};
     575/* }}} */
     576
     577static int xc_zend_startup(zend_extension *extension) /* {{{ */
     578{
     579    return SUCCESS;
     580}
     581/* }}} */
     582static void xc_zend_shutdown(zend_extension *extension) /* {{{ */
     583{
     584    /* empty */
     585}
     586/* }}} */
     587static void xc_statement_handler(zend_op_array *op_array) /* {{{ */
     588{
     589#ifdef HAVE_XCACHE_COVERAGER
     590    xc_coverager_handle_ext_stmt(op_array, ZEND_EXT_STMT);
     591#endif
     592}
     593/* }}} */
     594static void xc_fcall_begin_handler(zend_op_array *op_array) /* {{{ */
     595{
     596#if 0
     597    xc_coverager_handle_ext_stmt(op_array, ZEND_EXT_FCALL_BEGIN);
     598#endif
     599}
     600/* }}} */
     601static void xc_fcall_end_handler(zend_op_array *op_array) /* {{{ */
     602{
     603#if 0
     604    xc_coverager_handle_ext_stmt(op_array, ZEND_EXT_FCALL_END);
     605#endif
     606}
     607/* }}} */
     608/* {{{ zend extension definition structure */
     609static zend_extension xc_coverager_zend_extension_entry = {
     610    XCACHE_NAME " Coverager",
     611    XCACHE_VERSION,
     612    XCACHE_AUTHOR,
     613    XCACHE_URL,
     614    XCACHE_COPYRIGHT,
     615    xc_zend_startup,
     616    xc_zend_shutdown,
     617    NULL,           /* activate_func_t */
     618    NULL,           /* deactivate_func_t */
     619    NULL,           /* message_handler_func_t */
     620    NULL,           /* statement_handler_func_t */
     621    xc_statement_handler,
     622    xc_fcall_begin_handler,
     623    xc_fcall_end_handler,
     624    NULL,           /* op_array_ctor_func_t */
     625    NULL,           /* op_array_dtor_func_t */
     626    STANDARD_ZEND_EXTENSION_PROPERTIES
     627};
     628/* }}} */
     629/* {{{ PHP_INI */
     630PHP_INI_BEGIN()
     631    STD_PHP_INI_BOOLEAN("xcache.coverager"      ,        "0", PHP_INI_ALL,    OnUpdateBool,         coverager,         zend_xcache_globals, xcache_globals)
     632    PHP_INI_ENTRY1     ("xcache.coveragedump_directory",  "", PHP_INI_SYSTEM, xcache_OnUpdateDummy, NULL)
     633PHP_INI_END()
     634/* }}} */
     635static PHP_MINFO_FUNCTION(xcache_coverager) /* {{{ */
     636{
     637    char *covdumpdir;
     638
     639    php_info_print_table_start();
     640    php_info_print_table_row(2, "XCache Coverager Version", XCACHE_VERSION);
     641    if (cfg_get_string("xcache.coveragedump_directory", &covdumpdir) != SUCCESS || !covdumpdir[0]) {
     642        covdumpdir = NULL;
     643    }
     644    php_info_print_table_row(2, "Coverage Auto Dumper", XG(coverager) && covdumpdir ? "enabled" : "disabled");
     645    php_info_print_table_end();
     646
     647    DISPLAY_INI_ENTRIES();
     648}
     649/* }}} */
     650static PHP_MINIT_FUNCTION(xcache_coverager) /* {{{ */
    475651{
    476652    old_compile_file = zend_compile_file;
    477653    zend_compile_file = xc_compile_file_for_coverage;
     654
     655    REGISTER_INI_ENTRIES();
    478656
    479657    if (cfg_get_string("xcache.coveragedump_directory", &xc_coveragedump_dir) == SUCCESS && xc_coveragedump_dir) {
     
    492670    }
    493671
    494     return SUCCESS;
    495 }
    496 /* }}} */
    497 void xc_coverager_module_shutdown() /* {{{ */
     672    return xcache_zend_extension_register(&xc_coverager_zend_extension_entry, 0);
     673}
     674/* }}} */
     675static PHP_MSHUTDOWN_FUNCTION(xcache_coverager) /* {{{ */
    498676{
    499677    if (old_compile_file == xc_compile_file_for_coverage) {
     
    504682        xc_coveragedump_dir = NULL;
    505683    }
    506 }
    507 /* }}} */
    508 
    509 /* user api */
    510 /* {{{ proto array xcache_coverager_decode(string data)
    511  * decode specified data which is saved by auto dumper to array
    512  */
    513 PHP_FUNCTION(xcache_coverager_decode)
    514 {
    515     char *str;
    516     int len;
    517     long *p;
    518 
    519     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &len) == FAILURE) {
    520         return;
    521     }
    522 
    523     array_init(return_value);
    524 
    525     p = (long*) str;
    526     len -= sizeof(long);
    527     if (len < 0) {
    528         return;
    529     }
    530     if (*p++ != PCOV_HEADER_MAGIC) {
    531         TRACE("%s", "wrong magic in xcache_coverager_decode");
    532         return;
    533     }
    534 
    535     for (; len >= (int) sizeof(long) * 2; len -= sizeof(long) * 2, p += 2) {
    536         add_index_long(return_value, p[0], p[1] < 0 ? 0 : p[1]);
    537     }
    538 }
    539 /* }}} */
    540 /* {{{ proto void xcache_coverager_start([bool clean = true])
    541  * starts coverager data collecting
    542  */
    543 PHP_FUNCTION(xcache_coverager_start)
    544 {
    545     zend_bool clean = 1;
    546 
    547     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clean) == FAILURE) {
    548         return;
    549     }
    550 
    551     if (clean) {
    552         xc_coverager_clean(TSRMLS_C);
    553     }
    554 
    555     if (XG(coverager)) {
    556         xc_coverager_enable(TSRMLS_C);
    557     }
    558     else {
    559         php_error(E_WARNING, "You can only start coverager after you set 'xcache.coverager' to 'On' in ini");
    560     }
    561 }
    562 /* }}} */
    563 /* {{{ proto void xcache_coverager_stop([bool clean = false])
    564  * stop coverager data collecting
    565  */
    566 PHP_FUNCTION(xcache_coverager_stop)
    567 {
    568     zend_bool clean = 0;
    569 
    570     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clean) == FAILURE) {
    571         return;
    572     }
    573 
    574     xc_coverager_disable(TSRMLS_C);
    575     if (clean) {
    576         xc_coverager_clean(TSRMLS_C);
    577     }
    578 }
    579 /* }}} */
    580 /* {{{ proto array xcache_coverager_get([bool clean = false])
    581  * get coverager data collected
    582  */
    583 PHP_FUNCTION(xcache_coverager_get)
    584 {
    585     zend_bool clean = 0;
    586     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clean) == FAILURE) {
    587         return;
    588     }
    589 
    590     xc_coverager_dump(return_value TSRMLS_CC);
    591     if (clean) {
    592         xc_coverager_clean(TSRMLS_C);
    593     }
    594 }
    595 /* }}} */
     684    UNREGISTER_INI_ENTRIES();
     685    return xcache_zend_extension_unregister(&xc_coverager_zend_extension_entry);
     686}
     687/* }}} */
     688
     689static zend_module_entry xcache_coverager_module_entry = { /* {{{ */
     690    STANDARD_MODULE_HEADER,
     691    XCACHE_NAME "_Coverager",
     692    xcache_coverager_functions,
     693    PHP_MINIT(xcache_coverager),
     694    PHP_MSHUTDOWN(xcache_coverager),
     695    PHP_RINIT(xcache_coverager),
     696    PHP_RSHUTDOWN(xcache_coverager),
     697    PHP_MINFO(xcache_coverager),
     698    XCACHE_VERSION,
     699#ifdef PHP_GINIT
     700    NO_MODULE_GLOBALS,
     701#endif
     702#ifdef ZEND_ENGINE_2
     703    NULL,
     704#else
     705    NULL,
     706    NULL,
     707#endif
     708    STANDARD_MODULE_PROPERTIES_EX
     709};
     710/* }}} */
     711int xc_coverager_startup_module() /* {{{ */
     712{
     713    return zend_startup_module(&xcache_coverager_module_entry);
     714}
     715/* }}} */
  • trunk/mod_coverager/xc_coverager.h

    r1003 r1026  
     1#ifndef XC_COVERAGER_H_D5BB29AAB992B932E91C70A8C2F5D2B1
     2#define XC_COVERAGER_H_D5BB29AAB992B932E91C70A8C2F5D2B1
     3
     4#if _MSC_VER > 1000
     5#pragma once
     6#endif // _MSC_VER > 1000
     7
    18#include "php.h"
    2 #include "xcache.h"
    39
    4 void xc_coverager_handle_ext_stmt(zend_op_array *op_array, zend_uchar op);
    5 int xc_coverager_module_init(int module_number TSRMLS_DC);
    6 void xc_coverager_module_shutdown();
    7 void xc_coverager_request_init(TSRMLS_D);
    8 void xc_coverager_request_shutdown(TSRMLS_D);
    9 PHP_FUNCTION(xcache_coverager_decode);
    10 PHP_FUNCTION(xcache_coverager_start);
    11 PHP_FUNCTION(xcache_coverager_stop);
    12 PHP_FUNCTION(xcache_coverager_get);
    13 #define XCACHE_COVERAGER_FUNCTIONS() \
    14     PHP_FE(xcache_coverager_decode,  NULL) \
    15     PHP_FE(xcache_coverager_start,   NULL) \
    16     PHP_FE(xcache_coverager_stop,    NULL) \
    17     PHP_FE(xcache_coverager_get,     NULL)
     10int xc_coverager_startup_module();
     11
     12#endif /* XC_COVERAGER_H_D5BB29AAB992B932E91C70A8C2F5D2B1 */
  • trunk/mod_disassembler/xc_disassembler.c

    r1003 r1026  
    33#include "xcache/xc_utils.h"
    44#include "xcache/xc_sandbox.h"
     5#include "xcache/xc_compatibility.h"
    56#include "xc_processor.h"
     7
     8#include "ext/standard/info.h"
    69
    710static void xc_dasm(zval *output, zend_op_array *op_array TSRMLS_DC) /* {{{ */
     
    216219}
    217220/* }}} */
     221
     222/* {{{ PHP_MINFO_FUNCTION(xcache_disassembler) */
     223static PHP_MINFO_FUNCTION(xcache_disassembler)
     224{
     225    php_info_print_table_start();
     226    php_info_print_table_row(2, "XCache Disassembler Version", XCACHE_VERSION);
     227    php_info_print_table_end();
     228
     229    DISPLAY_INI_ENTRIES();
     230}
     231/* }}} */
     232static zend_function_entry xcache_disassembler_functions[] = /* {{{ */
     233{
     234    PHP_FE(xcache_dasm_file,         NULL)
     235    PHP_FE(xcache_dasm_string,       NULL)
     236    PHP_FE_END
     237};
     238/* }}} */
     239static zend_module_entry xcache_disassembler_module_entry = { /* {{{ */
     240    STANDARD_MODULE_HEADER,
     241    XCACHE_NAME "_Disassembler",
     242    xcache_disassembler_functions,
     243    NULL,
     244    NULL,
     245    NULL,
     246    NULL,
     247    PHP_MINFO(xcache_disassembler),
     248    XCACHE_VERSION,
     249#ifdef PHP_GINIT
     250    NO_MODULE_GLOBALS,
     251#endif
     252#ifdef ZEND_ENGINE_2
     253    NULL,
     254#else
     255    NULL,
     256    NULL,
     257#endif
     258    STANDARD_MODULE_PROPERTIES_EX
     259};
     260/* }}} */
     261int xc_disassembler_startup_module() /* {{{ */
     262{
     263    return zend_startup_module(&xcache_disassembler_module_entry);
     264}
     265/* }}} */
  • trunk/mod_disassembler/xc_disassembler.h

    r1003 r1026  
    1 #include "php.h"
     1#ifndef XC_DISASSEMBLER_H_1547840703D7ADD9C19041818BE9E3C7
     2#define XC_DISASSEMBLER_H_1547840703D7ADD9C19041818BE9E3C7
    23
    3 PHP_FUNCTION(xcache_dasm_file);
    4 PHP_FUNCTION(xcache_dasm_string);
    5 #define XCACHE_DISASSEMBLER_FUNCTIONS() \
    6     PHP_FE(xcache_dasm_file,         NULL) \
    7     PHP_FE(xcache_dasm_string,       NULL)
     4#if _MSC_VER > 1000
     5#pragma once
     6#endif // _MSC_VER > 1000
     7
     8int xc_disassembler_startup_module();
     9
     10#endif /* XC_DISASSEMBLER_H_1547840703D7ADD9C19041818BE9E3C7 */
  • trunk/mod_optimizer/xc_optimizer.c

    r1008 r1026  
    33#endif
    44
     5#include "xc_optimizer.h"
     6#include "xcache/xc_extension.h"
     7#include "xcache/xc_ini.h"
    58#include "xcache/xc_utils.h"
    6 #include "xc_optimizer.h"
    7 /* the "vector" stack */
    89#include "util/xc_stack.h"
    910#include "util/xc_trace.h"
    1011#include "xcache_globals.h"
     12
     13#include "ext/standard/info.h"
    1114
    1215#ifdef XCACHE_DEBUG
     
    607610}
    608611/* }}} */
    609 void xc_optimizer_op_array_handler(zend_op_array *op_array) /* {{{ */
     612static void xc_optimizer_op_array_handler(zend_op_array *op_array) /* {{{ */
    610613{
    611614    TSRMLS_FETCH();
     
    615618}
    616619/* }}} */
     620
     621static int xc_zend_startup(zend_extension *extension) /* {{{ */
     622{
     623    return SUCCESS;
     624}
     625/* }}} */
     626static void xc_zend_shutdown(zend_extension *extension) /* {{{ */
     627{
     628}
     629/* }}} */
     630/* {{{ zend extension definition structure */
     631static zend_extension xc_optimizer_zend_extension_entry = {
     632    XCACHE_NAME " Optimizer",
     633    XCACHE_VERSION,
     634    XCACHE_AUTHOR,
     635    XCACHE_URL,
     636    XCACHE_COPYRIGHT,
     637    xc_zend_startup,
     638    xc_zend_shutdown,
     639    NULL,           /* activate_func_t */
     640    NULL,           /* deactivate_func_t */
     641    NULL,           /* message_handler_func_t */
     642    xc_optimizer_op_array_handler,
     643    NULL,           /* statement_handler_func_t */
     644    NULL,           /* fcall_begin_handler_func_t */
     645    NULL,           /* fcall_end_handler_func_t */
     646    NULL,           /* op_array_ctor_func_t */
     647    NULL,           /* op_array_dtor_func_t */
     648    STANDARD_ZEND_EXTENSION_PROPERTIES
     649};
     650/* }}} */
     651
     652/* {{{ ini */
     653PHP_INI_BEGIN()
     654    STD_PHP_INI_BOOLEAN("xcache.optimizer",              "0", PHP_INI_ALL,    OnUpdateBool,        optimizer,         zend_xcache_globals, xcache_globals)
     655PHP_INI_END()
     656/* }}} */
     657static PHP_MINFO_FUNCTION(xcache_optimizer) /* {{{ */
     658{
     659    php_info_print_table_start();
     660    php_info_print_table_row(2, "XCache Optimizer Version", XCACHE_VERSION);
     661    php_info_print_table_end();
     662
     663    DISPLAY_INI_ENTRIES();
     664}
     665/* }}} */
     666static PHP_MINIT_FUNCTION(xcache_optimizer) /* {{{ */
     667{
     668    REGISTER_INI_ENTRIES();
     669    return xcache_zend_extension_register(&xc_optimizer_zend_extension_entry, 0);
     670}
     671/* }}} */
     672static PHP_MSHUTDOWN_FUNCTION(xcache_optimizer) /* {{{ */
     673{
     674    UNREGISTER_INI_ENTRIES();
     675    return xcache_zend_extension_unregister(&xc_optimizer_zend_extension_entry);
     676}
     677/* }}} */
     678static zend_module_entry xcache_optimizer_module_entry = { /* {{{ */
     679    STANDARD_MODULE_HEADER,
     680    XCACHE_NAME "_Optimizer",
     681    NULL,
     682    PHP_MINIT(xcache_optimizer),
     683    PHP_MSHUTDOWN(xcache_optimizer),
     684    NULL,
     685    NULL,
     686    PHP_MINFO(xcache_optimizer),
     687    XCACHE_VERSION,
     688#ifdef PHP_GINIT
     689    NO_MODULE_GLOBALS,
     690#endif
     691#ifdef ZEND_ENGINE_2
     692    NULL,
     693#else
     694    NULL,
     695    NULL,
     696#endif
     697    STANDARD_MODULE_PROPERTIES_EX
     698};
     699/* }}} */
     700int xc_optimizer_startup_module() /* {{{ */
     701{
     702    return zend_startup_module(&xcache_optimizer_module_entry);
     703}
     704/* }}} */
  • trunk/mod_optimizer/xc_optimizer.h

    r1003 r1026  
     1#ifndef XC_OPTIMIZER_H_6614228F428A266C39CDAC30269D9857
     2#define XC_OPTIMIZER_H_6614228F428A266C39CDAC30269D9857
     3
     4#if _MSC_VER > 1000
     5#pragma once
     6#endif // _MSC_VER > 1000
     7
    18#include "php.h"
    2 #include "xcache.h"
    39
    4 void xc_optimizer_op_array_handler(zend_op_array *op_array);
    5 #define XCACHE_OPTIMIZER_FUNCTIONS()
     10int xc_optimizer_startup_module();
     11
     12#endif /* XC_OPTIMIZER_H_6614228F428A266C39CDAC30269D9857 */
  • trunk/xcache-test.ini

    r870 r1026  
    33
    44[xcache]
    5 zend_extension_debug_ts=./modules/xcache.so
    6 zend_extension_debug=./modules/xcache.so
    7 zend_extension_ts=./modules/xcache.so
    8 zend_extension=./modules/xcache.so
     5extension_dir="./modules/"
     6extension=xcache.so
    97xcache.cacher = On
    108xcache.test = 1
  • trunk/xcache-zh-gb2312.ini

    r927 r1026  
    11;; ±¾ÎļþÖ»ÊÇÀý×Ó, ÇëÔÚ php.ini ÀïÉèÖÃÒÔ±ãÉúЧ
    22[xcache-common]
    3 ;; ¾¯¸æ: zend_extension* = *xcache* ±ØÐëÊÇËùÓÐ zend_extension*=* Ö®ÖеÚÒ»¸ö³öÏÖ
    4 ;; °²×°³É zend extension, ·¾¶Ò»°ãÊÇ "$extension_dir/xcache.so"
    5 ;; ²»ÍƼöʹÓà extension=xcache.so
    6 
    7 ;; ·Ç windows Àý×Ó
    8 ;; install as zend extension, normally "$extension_dir/xcache.so"
    9 zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so
     3;; ·Ç windows Àý×Ó:
     4extension = xcache.so
    105;; Windows ϵͳÀý×Ó:
    11 zend_extension_ts = c:/php/extensions/php_xcache.dll
    12 ;; ¶ÔÓÚа汾 PHP, _ts ºó׺ÒѾ­ÒƳý, ÇëʹÓÃÏÂÃæÕâÐÐ
    13 zend_extension = c:/php/extensions/php_xcache.dll
     6; extension = php_xcache.dll
    147
    158[xcache.admin]
  • trunk/xcache.c

    r1003 r1026  
    1515#include <signal.h>
    1616
    17 #include "php.h"
    18 #include "ext/standard/info.h"
    19 #include "ext/standard/md5.h"
    20 #include "ext/standard/php_math.h"
    21 #include "ext/standard/php_string.h"
    22 #include "zend_extensions.h"
    23 #include "SAPI.h"
    24 
    2517#include "xcache.h"
    2618#ifdef ZEND_ENGINE_2_1
     
    3022#ifdef HAVE_XCACHE_OPTIMIZER
    3123#   include "mod_optimizer/xc_optimizer.h"
    32 #else
    33 #   define XCACHE_OPTIMIZER_FUNCTIONS()
    3424#endif
    3525#ifdef HAVE_XCACHE_COVERAGER
    3626#   include "mod_coverager/xc_coverager.h"
    37 #else
    38 #   define XCACHE_COVERAGER_FUNCTIONS()
    3927#endif
    4028#ifdef HAVE_XCACHE_DISASSEMBLER
    4129#   include "mod_disassembler/xc_disassembler.h"
    42 #else
    43 #   define XCACHE_DISASSEMBLER_FUNCTIONS()
    4430#endif
    4531
    4632#include "xcache_globals.h"
    4733#include "xc_processor.h"
     34#include "xcache/xc_extension.h"
     35#include "xcache/xc_ini.h"
    4836#include "xcache/xc_const_string.h"
    4937#include "xcache/xc_opcode_spec.h"
     
    5442#include "util/xc_vector.h"
    5543#include "util/xc_trace.h"
     44
     45#include "php.h"
     46#include "ext/standard/info.h"
     47#include "ext/standard/md5.h"
     48#include "ext/standard/php_math.h"
     49#include "ext/standard/php_string.h"
     50#include "SAPI.h"
    5651
    5752#define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > (pentry)->ctime + (time_t) (pentry)->ttl)
     
    124119zend_bool xc_have_op_array_ctor = 0;
    125120
    126 static zend_bool xc_module_gotup = 0;
    127 static zend_bool xc_zend_extension_gotup = 0;
    128 static zend_bool xc_zend_extension_faked = 0;
    129 #if !COMPILE_DL_XCACHE
    130 #   define zend_extension_entry xcache_zend_extension_entry
    131 #endif
    132 ZEND_DLEXPORT zend_extension zend_extension_entry;
    133121ZEND_DECLARE_MODULE_GLOBALS(xcache)
    134122
     
    25272515    XG(request_time) = sapi_get_request_time(TSRMLS_C);
    25282516#endif
    2529 
    2530 #ifdef HAVE_XCACHE_COVERAGER
    2531     xc_coverager_request_init(TSRMLS_C);
    2532 #endif
    25332517}
    25342518/* }}} */
     
    25432527#ifdef ZEND_ENGINE_2
    25442528    zend_llist_destroy(&XG(gc_op_arrays));
    2545 #endif
    2546 #ifdef HAVE_XCACHE_COVERAGER
    2547     xc_coverager_request_shutdown(TSRMLS_C);
    25482529#endif
    25492530}
     
    33593340    PHP_FE(xcache_clear_cache,       NULL)
    33603341    PHP_FE(xcache_coredump,          NULL)
    3361     XCACHE_OPTIMIZER_FUNCTIONS()
    33623342#ifdef HAVE_XCACHE_ASSEMBLER
    33633343    PHP_FE(xcache_asm,               NULL)
    33643344#endif
    3365     XCACHE_DISASSEMBLER_FUNCTIONS()
    33663345#ifdef HAVE_XCACHE_ENCODER
    33673346    PHP_FE(xcache_encode,            NULL)
     
    33713350    PHP_FE(xcache_decode_string,     NULL)
    33723351#endif
    3373     XCACHE_COVERAGER_FUNCTIONS()
    33743352    PHP_FE(xcache_get_special_value, NULL)
    33753353    PHP_FE(xcache_get_type,          NULL)
     
    33913369    PHP_FE(xcache_dprint,            NULL)
    33923370#endif
    3393 #ifdef PHP_FE_END
    33943371    PHP_FE_END
    3395 #else
    3396     {NULL, NULL,                     NULL}
    3397 #endif
    33983372};
    33993373/* }}} */
     
    35473521#endif
    35483522
     3523static startup_func_t xc_last_ext_startup;
     3524static int xc_zend_startup_last(zend_extension *extension) /* {{{ */
     3525{
     3526    zend_extension *ext = zend_get_extension(XCACHE_NAME);
     3527    if (ext) {
     3528        zend_error(E_WARNING, "Module '" XCACHE_NAME "' already loaded");
     3529    }
     3530    /* restore */
     3531    extension->startup = xc_last_ext_startup;
     3532    if (extension->startup) {
     3533        if (extension->startup(extension) != SUCCESS) {
     3534            return FAILURE;
     3535        }
     3536    }
     3537    assert(xc_llist_zend_extension);
     3538    xcache_llist_prepend(&zend_extensions, xc_llist_zend_extension);
     3539    return SUCCESS;
     3540}
     3541/* }}} */
     3542static int xc_zend_startup(zend_extension *extension) /* {{{ */
     3543{
     3544    if (!origin_compile_file) {
     3545        origin_compile_file = zend_compile_file;
     3546        zend_compile_file = xc_check_initial_compile_file;
     3547    }
     3548
     3549    if (zend_llist_count(&zend_extensions) > 1) {
     3550        zend_llist_position lpos;
     3551        zend_extension *ext;
     3552
     3553        xc_llist_zend_extension = xcache_llist_get_element_by_zend_extension(&zend_extensions, XCACHE_NAME);
     3554        if (xc_llist_zend_extension != zend_extensions.head) {
     3555            zend_error(E_WARNING, "XCache failed to load itself as the first zend_extension. compatibility downgraded");
     3556        }
     3557        /* hide myself */
     3558        xcache_llist_unlink(&zend_extensions, xc_llist_zend_extension);
     3559
     3560        ext = (zend_extension *) zend_llist_get_last_ex(&zend_extensions, &lpos);
     3561        assert(ext && ext != (zend_extension *) xc_llist_zend_extension->data);
     3562        xc_last_ext_startup = ext->startup;
     3563        ext->startup = xc_zend_startup_last;
     3564    }
     3565    return SUCCESS;
     3566}
     3567/* }}} */
     3568static void xc_zend_shutdown(zend_extension *extension) /* {{{ */
     3569{
     3570}
     3571/* }}} */
     3572/* {{{ zend extension definition structure */
     3573static zend_extension zend_extension_entry = {
     3574    XCACHE_NAME,
     3575    XCACHE_VERSION,
     3576    XCACHE_AUTHOR,
     3577    XCACHE_URL,
     3578    XCACHE_COPYRIGHT,
     3579    xc_zend_startup,
     3580    xc_zend_shutdown,
     3581    NULL,           /* activate_func_t */
     3582    NULL,           /* deactivate_func_t */
     3583    NULL,           /* message_handler_func_t */
     3584    NULL,           /* op_array_handler_func_t */
     3585    NULL,           /* statement_handler_func_t */
     3586    NULL,           /* fcall_begin_handler_func_t */
     3587    NULL,           /* fcall_end_handler_func_t */
     3588    NULL,           /* op_array_ctor_func_t */
     3589    NULL,           /* op_array_dtor_func_t */
     3590    STANDARD_ZEND_EXTENSION_PROPERTIES
     3591};
     3592/* }}} */
     3593
    35493594/* {{{ PHP_INI */
    3550 
    3551 static PHP_INI_MH(xc_OnUpdateDummy)
    3552 {
    3553     return SUCCESS;
    3554 }
    3555 
    3556 static PHP_INI_MH(xc_OnUpdateULong)
    3557 {
    3558     zend_ulong *p = (zend_ulong *) mh_arg1;
    3559 
    3560     *p = (zend_ulong) atoi(new_value);
    3561     return SUCCESS;
    3562 }
    3563 
    3564 static PHP_INI_MH(xc_OnUpdateBool)
    3565 {
    3566     zend_bool *p = (zend_bool *)mh_arg1;
    3567 
    3568     if (strncasecmp("on", new_value, sizeof("on"))) {
    3569         *p = (zend_bool) atoi(new_value);
    3570     }
    3571     else {
    3572         *p = (zend_bool) 1;
    3573     }
    3574     return SUCCESS;
    3575 }
    3576 
    3577 static PHP_INI_MH(xc_OnUpdateString)
    3578 {
    3579     char **p = (char**)mh_arg1;
    3580     if (*p) {
    3581         pefree(*p, 1);
    3582     }
    3583     *p = pemalloc(strlen(new_value) + 1, 1);
    3584     strcpy(*p, new_value);
    3585     return SUCCESS;
    3586 }
    3587 
    3588 #ifndef ZEND_ENGINE_2
    3589 #define OnUpdateLong OnUpdateInt
    3590 #endif
    3591 
    35923595#ifdef ZEND_WIN32
    35933596#   define DEFAULT_PATH "xcache"
     
    35963599#endif
    35973600PHP_INI_BEGIN()
    3598     PHP_INI_ENTRY1     ("xcache.mmap_path",     DEFAULT_PATH, PHP_INI_SYSTEM, xc_OnUpdateString,   &xc_mmap_path)
    3599     PHP_INI_ENTRY1     ("xcache.coredump_directory",      "", PHP_INI_SYSTEM, xc_OnUpdateString,   &xc_coredump_dir)
    3600     PHP_INI_ENTRY1     ("xcache.disable_on_crash",       "0", PHP_INI_SYSTEM, xc_OnUpdateBool,     &xc_disable_on_crash)
    3601     PHP_INI_ENTRY1     ("xcache.test",                   "0", PHP_INI_SYSTEM, xc_OnUpdateBool,     &xc_test)
    3602     PHP_INI_ENTRY1     ("xcache.readonly_protection",    "0", PHP_INI_SYSTEM, xc_OnUpdateBool,     &xc_readonly_protection)
     3601    PHP_INI_ENTRY1     ("xcache.mmap_path",     DEFAULT_PATH, PHP_INI_SYSTEM, xcache_OnUpdateString,   &xc_mmap_path)
     3602    PHP_INI_ENTRY1     ("xcache.coredump_directory",      "", PHP_INI_SYSTEM, xcache_OnUpdateString,   &xc_coredump_dir)
     3603    PHP_INI_ENTRY1     ("xcache.disable_on_crash",       "0", PHP_INI_SYSTEM, xcache_OnUpdateBool,     &xc_disable_on_crash)
     3604    PHP_INI_ENTRY1     ("xcache.test",                   "0", PHP_INI_SYSTEM, xcache_OnUpdateBool,     &xc_test)
     3605    PHP_INI_ENTRY1     ("xcache.readonly_protection",    "0", PHP_INI_SYSTEM, xcache_OnUpdateBool,     &xc_readonly_protection)
    36033606    /* opcode cache */
    3604     PHP_INI_ENTRY1     ("xcache.size",                   "0", PHP_INI_SYSTEM, xc_OnUpdateDummy,    NULL)
    3605     PHP_INI_ENTRY1     ("xcache.count",                  "1", PHP_INI_SYSTEM, xc_OnUpdateDummy,    NULL)
    3606     PHP_INI_ENTRY1     ("xcache.slots",                 "8K", PHP_INI_SYSTEM, xc_OnUpdateDummy,    NULL)
    3607     PHP_INI_ENTRY1     ("xcache.shm_scheme",          "mmap", PHP_INI_SYSTEM, xc_OnUpdateString,   &xc_shm_scheme)
    3608     PHP_INI_ENTRY1     ("xcache.ttl",                    "0", PHP_INI_SYSTEM, xc_OnUpdateULong,    &xc_php_ttl)
    3609     PHP_INI_ENTRY1     ("xcache.gc_interval",            "0", PHP_INI_SYSTEM, xc_OnUpdateULong,    &xc_php_gc_interval)
     3607    PHP_INI_ENTRY1     ("xcache.size",                   "0", PHP_INI_SYSTEM, xcache_OnUpdateDummy,    NULL)
     3608    PHP_INI_ENTRY1     ("xcache.count",                  "1", PHP_INI_SYSTEM, xcache_OnUpdateDummy,    NULL)
     3609    PHP_INI_ENTRY1     ("xcache.slots",                 "8K", PHP_INI_SYSTEM, xcache_OnUpdateDummy,    NULL)
     3610    PHP_INI_ENTRY1     ("xcache.shm_scheme",          "mmap", PHP_INI_SYSTEM, xcache_OnUpdateString,   &xc_shm_scheme)
     3611    PHP_INI_ENTRY1     ("xcache.ttl",                    "0", PHP_INI_SYSTEM, xcache_OnUpdateULong,    &xc_php_ttl)
     3612    PHP_INI_ENTRY1     ("xcache.gc_interval",            "0", PHP_INI_SYSTEM, xcache_OnUpdateULong,    &xc_php_gc_interval)
    36103613    /* var cache */
    3611     PHP_INI_ENTRY1     ("xcache.var_size",               "0", PHP_INI_SYSTEM, xc_OnUpdateDummy,    NULL)
    3612     PHP_INI_ENTRY1     ("xcache.var_count",              "1", PHP_INI_SYSTEM, xc_OnUpdateDummy,    NULL)
    3613     PHP_INI_ENTRY1     ("xcache.var_slots",             "8K", PHP_INI_SYSTEM, xc_OnUpdateDummy,    NULL)
    3614     PHP_INI_ENTRY1     ("xcache.var_maxttl",             "0", PHP_INI_SYSTEM, xc_OnUpdateULong,    &xc_var_maxttl)
    3615     PHP_INI_ENTRY1     ("xcache.var_gc_interval",      "120", PHP_INI_SYSTEM, xc_OnUpdateULong,    &xc_var_gc_interval)
     3614    PHP_INI_ENTRY1     ("xcache.var_size",               "0", PHP_INI_SYSTEM, xcache_OnUpdateDummy,    NULL)
     3615    PHP_INI_ENTRY1     ("xcache.var_count",              "1", PHP_INI_SYSTEM, xcache_OnUpdateDummy,    NULL)
     3616    PHP_INI_ENTRY1     ("xcache.var_slots",             "8K", PHP_INI_SYSTEM, xcache_OnUpdateDummy,    NULL)
     3617    PHP_INI_ENTRY1     ("xcache.var_maxttl",             "0", PHP_INI_SYSTEM, xcache_OnUpdateULong,    &xc_var_maxttl)
     3618    PHP_INI_ENTRY1     ("xcache.var_gc_interval",      "120", PHP_INI_SYSTEM, xcache_OnUpdateULong,    &xc_var_gc_interval)
    36163619
    36173620    STD_PHP_INI_BOOLEAN("xcache.cacher",                 "1", PHP_INI_ALL,    OnUpdateBool,        cacher,            zend_xcache_globals, xcache_globals)
     
    36193622    STD_PHP_INI_BOOLEAN("xcache.admin.enable_auth",      "1", PHP_INI_SYSTEM, OnUpdateBool,        auth_enabled,      zend_xcache_globals, xcache_globals)
    36203623    STD_PHP_INI_BOOLEAN("xcache.experimental",           "0", PHP_INI_ALL,    OnUpdateBool,        experimental,      zend_xcache_globals, xcache_globals)
    3621 #ifdef HAVE_XCACHE_OPTIMIZER
    3622     STD_PHP_INI_BOOLEAN("xcache.optimizer",              "0", PHP_INI_ALL,    OnUpdateBool,        optimizer,         zend_xcache_globals, xcache_globals)
    3623 #endif
    36243624    STD_PHP_INI_ENTRY  ("xcache.var_ttl",                "0", PHP_INI_ALL,    OnUpdateLong,        var_ttl,           zend_xcache_globals, xcache_globals)
    3625 #ifdef HAVE_XCACHE_COVERAGER
    3626     STD_PHP_INI_BOOLEAN("xcache.coverager"      ,        "0", PHP_INI_ALL,    OnUpdateBool,        coverager,         zend_xcache_globals, xcache_globals)
    3627     PHP_INI_ENTRY1     ("xcache.coveragedump_directory",  "", PHP_INI_SYSTEM, xc_OnUpdateDummy,    NULL)
    3628 #endif
    36293625PHP_INI_END()
    36303626/* }}} */
    3631 /* {{{ PHP_MINFO_FUNCTION(xcache) */
    3632 static PHP_MINFO_FUNCTION(xcache)
     3627static PHP_MINFO_FUNCTION(xcache) /* {{{ */
    36333628{
    36343629    char buf[100];
     
    36363631    int left, len;
    36373632    xc_shm_scheme_t *scheme;
    3638 #ifdef HAVE_XCACHE_COVERAGER
    3639     char *covdumpdir;
    3640 #endif
    36413633
    36423634    php_info_print_table_start();
    3643     php_info_print_table_header(2, "XCache Support", "enabled");
    3644     php_info_print_table_row(2, "Version", XCACHE_VERSION);
     3635    php_info_print_table_row(2, "XCache Version", XCACHE_VERSION);
    36453636#ifdef XCACHE_VERSION_REVISION
    36463637    php_info_print_table_row(2, "Revision", "r" XCACHE_VERSION_REVISION);
    36473638#endif
    36483639    php_info_print_table_row(2, "Modules Built", XCACHE_MODULES);
    3649     php_info_print_table_row(2, "Readonly Protection", xc_readonly_protection ? "enabled" : "N/A");
     3640    php_info_print_table_row(2, "Readonly Protection", xc_readonly_protection ? "enabled" : "disabled");
    36503641#ifdef ZEND_ENGINE_2_1
    36513642    ptr = php_format_date("Y-m-d H:i:s", sizeof("Y-m-d H:i:s") - 1, xc_init_time, 1 TSRMLS_CC);
     
    36933684    php_info_print_table_row(2, "Shared Memory Schemes", buf);
    36943685
    3695 #ifdef HAVE_XCACHE_COVERAGER
    3696     if (cfg_get_string("xcache.coveragedump_directory", &covdumpdir) != SUCCESS || !covdumpdir[0]) {
    3697         covdumpdir = NULL;
    3698     }
    3699     php_info_print_table_row(2, "Coverage Auto Dumper", XG(coverager) && covdumpdir ? "enabled" : "disabled");
    3700 #endif
    37013686    php_info_print_table_end();
    37023687
    37033688    DISPLAY_INI_ENTRIES();
    3704 }
    3705 /* }}} */
    3706 /* {{{ extension startup */
    3707 static void xc_zend_extension_register(zend_extension *new_extension, DL_HANDLE handle)
    3708 {
    3709     zend_extension extension;
    3710 
    3711     extension = *new_extension;
    3712     extension.handle = handle;
    3713 
    3714     zend_extension_dispatch_message(ZEND_EXTMSG_NEW_EXTENSION, &extension);
    3715 
    3716     zend_llist_prepend_element(&zend_extensions, &extension);
    3717     TRACE("%s", "registered");
    3718 }
    3719 
    3720 static zend_llist_element *xc_llist_get_element_by_zend_extension(zend_llist *l, const char *extension_name)
    3721 {
    3722     zend_llist_element *element;
    3723 
    3724     for (element = zend_extensions.head; element; element = element->next) {
    3725         zend_extension *extension = (zend_extension *) element->data;
    3726 
    3727         if (!strcmp(extension->name, extension_name)) {
    3728             return element;
    3729         }
    3730     }
    3731     return NULL;
    3732 }
    3733 
    3734 static void xc_llist_prepend(zend_llist *l, zend_llist_element *element)
    3735 {
    3736     element->next = l->head;
    3737     element->prev = NULL;
    3738     if (l->head) {
    3739         l->head->prev = element;
    3740     }
    3741     else {
    3742         l->tail = element;
    3743     }
    3744     l->head = element;
    3745     ++l->count;
    3746 }
    3747 
    3748 static void xc_llist_unlink(zend_llist *l, zend_llist_element *element)
    3749 {
    3750     if ((element)->prev) {
    3751         (element)->prev->next = (element)->next;
    3752     }
    3753     else {
    3754         (l)->head = (element)->next;
    3755     }
    3756 
    3757     if ((element)->next) {
    3758         (element)->next->prev = (element)->prev;
    3759     }
    3760     else {
    3761         (l)->tail = (element)->prev;
    3762     }
    3763 
    3764     --l->count;
    3765 }
    3766 
    3767 static int xc_zend_extension_startup(zend_extension *extension)
    3768 {
    3769     if (extension->startup) {
    3770         if (extension->startup(extension) != SUCCESS) {
    3771             return FAILURE;
    3772         }
    3773     }
    3774     return SUCCESS;
    3775 }
    3776 /* }}} */
    3777 static int xc_ptr_compare_func(void *p1, void *p2) /* {{{ */
    3778 {
    3779     return p1 == p2;
    3780 }
    3781 /* }}} */
    3782 static int xc_zend_remove_extension(zend_extension *extension) /* {{{ */
    3783 {
    3784     llist_dtor_func_t dtor;
    3785 
    3786     assert(extension);
    3787     dtor = zend_extensions.dtor; /* avoid dtor */
    3788     zend_extensions.dtor = NULL;
    3789     zend_llist_del_element(&zend_extensions, extension, xc_ptr_compare_func);
    3790     zend_extensions.dtor = dtor;
    3791     return SUCCESS;
    37923689}
    37933690/* }}} */
     
    38243721}
    38253722/* }}} */
    3826 /* {{{ PHP_MINIT_FUNCTION(xcache) */
    3827 static PHP_MINIT_FUNCTION(xcache)
     3723static PHP_MINIT_FUNCTION(xcache) /* {{{ */
    38283724{
    38293725    char *env;
     
    38313727    zend_llist_position lpos;
    38323728
    3833     xc_module_gotup = 1;
    3834     if (!xc_zend_extension_gotup) {
    3835         zend_error(E_WARNING, "XCache is designed to be loaded as zend_extension not extension");
    3836         xc_zend_extension_register(&zend_extension_entry, 0);
    3837         xc_zend_extension_startup(&zend_extension_entry);
    3838         xc_zend_extension_faked = 1;
    3839     }
    3840 
     3729    xcache_zend_extension_register(&zend_extension_entry, 1);
    38413730    ext = zend_get_extension("Zend Optimizer");
    38423731    if (ext) {
     
    39183807    }
    39193808
     3809#ifdef HAVE_XCACHE_OPTIMIZER
     3810    xc_optimizer_startup_module();
     3811#endif
     3812#ifdef HAVE_XCACHE_COVERAGER
     3813    xc_coverager_startup_module();
     3814#endif
     3815#ifdef HAVE_XCACHE_DISASSEMBLER
     3816    xc_disassembler_startup_module();
     3817#endif
    39203818    xc_sandbox_module_init(module_number TSRMLS_CC);
    3921 #ifdef HAVE_XCACHE_COVERAGER
    3922     xc_coverager_module_init(module_number TSRMLS_CC);
    3923 #endif
    3924 
    39253819    return SUCCESS;
    39263820
     
    39323826static PHP_MSHUTDOWN_FUNCTION(xcache)
    39333827{
    3934 #ifdef HAVE_XCACHE_COVERAGER
    3935     xc_coverager_module_shutdown();
    3936 #endif
    39373828    xc_sandbox_module_shutdown();
    39383829
     
    39643855#endif
    39653856
    3966     if (xc_zend_extension_faked) {
    3967         zend_extension *ext = zend_get_extension(XCACHE_NAME);
    3968         if (ext) {
    3969             if (ext->shutdown) {
    3970                 ext->shutdown(ext);
    3971             }
    3972             xc_zend_remove_extension(ext);
    3973         }
    3974     }
     3857    xcache_zend_extension_unregister(&zend_extension_entry);
    39753858    UNREGISTER_INI_ENTRIES();
    3976 
    3977     xc_module_gotup = 0;
    3978     xc_zend_extension_gotup = 0;
    3979     xc_zend_extension_faked = 0;
    3980 
    39813859    return SUCCESS;
    39823860}
     
    40053883/* }}} */
    40063884/* {{{ module dependencies */
    4007 #if ZEND_MODULE_API_NO >= 20050922
     3885#ifdef STANDARD_MODULE_HEADER_EX
    40083886static zend_module_dep xcache_module_deps[] = {
    40093887    ZEND_MOD_REQUIRED("standard")
     
    40113889    ZEND_MOD_CONFLICTS("eAccelerator")
    40123890    ZEND_MOD_CONFLICTS("Turck MMCache")
    4013 #ifdef ZEND_MOD_END
    40143891    ZEND_MOD_END
    4015 #else
    4016     {NULL, NULL, NULL, 0}
    4017 #endif
    40183892};
    40193893#endif
    40203894/* }}} */
    40213895/* {{{ module definition structure */
    4022 
    40233896zend_module_entry xcache_module_entry = {
    4024 #if ZEND_MODULE_API_NO >= 20050922
     3897#ifdef STANDARD_MODULE_HEADER_EX
    40253898    STANDARD_MODULE_HEADER_EX,
    40263899    NULL,
     
    40593932#endif
    40603933/* }}} */
    4061 static startup_func_t xc_last_ext_startup;
    4062 static int xc_zend_startup_last(zend_extension *extension) /* {{{ */
    4063 {
    4064     zend_extension *ext = zend_get_extension(XCACHE_NAME);
    4065     if (ext) {
    4066         zend_error(E_WARNING, "Module '" XCACHE_NAME "' already loaded");
    4067     }
    4068     /* restore */
    4069     extension->startup = xc_last_ext_startup;
    4070     if (extension->startup) {
    4071         if (extension->startup(extension) != SUCCESS) {
    4072             return FAILURE;
    4073         }
    4074     }
    4075     assert(xc_llist_zend_extension);
    4076     xc_llist_prepend(&zend_extensions, xc_llist_zend_extension);
    4077     if (!xc_module_gotup) {
    4078         return zend_startup_module(&xcache_module_entry);
    4079     }
    4080     return SUCCESS;
    4081 }
    4082 /* }}} */
    4083 ZEND_DLEXPORT int xcache_zend_startup(zend_extension *extension) /* {{{ */
    4084 {
    4085     xc_zend_extension_gotup = 1;
    4086 
    4087     if (!origin_compile_file) {
    4088         origin_compile_file = zend_compile_file;
    4089         zend_compile_file = xc_check_initial_compile_file;
    4090     }
    4091 
    4092     if (zend_llist_count(&zend_extensions) > 1) {
    4093         zend_llist_position lpos;
    4094         zend_extension *ext;
    4095 
    4096         xc_llist_zend_extension = xc_llist_get_element_by_zend_extension(&zend_extensions, XCACHE_NAME);
    4097         if (xc_llist_zend_extension != zend_extensions.head) {
    4098             zend_error(E_WARNING, "XCache must be loaded as the first zend_extension for maximum compatibility");
    4099         }
    4100         /* hide myself */
    4101         xc_llist_unlink(&zend_extensions, xc_llist_zend_extension);
    4102 
    4103         ext = (zend_extension *) zend_llist_get_last_ex(&zend_extensions, &lpos);
    4104         assert(ext && ext != (zend_extension *) xc_llist_zend_extension->data);
    4105         xc_last_ext_startup = ext->startup;
    4106         ext->startup = xc_zend_startup_last;
    4107     }
    4108     else if (!xc_module_gotup) {
    4109         return zend_startup_module(&xcache_module_entry);
    4110     }
    4111     return SUCCESS;
    4112 }
    4113 /* }}} */
    4114 ZEND_DLEXPORT void xcache_zend_shutdown(zend_extension *extension) /* {{{ */
    4115 {
    4116     /* empty */
    4117 }
    4118 /* }}} */
    4119 ZEND_DLEXPORT void xcache_statement_handler(zend_op_array *op_array) /* {{{ */
    4120 {
    4121 #ifdef HAVE_XCACHE_COVERAGER
    4122     xc_coverager_handle_ext_stmt(op_array, ZEND_EXT_STMT);
    4123 #endif
    4124 }
    4125 /* }}} */
    4126 ZEND_DLEXPORT void xcache_fcall_begin_handler(zend_op_array *op_array) /* {{{ */
    4127 {
    4128 #if 0
    4129     xc_coverager_handle_ext_stmt(op_array, ZEND_EXT_FCALL_BEGIN);
    4130 #endif
    4131 }
    4132 /* }}} */
    4133 ZEND_DLEXPORT void xcache_fcall_end_handler(zend_op_array *op_array) /* {{{ */
    4134 {
    4135 #if 0
    4136     xc_coverager_handle_ext_stmt(op_array, ZEND_EXT_FCALL_END);
    4137 #endif
    4138 }
    4139 /* }}} */
    4140 /* {{{ zend extension definition structure */
    4141 ZEND_DLEXPORT zend_extension zend_extension_entry = {
    4142     XCACHE_NAME,
    4143     XCACHE_VERSION,
    4144     XCACHE_AUTHOR,
    4145     XCACHE_URL,
    4146     XCACHE_COPYRIGHT,
    4147     xcache_zend_startup,
    4148     xcache_zend_shutdown,
    4149     NULL,           /* activate_func_t */
    4150     NULL,           /* deactivate_func_t */
    4151     NULL,           /* message_handler_func_t */
    4152 #ifdef HAVE_XCACHE_OPTIMIZER
    4153     xc_optimizer_op_array_handler,
    4154 #else
    4155     NULL,           /* op_array_handler_func_t */
    4156 #endif
    4157     xcache_statement_handler,
    4158     xcache_fcall_begin_handler,
    4159     xcache_fcall_end_handler,
    4160     NULL,           /* op_array_ctor_func_t */
    4161     NULL,           /* op_array_dtor_func_t */
    4162     STANDARD_ZEND_EXTENSION_PROPERTIES
    4163 };
    4164 
    4165 #ifndef ZEND_EXT_API
    4166 #   define ZEND_EXT_API ZEND_DLEXPORT
    4167 #endif
    4168 #if COMPILE_DL_XCACHE
    4169 ZEND_EXTENSION();
    4170 #endif
    4171 /* }}} */
  • trunk/xcache.ini

    r979 r1026  
    11;; this is an example, it won't work unless properly configured into php.ini
    22[xcache-common]
    3 ;; WARNING: zend_extension* = *xcache* MUST be the first(above) of all zend_extension*=*
    4 ;; using extension=xcache.so is not recommended
    5 
    6 ;; non-windows example
    7 ;; update xxx accordingly
    8 zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so
    9 ;; windows example:
    10 zend_extension_ts = c:/php/extensions/php_xcache.dll
    11 ;; for newer PHP, _ts is removed, use the following line instead
    12 zend_extension = c:/php/extensions/php_xcache.dll
     3;; non-Windows example:
     4extension = xcache.so
     5;; Windows example:
     6; extension = php_xcache.dll
    137
    148[xcache.admin]
  • trunk/xcache/xc_compatibility.h

    r991 r1026  
    228228#endif
    229229
     230#ifndef ZEND_MOD_END
     231#   define ZEND_MOD_END {NULL, NULL, NULL, 0}
     232#endif
     233
     234#ifndef PHP_FE_END
     235#   define PHP_FE_END {NULL, NULL, NULL}
     236#endif
     237
    230238#endif /* XC_COMPATIBILITY_H_54F26ED90198353558718191D5EE244C */
  • trunk/xcache/xc_sandbox.h

    r1018 r1026  
    99 */
    1010
    11 #include "xcache.h"
    12 #include "xcache/xc_compatibility.h"
     11#include "xc_compatibility.h"
    1312
    1413int xc_sandbox_module_init(int module_number TSRMLS_DC);
Note: See TracChangeset for help on using the changeset viewer.