php_reentrancy.h 3.6 KB

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