php_reentrancy.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Author: Sascha Schumann <sascha@schumann.cx> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef PHP_REENTRANCY_H
  17. #define PHP_REENTRANCY_H
  18. #include "php.h"
  19. #include <sys/types.h>
  20. #ifdef HAVE_DIRENT_H
  21. #include <dirent.h>
  22. #endif
  23. #include <time.h>
  24. /* currently, PHP does not check for these functions, but assumes
  25. that they are available on all systems. */
  26. #define HAVE_LOCALTIME 1
  27. #define HAVE_GMTIME 1
  28. #define HAVE_ASCTIME 1
  29. #define HAVE_CTIME 1
  30. #if defined(PHP_IRIX_TIME_R)
  31. #undef HAVE_ASCTIME_R
  32. #undef HAVE_CTIME_R
  33. #endif
  34. #if defined(PHP_HPUX_TIME_R)
  35. #undef HAVE_LOCALTIME_R
  36. #undef HAVE_ASCTIME_R
  37. #undef HAVE_CTIME_R
  38. #undef HAVE_GMTIME_R
  39. #endif
  40. BEGIN_EXTERN_C()
  41. #if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME)
  42. #define PHP_NEED_REENTRANCY 1
  43. PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm);
  44. #else
  45. #define php_localtime_r localtime_r
  46. #ifdef MISSING_LOCALTIME_R_DECL
  47. struct tm *localtime_r(const time_t *const timep, struct tm *p_tm);
  48. #endif
  49. #endif
  50. #if !defined(HAVE_CTIME_R) && defined(HAVE_CTIME)
  51. #define PHP_NEED_REENTRANCY 1
  52. PHPAPI char *php_ctime_r(const time_t *clock, char *buf);
  53. #else
  54. #define php_ctime_r ctime_r
  55. #ifdef MISSING_CTIME_R_DECL
  56. char *ctime_r(const time_t *clock, char *buf);
  57. #endif
  58. #endif
  59. #if !defined(HAVE_ASCTIME_R) && defined(HAVE_ASCTIME)
  60. #define PHP_NEED_REENTRANCY 1
  61. PHPAPI char *php_asctime_r(const struct tm *tm, char *buf);
  62. #else
  63. #define php_asctime_r asctime_r
  64. #ifdef MISSING_ASCTIME_R_DECL
  65. char *asctime_r(const struct tm *tm, char *buf);
  66. #endif
  67. #endif
  68. #if !defined(HAVE_GMTIME_R) && defined(HAVE_GMTIME)
  69. #define PHP_NEED_REENTRANCY 1
  70. PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
  71. #else
  72. #define php_gmtime_r gmtime_r
  73. #ifdef MISSING_GMTIME_R_DECL
  74. struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
  75. #endif
  76. #endif
  77. #if !defined(HAVE_STRTOK_R)
  78. PHPAPI char *php_strtok_r(char *s, const char *delim, char **last);
  79. #else
  80. #define php_strtok_r strtok_r
  81. #ifdef MISSING_STRTOK_R_DECL
  82. char *strtok_r(char *s, const char *delim, char **last);
  83. #endif
  84. #endif
  85. END_EXTERN_C()
  86. #if !defined(ZTS)
  87. #undef PHP_NEED_REENTRANCY
  88. #endif
  89. #if defined(PHP_NEED_REENTRANCY)
  90. void reentrancy_startup(void);
  91. void reentrancy_shutdown(void);
  92. #else
  93. #define reentrancy_startup()
  94. #define reentrancy_shutdown()
  95. #endif
  96. #endif