Changeset 7
- Timestamp:
- 07/22/04 17:27:16 (9 years ago)
- Files:
-
- trunk/config.m4 (modified) (1 diff)
- trunk/fastxsl.c (modified) (26 diffs)
- trunk/php_fastxsl.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/config.m4
r1 r7 26 26 PHP_ADD_INCLUDE($FASTXSL_DIR/include/libxml2) 27 27 PHP_ADD_INCLUDE($FASTXSL_DIR/include) 28 29 PHP_ADD_LIBRARY_WITH_PATH(mm, $FASTXSL_DIR/lib, FASTXSL_SHARED_LIBADD) 28 AC_MSG_CHECKING(whether to support libmm based shared template cache) 29 AC_ARG_ENABLE(libmm, 30 [ --enable-libmm Enable libmm based shared template cache],[ 31 if test "$enableval" = "yes" ; then 32 AC_DEFINE(FASTXSL_MM, 1, [ ]) 33 AC_MSG_RESULT(yes) 34 PHP_ADD_LIBRARY_WITH_PATH(mm, $FASTXSL_DIR/lib, FASTXSL_SHARED_LIBADD) 35 else 36 AC_MSG_RESULT(no) 37 fi 38 ],[ 39 AC_MSG_RESULT(no) 40 ]) 30 41 PHP_ADD_LIBRARY_WITH_PATH(xslt, $FASTXSL_DIR/lib, FASTXSL_SHARED_LIBADD) 31 42 PHP_ADD_LIBRARY_WITH_PATH(xml2, $FASTXSL_DIR/lib, FASTXSL_SHARED_LIBADD) trunk/fastxsl.c
r6 r7 29 29 #include <libxml/xinclude.h> 30 30 #include <libxml/catalog.h> 31 #include <libxml/xpathInternals.h> 32 #include <libxml/xpath.h> 31 33 #include <libxslt/xslt.h> 32 34 #include <libxslt/xsltInternals.h> … … 34 36 #include <libxslt/xsltutils.h> 35 37 38 #ifdef FASTXSL_MM 36 39 #include <mm.h> 40 #endif 37 41 #include <sys/types.h> 38 42 #include <unistd.h> … … 60 64 61 65 if (shared) { 66 #ifdef FASTXSL_MM 62 67 if (shared == FASTXSL_SHARED_ALLOC) { 63 68 wrapper = (php_ss_wrapper *) mm_calloc(FASTXSL_G(cache)->mm, 1, sizeof(php_ss_wrapper)); … … 66 71 } 67 72 wrapper->persistant = 1; 73 #else 74 wrapper = (php_ss_wrapper *) calloc(1, sizeof(php_ss_wrapper)); 75 wrapper->persistant = 1; 76 #endif 68 77 } else { 69 78 wrapper = (php_ss_wrapper *) calloc(1, sizeof(php_ss_wrapper)); … … 87 96 static xmlStrdupFunc strdup_ptr; 88 97 98 #ifdef FASTXSL_MM 89 99 static void 90 100 ShmCache_Free(void *ptr) … … 162 172 return newstring; 163 173 } 174 #endif 164 175 165 176 static void … … 187 198 } 188 199 200 #ifdef FASTXSL_MM 189 201 static void 190 202 ShmCache_UseAllocationFunctions(void) … … 192 204 xmlMemSetup(ShmCache_Free, ShmCache_Malloc, ShmCache_Realloc, ShmCache_Strdup); 193 205 } 206 #endif 194 207 195 208 static void … … 205 218 } 206 219 220 #ifdef FASTXSL_MM 207 221 static php_ss_wrapper * 208 222 ShmCache_Stylesheet_ParseAndStore(char *filename, size_t filename_len, int mtime TSRMLS_DC) … … 250 264 } 251 265 } 266 #endif 252 267 253 268 static php_ss_wrapper * … … 256 271 php_ss_wrapper *wrapper; 257 272 258 wrapper = SS_Wrapper_Alloc(FASTXSL_PRM_ALLOC TSRMLS_CC);273 wrapper = (php_ss_wrapper *) SS_Wrapper_Alloc(FASTXSL_PRM_ALLOC TSRMLS_CC); 259 274 260 275 wrapper->ss = xsltParseStylesheetFile(filename); … … 305 320 /* {{{ proto array fastxsl_shmcache_getstatistics(void) 306 321 Get an array of statistics regarding the documents in the shared memory cache */ 322 #ifdef FASTXSL_MM 307 323 PHP_FUNCTION(fastxsl_shmcache_getstatistics) 308 324 { … … 347 363 mm_unlock(FASTXSL_G(cache)->mm); 348 364 } 365 #endif 349 366 /* }}} */ 350 367 … … 362 379 } 363 380 364 wrapper = SS_Wrapper_Alloc(0 TSRMLS_CC);381 wrapper = (php_ss_wrapper *) SS_Wrapper_Alloc(0 TSRMLS_CC); 365 382 wrapper->ss = xsltParseStylesheetFile((const xmlChar *) filename); 366 383 if (!wrapper->ss) { … … 467 484 /* {{{ proto resource fastxsl_shmcache_transform(string filename, resource xmldoc[, array parameters]) 468 485 Transform a XML document, "xmldoc", by a XSL stylesheet "filename" with transform "parameters." */ 486 #ifdef FASTXSL_MM 469 487 PHP_FUNCTION(fastxsl_shmcache_transform) 470 488 { … … 543 561 ZEND_REGISTER_RESOURCE(return_value, result_wrapper, le_fastxsl_document); 544 562 } 563 #endif 545 564 /* }}} */ 546 565 … … 749 768 /* {{{ proto string fastxsl_shmcache_tostring(string filename, resource xmldoc) 750 769 Return the string representation of xmldoc which is the result of an XSLT transformation on filename */ 770 #ifdef FASTXSL_MM 751 771 PHP_FUNCTION(fastxsl_shmcache_tostring) 752 772 { … … 781 801 } 782 802 } 803 #endif 783 804 /* }}} */ 784 805 … … 821 842 PHP_FE(fastxsl_xml_parsefile, NULL) 822 843 PHP_FE(fastxsl_xml_parsestring, NULL) 844 #ifdef FASTXSL_MM 823 845 PHP_FE(fastxsl_shmcache_transform, NULL) 846 PHP_FE(fastxsl_shmcache_tostring, NULL) 847 PHP_FE(fastxsl_shmcache_getstatistics, NULL) 848 #endif 824 849 PHP_FE(fastxsl_prmcache_transform, NULL) 825 850 PHP_FE(fastxsl_nocache_transform, NULL) 826 851 PHP_FE(fastxsl_nocache_profile, NULL) 827 852 PHP_FE(fastxsl_nocache_tostring, NULL) 828 PHP_FE(fastxsl_shmcache_tostring, NULL)829 853 PHP_FE(fastxsl_prmcache_tostring, NULL) 830 PHP_FE(fastxsl_shmcache_getstatistics, NULL)831 854 PHP_FE(fastxsl_prmcache_getstatistics, NULL) 832 855 {NULL, NULL, NULL} … … 915 938 * Allocators for the fl_hash storage 916 939 */ 940 #ifdef FASTXSL_MM 917 941 static FL_Allocator mm_allocators = {ShmCache_Free, ShmCache_Malloc, ShmCache_Calloc}; 942 #endif 918 943 static FL_Allocator normal_allocators = {free, malloc, calloc}; 919 944 … … 937 962 return; 938 963 } 939 964 #ifdef FASTXSL_MM 940 965 mm_lock(cache->mm, MM_LOCK_RW); 941 966 fl_hash_free(cache->table); … … 943 968 944 969 mm_destroy(cache->mm); 945 970 #endif 946 971 fl_hash_free(cache->prmtable); 947 972 } … … 962 987 int i; 963 988 964 tctxt = xsltXPathGetTransformContext(ctxt);989 tctxt = (xsltTransformContextPtr) xsltXPathGetTransformContext(ctxt); 965 990 if (tctxt == NULL) { 966 991 xsltGenericError(xsltGenericErrorContext, … … 1075 1100 1076 1101 le_fastxsl_stylesheet = zend_register_list_destructors_ex(SS_Wrapper_Dtor, NULL, 1077 le_fastxsl_stylesheet_name, module_number);1102 le_fastxsl_stylesheet_name, module_number); 1078 1103 le_fastxsl_document = zend_register_list_destructors_ex(XD_Wrapper_Dtor, NULL, 1079 1104 le_fastxsl_document_name, module_number); … … 1087 1112 Stream_XmlWrite_WriteWrapper, Stream_CloseWrapper); 1088 1113 1089 1114 #ifdef FASTXSL_MM 1090 1115 if (!sprintf(euid, "%d", geteuid())) { 1091 1116 return FAILURE; … … 1109 1134 FASTXSL_G(cache)->table = fl_hash_new(&mm_allocators, NULL); 1110 1135 mm_unlock(FASTXSL_G(cache)->mm); 1136 #endif 1111 1137 FASTXSL_G(cache)->prmtable = fl_hash_new(&normal_allocators, NULL); 1112 1138 trunk/php_fastxsl.h
r6 r7 35 35 #include <libxslt/xsltutils.h> 36 36 37 #ifdef FASTXSL_MM 37 38 #include <mm.h> 39 #endif 40 38 41 #include <sys/types.h> 39 42 #include <unistd.h> … … 59 62 60 63 typedef struct { 64 #ifdef FASTXSL_MM 61 65 MM *mm; 66 #endif 62 67 FL_Hash *table; 63 68 pid_t owner;
