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.

109 lines
2.2 KiB

  1. #ifdef HAVE_XCACHE_TEST
  2. # define RELAYLINE_DC , int relayline
  3. # define RELAYLINE_CC , __LINE__
  4. #else
  5. # define RELAYLINE_DC
  6. # define RELAYLINE_CC
  7. #endif
  8. #ifdef HAVE_XCACHE_TEST
  9. # undef NDEBUG
  10. # include <assert.h>
  11. #endif
  12. #ifndef NDEBUG
  13. # undef inline
  14. #define inline
  15. #endif
  16. #ifdef NDEBUG
  17. #define notnullable(ptr) (ptr)
  18. #else
  19. static inline void *notnullable(const void *ptr)
  20. {
  21. assert(ptr);
  22. return (void *) ptr;
  23. }
  24. #endif
  25. #ifdef HAVE_XCACHE_DPRINT
  26. static void xc_dprint_indent(int indent) /* {{{ */
  27. {
  28. int i;
  29. for (i = 0; i < indent; i ++) {
  30. fprintf(stderr, " ");
  31. }
  32. }
  33. /* }}} */
  34. static void xc_dprint_str_len(const char *str, int len) /* {{{ */
  35. {
  36. const unsigned char *p = (const unsigned char *) str;
  37. int i;
  38. for (i = 0; i < len; i ++) {
  39. if (p[i] < 32 || p[i] == 127) {
  40. fprintf(stderr, "\\%03o", (unsigned int) p[i]);
  41. }
  42. else {
  43. fputc(p[i], stderr);
  44. }
  45. }
  46. }
  47. /* }}} */
  48. #endif
  49. #ifdef HAVE_XCACHE_TEST
  50. static int xc_check_names(const char *file, int line, const char *functionName, const char **assert_names, size_t assert_names_count, HashTable *done_names) /* {{{ field name checker */
  51. {
  52. int errors = 0;
  53. if (assert_names_count) {
  54. size_t i;
  55. Bucket *b;
  56. for (i = 0; i < assert_names_count; ++i) {
  57. if (!zend_u_hash_exists(done_names, IS_STRING, assert_names[i], (uint) strlen(assert_names[i]) + 1)) {
  58. fprintf(stderr
  59. , "Error: missing field at %s `#'%d %s`' : %s\n"
  60. , file, line, functionName
  61. , assert_names[i]
  62. );
  63. ++errors;
  64. }
  65. }
  66. for (b = done_names->pListHead; b != NULL; b = b->pListNext) {
  67. int known = 0;
  68. for (i = 0; i < assert_names_count; ++i) {
  69. if (strcmp(assert_names[i], BUCKET_KEY_S(b)) == 0) {
  70. known = 1;
  71. break;
  72. }
  73. }
  74. if (!known) {
  75. fprintf(stderr
  76. , "Error: unknown field at %s `#'%d %s`' : %s\n"
  77. , file, line, functionName
  78. , BUCKET_KEY_S(b)
  79. );
  80. ++errors;
  81. }
  82. }
  83. }
  84. return errors;
  85. }
  86. /* }}} */
  87. #endif
  88. #ifdef HAVE_XCACHE_TEST
  89. static void *xc_memsetptr(void *mem, void *content, size_t n) /* {{{ */
  90. {
  91. void **p = (void **) mem;
  92. void **end = (void **) ((char *) mem + n);
  93. while (p < end - sizeof(content)) {
  94. *p = content;
  95. p += sizeof(content);
  96. }
  97. if (p < end) {
  98. memset(p, -1, end - p);
  99. }
  100. return mem;
  101. }
  102. /* }}} */
  103. #endif