Changeset 1026
- Timestamp:
- 07/22/2012 08:26:35 AM (10 months ago)
- Location:
- trunk
- Files:
-
- 4 added
- 18 modified
-
ChangeLog (modified) (1 diff)
-
Makefile.frag.deps (modified) (1 diff)
-
NEWS (modified) (1 diff)
-
config.m4 (modified) (1 diff)
-
config.w32 (modified) (1 diff)
-
mod_cacher/htdocs/xcache.php (modified) (1 diff)
-
mod_coverager/xc_coverager.c (modified) (11 diffs)
-
mod_coverager/xc_coverager.h (modified) (1 diff)
-
mod_disassembler/xc_disassembler.c (modified) (2 diffs)
-
mod_disassembler/xc_disassembler.h (modified) (1 diff)
-
mod_optimizer/xc_optimizer.c (modified) (3 diffs)
-
mod_optimizer/xc_optimizer.h (modified) (1 diff)
-
xcache-test.ini (modified) (1 diff)
-
xcache-zh-gb2312.ini (modified) (1 diff)
-
xcache.c (modified) (22 diffs)
-
xcache.ini (modified) (1 diff)
-
xcache/xc_compatibility.h (modified) (1 diff)
-
xcache/xc_extension.c (added)
-
xcache/xc_extension.h (added)
-
xcache/xc_ini.c (added)
-
xcache/xc_ini.h (added)
-
xcache/xc_sandbox.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r979 r1026 14 14 * closes #73: warn for improper PHP_FCGI_CHILDREN setting fcgi mode (>=PHP_5_3) 15 15 * closes #174: updated api for clear all cache 16 * uses extension to load XCache. load via zend_extension is unsupported 16 17 17 18 2.0.1 2012-07-14 -
trunk/Makefile.frag.deps
r1018 r1026 1 1 $(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 2 2 $(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.h3 $(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 4 4 $(builddir)/mod_decoder/xc_decoder.lo: 5 5 $(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) 6 6 $(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.h7 $(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 8 8 $(builddir)/util/xc_stack.lo: $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_stack.h 9 9 $(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.h10 $(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 11 11 $(builddir)/xcache/xc_compatibility.lo: $(srcdir)/xcache/xc_compatibility.h 12 12 $(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 13 15 $(builddir)/xcache/xc_lock.lo: $(srcdir)/xcache/xc_lock.h 14 16 $(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 4 4 * adds warning for misconfiguration 5 5 * auto disable caching on crash 6 * uses extension to load XCache. load via zend_extension is unsupported 6 7 7 8 2.0.1 2012-07-14 -
trunk/config.m4
r1011 r1026 32 32 done 33 33 for i in \ 34 xc_compatibility.c \ 34 35 xc_const_string.c \ 35 xc_compatibility.c \ 36 xc_extension.c \ 37 xc_ini.c \ 36 38 xc_lock.c \ 37 39 xc_mem.c \ -
trunk/config.w32
r1011 r1026 19 19 20 20 ADD_SOURCES(configure_module_dirname + "/xcache", " \ 21 xc_compatibility.c \ 21 22 xc_const_string.c \ 22 xc_compatibility.c \ 23 xc_extension.c \ 24 xc_ini.c \ 23 25 xc_lock.c \ 24 26 xc_mem.c \ -
trunk/mod_cacher/htdocs/xcache.php
r976 r1026 355 355 phpinfo(INFO_MODULES); 356 356 $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]); 359 359 } 360 360 else { -
trunk/mod_coverager/xc_coverager.c
r1008 r1026 2 2 #define XCACHE_DEBUG 3 3 #endif 4 5 #include "xc_coverager.h" 4 6 5 7 #include <stdio.h> … … 13 15 #include <fcntl.h> 14 16 17 #include "xcache/xc_extension.h" 18 #include "xcache/xc_ini.h" 19 #include "xcache/xc_utils.h" 15 20 #include "util/xc_stack.h" 16 21 #include "util/xc_trace.h" 17 22 #include "xcache_globals.h" 18 #include "xc_coverager.h" 19 #include " xcache/xc_utils.h"23 24 #include "ext/standard/info.h" 20 25 21 26 typedef HashTable *coverager_t; … … 34 39 } 35 40 /* }}} */ 36 void xcache_mkdirs_ex(char *root, int rootlen, char *path, int pathlen TSRMLS_DC) /* {{{ */41 static void xcache_mkdirs_ex(char *root, int rootlen, char *path, int pathlen TSRMLS_DC) /* {{{ */ 37 42 { 38 43 char *fullpath; … … 248 253 /* }}} */ 249 254 250 void xc_coverager_request_init(TSRMLS_D) /* {{{ */255 static PHP_RINIT_FUNCTION(xcache_coverager) /* {{{ */ 251 256 { 252 257 if (XG(coverager)) { … … 261 266 XG(coverage_enabled) = 0; 262 267 } 268 return SUCCESS; 263 269 } 264 270 /* }}} */ … … 335 341 } 336 342 /* }}} */ 337 void xc_coverager_request_shutdown(TSRMLS_D) /* {{{ */343 static PHP_RSHUTDOWN_FUNCTION(xcache_coverager) /* {{{ */ 338 344 { 339 345 if (XG(coverager)) { … … 341 347 xc_coverager_cleanup(TSRMLS_C); 342 348 } 349 return SUCCESS; 343 350 } 344 351 /* }}} */ … … 457 464 458 465 /* hits */ 459 void xc_coverager_handle_ext_stmt(zend_op_array *op_array, zend_uchar op) /* {{{ */466 static void xc_coverager_handle_ext_stmt(zend_op_array *op_array, zend_uchar op) /* {{{ */ 460 467 { 461 468 TSRMLS_FETCH(); … … 471 478 /* }}} */ 472 479 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 */ 484 PHP_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 */ 514 PHP_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 */ 537 PHP_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 */ 554 PHP_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 /* }}} */ 567 static 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 577 static int xc_zend_startup(zend_extension *extension) /* {{{ */ 578 { 579 return SUCCESS; 580 } 581 /* }}} */ 582 static void xc_zend_shutdown(zend_extension *extension) /* {{{ */ 583 { 584 /* empty */ 585 } 586 /* }}} */ 587 static 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 /* }}} */ 594 static 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 /* }}} */ 601 static 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 */ 609 static 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 */ 630 PHP_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) 633 PHP_INI_END() 634 /* }}} */ 635 static 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 /* }}} */ 650 static PHP_MINIT_FUNCTION(xcache_coverager) /* {{{ */ 475 651 { 476 652 old_compile_file = zend_compile_file; 477 653 zend_compile_file = xc_compile_file_for_coverage; 654 655 REGISTER_INI_ENTRIES(); 478 656 479 657 if (cfg_get_string("xcache.coveragedump_directory", &xc_coveragedump_dir) == SUCCESS && xc_coveragedump_dir) { … … 492 670 } 493 671 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 /* }}} */ 675 static PHP_MSHUTDOWN_FUNCTION(xcache_coverager) /* {{{ */ 498 676 { 499 677 if (old_compile_file == xc_compile_file_for_coverage) { … … 504 682 xc_coveragedump_dir = NULL; 505 683 } 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 689 static 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 /* }}} */ 711 int 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 1 8 #include "php.h" 2 #include "xcache.h"3 9 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) 10 int xc_coverager_startup_module(); 11 12 #endif /* XC_COVERAGER_H_D5BB29AAB992B932E91C70A8C2F5D2B1 */ -
trunk/mod_disassembler/xc_disassembler.c
r1003 r1026 3 3 #include "xcache/xc_utils.h" 4 4 #include "xcache/xc_sandbox.h" 5 #include "xcache/xc_compatibility.h" 5 6 #include "xc_processor.h" 7 8 #include "ext/standard/info.h" 6 9 7 10 static void xc_dasm(zval *output, zend_op_array *op_array TSRMLS_DC) /* {{{ */ … … 216 219 } 217 220 /* }}} */ 221 222 /* {{{ PHP_MINFO_FUNCTION(xcache_disassembler) */ 223 static 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 /* }}} */ 232 static 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 /* }}} */ 239 static 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 /* }}} */ 261 int 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 2 3 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 8 int xc_disassembler_startup_module(); 9 10 #endif /* XC_DISASSEMBLER_H_1547840703D7ADD9C19041818BE9E3C7 */ -
trunk/mod_optimizer/xc_optimizer.c
r1008 r1026 3 3 #endif 4 4 5 #include "xc_optimizer.h" 6 #include "xcache/xc_extension.h" 7 #include "xcache/xc_ini.h" 5 8 #include "xcache/xc_utils.h" 6 #include "xc_optimizer.h"7 /* the "vector" stack */8 9 #include "util/xc_stack.h" 9 10 #include "util/xc_trace.h" 10 11 #include "xcache_globals.h" 12 13 #include "ext/standard/info.h" 11 14 12 15 #ifdef XCACHE_DEBUG … … 607 610 } 608 611 /* }}} */ 609 void xc_optimizer_op_array_handler(zend_op_array *op_array) /* {{{ */612 static void xc_optimizer_op_array_handler(zend_op_array *op_array) /* {{{ */ 610 613 { 611 614 TSRMLS_FETCH(); … … 615 618 } 616 619 /* }}} */ 620 621 static int xc_zend_startup(zend_extension *extension) /* {{{ */ 622 { 623 return SUCCESS; 624 } 625 /* }}} */ 626 static void xc_zend_shutdown(zend_extension *extension) /* {{{ */ 627 { 628 } 629 /* }}} */ 630 /* {{{ zend extension definition structure */ 631 static 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 */ 653 PHP_INI_BEGIN() 654 STD_PHP_INI_BOOLEAN("xcache.optimizer", "0", PHP_INI_ALL, OnUpdateBool, optimizer, zend_xcache_globals, xcache_globals) 655 PHP_INI_END() 656 /* }}} */ 657 static 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 /* }}} */ 666 static PHP_MINIT_FUNCTION(xcache_optimizer) /* {{{ */ 667 { 668 REGISTER_INI_ENTRIES(); 669 return xcache_zend_extension_register(&xc_optimizer_zend_extension_entry, 0); 670 } 671 /* }}} */ 672 static PHP_MSHUTDOWN_FUNCTION(xcache_optimizer) /* {{{ */ 673 { 674 UNREGISTER_INI_ENTRIES(); 675 return xcache_zend_extension_unregister(&xc_optimizer_zend_extension_entry); 676 } 677 /* }}} */ 678 static 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 /* }}} */ 700 int 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 1 8 #include "php.h" 2 #include "xcache.h"3 9 4 void xc_optimizer_op_array_handler(zend_op_array *op_array); 5 #define XCACHE_OPTIMIZER_FUNCTIONS() 10 int xc_optimizer_startup_module(); 11 12 #endif /* XC_OPTIMIZER_H_6614228F428A266C39CDAC30269D9857 */ -
trunk/xcache-test.ini
r870 r1026 3 3 4 4 [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 5 extension_dir="./modules/" 6 extension=xcache.so 9 7 xcache.cacher = On 10 8 xcache.test = 1 -
trunk/xcache-zh-gb2312.ini
r927 r1026 1 1 ;; ���ļ�ֻ������, ���� php.ini �������Ա���Ч 2 2 [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 ����: 4 extension = xcache.so 10 5 ;; 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 14 7 15 8 [xcache.admin] -
trunk/xcache.c
r1003 r1026 15 15 #include <signal.h> 16 16 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 25 17 #include "xcache.h" 26 18 #ifdef ZEND_ENGINE_2_1 … … 30 22 #ifdef HAVE_XCACHE_OPTIMIZER 31 23 # include "mod_optimizer/xc_optimizer.h" 32 #else33 # define XCACHE_OPTIMIZER_FUNCTIONS()34 24 #endif 35 25 #ifdef HAVE_XCACHE_COVERAGER 36 26 # include "mod_coverager/xc_coverager.h" 37 #else38 # define XCACHE_COVERAGER_FUNCTIONS()39 27 #endif 40 28 #ifdef HAVE_XCACHE_DISASSEMBLER 41 29 # include "mod_disassembler/xc_disassembler.h" 42 #else43 # define XCACHE_DISASSEMBLER_FUNCTIONS()44 30 #endif 45 31 46 32 #include "xcache_globals.h" 47 33 #include "xc_processor.h" 34 #include "xcache/xc_extension.h" 35 #include "xcache/xc_ini.h" 48 36 #include "xcache/xc_const_string.h" 49 37 #include "xcache/xc_opcode_spec.h" … … 54 42 #include "util/xc_vector.h" 55 43 #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" 56 51 57 52 #define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > (pentry)->ctime + (time_t) (pentry)->ttl) … … 124 119 zend_bool xc_have_op_array_ctor = 0; 125 120 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_XCACHE130 # define zend_extension_entry xcache_zend_extension_entry131 #endif132 ZEND_DLEXPORT zend_extension zend_extension_entry;133 121 ZEND_DECLARE_MODULE_GLOBALS(xcache) 134 122 … … 2527 2515 XG(request_time) = sapi_get_request_time(TSRMLS_C); 2528 2516 #endif 2529 2530 #ifdef HAVE_XCACHE_COVERAGER2531 xc_coverager_request_init(TSRMLS_C);2532 #endif2533 2517 } 2534 2518 /* }}} */ … … 2543 2527 #ifdef ZEND_ENGINE_2 2544 2528 zend_llist_destroy(&XG(gc_op_arrays)); 2545 #endif2546 #ifdef HAVE_XCACHE_COVERAGER2547 xc_coverager_request_shutdown(TSRMLS_C);2548 2529 #endif 2549 2530 } … … 3359 3340 PHP_FE(xcache_clear_cache, NULL) 3360 3341 PHP_FE(xcache_coredump, NULL) 3361 XCACHE_OPTIMIZER_FUNCTIONS()3362 3342 #ifdef HAVE_XCACHE_ASSEMBLER 3363 3343 PHP_FE(xcache_asm, NULL) 3364 3344 #endif 3365 XCACHE_DISASSEMBLER_FUNCTIONS()3366 3345 #ifdef HAVE_XCACHE_ENCODER 3367 3346 PHP_FE(xcache_encode, NULL) … … 3371 3350 PHP_FE(xcache_decode_string, NULL) 3372 3351 #endif 3373 XCACHE_COVERAGER_FUNCTIONS()3374 3352 PHP_FE(xcache_get_special_value, NULL) 3375 3353 PHP_FE(xcache_get_type, NULL) … … 3391 3369 PHP_FE(xcache_dprint, NULL) 3392 3370 #endif 3393 #ifdef PHP_FE_END3394 3371 PHP_FE_END 3395 #else3396 {NULL, NULL, NULL}3397 #endif3398 3372 }; 3399 3373 /* }}} */ … … 3547 3521 #endif 3548 3522 3523 static startup_func_t xc_last_ext_startup; 3524 static 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 /* }}} */ 3542 static 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 /* }}} */ 3568 static void xc_zend_shutdown(zend_extension *extension) /* {{{ */ 3569 { 3570 } 3571 /* }}} */ 3572 /* {{{ zend extension definition structure */ 3573 static 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 3549 3594 /* {{{ 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_23589 #define OnUpdateLong OnUpdateInt3590 #endif3591 3592 3595 #ifdef ZEND_WIN32 3593 3596 # define DEFAULT_PATH "xcache" … … 3596 3599 #endif 3597 3600 PHP_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) 3603 3606 /* 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) 3610 3613 /* 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) 3616 3619 3617 3620 STD_PHP_INI_BOOLEAN("xcache.cacher", "1", PHP_INI_ALL, OnUpdateBool, cacher, zend_xcache_globals, xcache_globals) … … 3619 3622 STD_PHP_INI_BOOLEAN("xcache.admin.enable_auth", "1", PHP_INI_SYSTEM, OnUpdateBool, auth_enabled, zend_xcache_globals, xcache_globals) 3620 3623 STD_PHP_INI_BOOLEAN("xcache.experimental", "0", PHP_INI_ALL, OnUpdateBool, experimental, zend_xcache_globals, xcache_globals) 3621 #ifdef HAVE_XCACHE_OPTIMIZER3622 STD_PHP_INI_BOOLEAN("xcache.optimizer", "0", PHP_INI_ALL, OnUpdateBool, optimizer, zend_xcache_globals, xcache_globals)3623 #endif3624 3624 STD_PHP_INI_ENTRY ("xcache.var_ttl", "0", PHP_INI_ALL, OnUpdateLong, var_ttl, zend_xcache_globals, xcache_globals) 3625 #ifdef HAVE_XCACHE_COVERAGER3626 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 #endif3629 3625 PHP_INI_END() 3630 3626 /* }}} */ 3631 /* {{{ PHP_MINFO_FUNCTION(xcache) */ 3632 static PHP_MINFO_FUNCTION(xcache) 3627 static PHP_MINFO_FUNCTION(xcache) /* {{{ */ 3633 3628 { 3634 3629 char buf[100]; … … 3636 3631 int left, len; 3637 3632 xc_shm_scheme_t *scheme; 3638 #ifdef HAVE_XCACHE_COVERAGER3639 char *covdumpdir;3640 #endif3641 3633 3642 3634 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); 3645 3636 #ifdef XCACHE_VERSION_REVISION 3646 3637 php_info_print_table_row(2, "Revision", "r" XCACHE_VERSION_REVISION); 3647 3638 #endif 3648 3639 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"); 3650 3641 #ifdef ZEND_ENGINE_2_1 3651 3642 ptr = php_format_date("Y-m-d H:i:s", sizeof("Y-m-d H:i:s") - 1, xc_init_time, 1 TSRMLS_CC); … … 3693 3684 php_info_print_table_row(2, "Shared Memory Schemes", buf); 3694 3685 3695 #ifdef HAVE_XCACHE_COVERAGER3696 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 #endif3701 3686 php_info_print_table_end(); 3702 3687 3703 3688 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;3792 3689 } 3793 3690 /* }}} */ … … 3824 3721 } 3825 3722 /* }}} */ 3826 /* {{{ PHP_MINIT_FUNCTION(xcache) */ 3827 static PHP_MINIT_FUNCTION(xcache) 3723 static PHP_MINIT_FUNCTION(xcache) /* {{{ */ 3828 3724 { 3829 3725 char *env; … … 3831 3727 zend_llist_position lpos; 3832 3728 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); 3841 3730 ext = zend_get_extension("Zend Optimizer"); 3842 3731 if (ext) { … … 3918 3807 } 3919 3808 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 3920 3818 xc_sandbox_module_init(module_number TSRMLS_CC); 3921 #ifdef HAVE_XCACHE_COVERAGER3922 xc_coverager_module_init(module_number TSRMLS_CC);3923 #endif3924 3925 3819 return SUCCESS; 3926 3820 … … 3932 3826 static PHP_MSHUTDOWN_FUNCTION(xcache) 3933 3827 { 3934 #ifdef HAVE_XCACHE_COVERAGER3935 xc_coverager_module_shutdown();3936 #endif3937 3828 xc_sandbox_module_shutdown(); 3938 3829 … … 3964 3855 #endif 3965 3856 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); 3975 3858 UNREGISTER_INI_ENTRIES(); 3976 3977 xc_module_gotup = 0;3978 xc_zend_extension_gotup = 0;3979 xc_zend_extension_faked = 0;3980 3981 3859 return SUCCESS; 3982 3860 } … … 4005 3883 /* }}} */ 4006 3884 /* {{{ module dependencies */ 4007 #if ZEND_MODULE_API_NO >= 200509223885 #ifdef STANDARD_MODULE_HEADER_EX 4008 3886 static zend_module_dep xcache_module_deps[] = { 4009 3887 ZEND_MOD_REQUIRED("standard") … … 4011 3889 ZEND_MOD_CONFLICTS("eAccelerator") 4012 3890 ZEND_MOD_CONFLICTS("Turck MMCache") 4013 #ifdef ZEND_MOD_END4014 3891 ZEND_MOD_END 4015 #else4016 {NULL, NULL, NULL, 0}4017 #endif4018 3892 }; 4019 3893 #endif 4020 3894 /* }}} */ 4021 3895 /* {{{ module definition structure */ 4022 4023 3896 zend_module_entry xcache_module_entry = { 4024 #if ZEND_MODULE_API_NO >= 200509223897 #ifdef STANDARD_MODULE_HEADER_EX 4025 3898 STANDARD_MODULE_HEADER_EX, 4026 3899 NULL, … … 4059 3932 #endif 4060 3933 /* }}} */ 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_COVERAGER4122 xc_coverager_handle_ext_stmt(op_array, ZEND_EXT_STMT);4123 #endif4124 }4125 /* }}} */4126 ZEND_DLEXPORT void xcache_fcall_begin_handler(zend_op_array *op_array) /* {{{ */4127 {4128 #if 04129 xc_coverager_handle_ext_stmt(op_array, ZEND_EXT_FCALL_BEGIN);4130 #endif4131 }4132 /* }}} */4133 ZEND_DLEXPORT void xcache_fcall_end_handler(zend_op_array *op_array) /* {{{ */4134 {4135 #if 04136 xc_coverager_handle_ext_stmt(op_array, ZEND_EXT_FCALL_END);4137 #endif4138 }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_OPTIMIZER4153 xc_optimizer_op_array_handler,4154 #else4155 NULL, /* op_array_handler_func_t */4156 #endif4157 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_PROPERTIES4163 };4164 4165 #ifndef ZEND_EXT_API4166 # define ZEND_EXT_API ZEND_DLEXPORT4167 #endif4168 #if COMPILE_DL_XCACHE4169 ZEND_EXTENSION();4170 #endif4171 /* }}} */ -
trunk/xcache.ini
r979 r1026 1 1 ;; this is an example, it won't work unless properly configured into php.ini 2 2 [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: 4 extension = xcache.so 5 ;; Windows example: 6 ; extension = php_xcache.dll 13 7 14 8 [xcache.admin] -
trunk/xcache/xc_compatibility.h
r991 r1026 228 228 #endif 229 229 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 230 238 #endif /* XC_COMPATIBILITY_H_54F26ED90198353558718191D5EE244C */ -
trunk/xcache/xc_sandbox.h
r1018 r1026 9 9 */ 10 10 11 #include "xcache.h" 12 #include "xcache/xc_compatibility.h" 11 #include "xc_compatibility.h" 13 12 14 13 int xc_sandbox_module_init(int module_number TSRMLS_DC);

