XCache is a fast, stable PHP opcode cacher that has been proven and is now running on production servers under high load. https://xcache.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.2 KiB

  1. dnl {{{ PROC_STRING_N_EX(1:dst, 2:src, 3:size, 4:name, 5:type=char)
  2. define(`PROC_STRING_N_EX', `
  3. pushdef(`STRTYPE', `ifelse(`$5',,`char',`$5')')
  4. pushdef(`PTRTYPE', ifelse(
  5. STRTYPE, `char', `char',
  6. STRTYPE, `zstr_char', `char',
  7. `', `', `UChar'))
  8. pushdef(`ISTYPE', ifelse(PTRTYPE,`UChar',IS_UNICODE,IS_STRING))
  9. pushdef(`UNI_STRLEN', ifelse(
  10. STRTYPE, `zstr_uchar', `xc_zstrlen_uchar',
  11. STRTYPE, `zstr_char', `xc_zstrlen_char',
  12. `', `', `strlen'))
  13. pushdef(`SRCSTR', ifelse(STRTYPE,`char',`ZSTR($2)',STRTYPE,`UChar',`ZSTR($2)',`$2'))
  14. pushdef(`SRCPTR', ifelse(
  15. STRTYPE, `zstr_uchar', `ZSTR_U($2)',
  16. STRTYPE, `zstr_char', `ZSTR_S($2)',
  17. `', `', `$2'))
  18. pushdef(`DSTPTR', ifelse(
  19. STRTYPE, `zstr_uchar', `ZSTR_U($1)',
  20. STRTYPE, `zstr_char', `ZSTR_S($1)',
  21. `', `', `$1'))
  22. pushdef(`STRDUP', ifelse(
  23. PTRTYPE, `char', `estrndup',
  24. PTRTYPE, `UChar', `eustrndup'))
  25. if (SRCPTR == NULL) {
  26. IFNOTMEMCPY(`IFCOPY(`
  27. DSTPTR = NULL;
  28. ')')
  29. IFDASM(`
  30. add_assoc_null_ex(dst, XCACHE_STRS("$4"));
  31. ')
  32. }
  33. else {
  34. IFDPRINT(`INDENT()
  35. ifelse(STRTYPE, `zstr_uchar', `
  36. #ifdef IS_UNICODE
  37. do {
  38. zval zv;
  39. zval reszv;
  40. int usecopy;
  41. INIT_ZVAL(zv);
  42. ZVAL_UNICODEL(&zv, ZSTR_U($2), $3 - 1, 1);
  43. zend_make_printable_zval(&zv, &reszv, &usecopy);
  44. fprintf(stderr, "string:%s:\t\"", "$1");
  45. xc_dprint_str_len(Z_STRVAL(reszv), Z_STRLEN(reszv));
  46. fprintf(stderr, "\" len=%lu\n", (unsigned long) $3 - 1);
  47. if (usecopy) {
  48. zval_dtor(&reszv);
  49. }
  50. zval_dtor(&zv);
  51. } while (0);
  52. #endif
  53. ', `
  54. fprintf(stderr, "string:%s:\t\"", "$1");
  55. xc_dprint_str_len(SRCPTR, $3 - 1);
  56. fprintf(stderr, "\" len=%lu\n", (unsigned long) $3 - 1);
  57. ')
  58. ')
  59. IFCALC(`xc_calc_string_n(processor, ISTYPE, SRCSTR, $3 C_RELAYLINE TSRMLS_CC);')
  60. IFSTORE(`DSTPTR = ifdef(`REALPTRTYPE', `(REALPTRTYPE() *)') ifelse(PTRTYPE,`char',`ZSTR_S',`ZSTR_U')(xc_store_string_n(processor, ISTYPE, SRCSTR, $3 C_RELAYLINE));')
  61. IFRESTORE(`
  62. DSTPTR = ifdef(`REALPTRTYPE', `(REALPTRTYPE() *)') STRDUP() (SRCPTR, ($3) - 1);
  63. ')
  64. RELOCATE_EX(ifdef(`REALPTRTYPE', `REALPTRTYPE()', `PTRTYPE'), DSTPTR)
  65. IFDASM(`
  66. ifelse(STRTYPE,zstr_uchar, `
  67. add_assoc_unicodel_ex(dst, XCACHE_STRS("$4"), ZSTR_U($2), $3-1, 1);
  68. ', ` dnl else
  69. ifelse(STRTYPE,zstr_char, `
  70. add_assoc_stringl_ex(dst, XCACHE_STRS("$4"), (char *) ZSTR_S($2), $3-1, 1);
  71. ', `
  72. add_assoc_stringl_ex(dst, XCACHE_STRS("$4"), (char *) $2, $3-1, 1);
  73. ')
  74. ')
  75. ')
  76. }
  77. popdef(`STRDUP')
  78. popdef(`DSTPTR')
  79. popdef(`SRCPTR')
  80. popdef(`SRCSTR')
  81. popdef(`UNI_STRLEN')
  82. popdef(`STRTYPE')
  83. popdef(`ISTYPE')
  84. ')
  85. dnl }}}
  86. dnl PROC_STRING_N(1:name, 2:size, 3:type)
  87. define(`PROC_STRING_N', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`DST(`$1')', `SRC(`$1')', `SRC(`$2')', `$1', `char')')
  88. define(`PROC_USTRING_N', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`DST(`$1')', `SRC(`$1')', `SRC(`$2')', `$1', `UChar')')
  89. define(`PROC_STRING_L', `DBG(`$0($*)') PROC_STRING_N(`$1', `$2 + 1')')
  90. define(`PROC_USTRING_L', `DBG(`$0($*)') PROC_USTRING_N(`$1', `$2 + 1')')
  91. define(`PROC_STRING', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`DST(`$1')', `SRC(`$1')', `strlen(SRC(`$1')) + 1', `$1', `char')')
  92. define(`PROC_USTRING', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`DST(`$1')', `SRC(`$1')', `strlen(SRC(`$1')) + 1', `$1', `UChar')')
  93. dnl {{{ PROC_ZSTRING_N(1:type, 2:name, 3:size, 4:size_type)
  94. define(`PROC_ZSTRING_N', `
  95. DBG(`$0($*)')
  96. #ifdef IS_UNICODE
  97. pushdef(`NSIZE', ifelse(
  98. `$4', `strlen', `UNI_STRLEN (SRC(`$2')) + 1',
  99. `$4', `len', `SRC(`$3') + 1',
  100. `', `', `SRC(`$3')',
  101. ))
  102. DONE(`$2')
  103. ifelse(`$1', `1', `PROC_STRING_N_EX(`DST(`$2')', `SRC(`$2')', defn(`NSIZE'), `$2', `zstr_uchar')
  104. ', `
  105. if (ifelse(`$1', `', `UG(unicode)', `SRC(`$1') == IS_UNICODE')) {
  106. PROC_STRING_N_EX(`DST(`$2')', `SRC(`$2')', defn(`NSIZE'), `$2', `zstr_uchar')
  107. }
  108. else {
  109. PROC_STRING_N_EX(`DST(`$2')', `SRC(`$2')', defn(`NSIZE'), `$2', `zstr_char')
  110. }
  111. ')
  112. #else
  113. DONE(`$2')
  114. PROC_STRING_N_EX(`DST(`$2')', `SRC(`$2')', NSIZE, `$2', `zstr_char')
  115. #endif
  116. popdef(`NSIZE')
  117. ')
  118. dnl }}}
  119. define(`PROC_ZSTRING_L', `DBG(`$0($*)') PROC_ZSTRING_N(`$1', `$2', `$3', `len')')
  120. define(`PROC_ZSTRING', `DBG(`$0($*)') PROC_ZSTRING_N(`$1', `$2', , `strlen')')