php_reentrancy.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 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. #ifndef PHP_REENTRANCY_H
  19. #define PHP_REENTRANCY_H
  20. #include "php.h"
  21. #include <sys/types.h>
  22. #ifdef HAVE_DIRENT_H
  23. #include <dirent.h>
  24. #endif
  25. #include <time.h>
  26. /* currently, PHP does not check for these functions, but assumes
  27. that they are available on all systems. */
  28. #define HAVE_LOCALTIME 1
  29. #define HAVE_GMTIME 1
  30. #define HAVE_ASCTIME 1
  31. #define HAVE_CTIME 1
  32. #if defined(PHP_IRIX_TIME_R)
  33. #undef HAVE_ASCTIME_R
  34. #undef HAVE_CTIME_R
  35. #endif
  36. #if defined(PHP_HPUX_TIME_R)
  37. #undef HAVE_LOCALTIME_R
  38. #undef HAVE_ASCTIME_R
  39. #undef HAVE_CTIME_R
  40. #undef HAVE_GMTIME_R
  41. #endif
  42. BEGIN_EXTERN_C()
  43. #if defined(HAVE_POSIX_READDIR_R)
  44. #define php_readdir_r readdir_r
  45. #else
  46. PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry,
  47. struct dirent **result);
  48. #endif
  49. #if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME)
  50. #define PHP_NEED_REENTRANCY 1
  51. PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm);
  52. #else
  53. #define php_localtime_r localtime_r
  54. #ifdef MISSING_LOCALTIME_R_DECL
  55. struct tm *localtime_r(const time_t *const timep, struct tm *p_tm);
  56. #endif
  57. #endif
  58. #if !defined(HAVE_CTIME_R) && defined(HAVE_CTIME)
  59. #define PHP_NEED_REENTRANCY 1
  60. PHPAPI char *php_ctime_r(const time_t *clock, char *buf);
  61. #else
  62. #define php_ctime_r ctime_r
  63. #ifdef MISSING_CTIME_R_DECL
  64. char *ctime_r(const time_t *clock, char *buf);
  65. #endif
  66. #endif
  67. #if !defined(HAVE_ASCTIME_R) && defined(HAVE_ASCTIME)
  68. #define PHP_NEED_REENTRANCY 1
  69. PHPAPI char *php_asctime_r(const struct tm *tm, char *buf);
  70. #else
  71. #define php_asctime_r asctime_r
  72. #ifdef MISSING_ASCTIME_R_DECL
  73. char *asctime_r(const struct tm *tm, char *buf);
  74. #endif
  75. #endif
  76. #if !defined(HAVE_GMTIME_R) && defined(HAVE_GMTIME)
  77. #define PHP_NEED_REENTRANCY 1
  78. PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
  79. #else
  80. #define php_gmtime_r gmtime_r
  81. #ifdef MISSING_GMTIME_R_DECL
  82. struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
  83. #endif
  84. #endif
  85. #if !defined(HAVE_STRTOK_R)
  86. PHPAPI char *php_strtok_r(char *s, const char *delim, char **last);
  87. #else
  88. #define php_strtok_r strtok_r
  89. #ifdef MISSING_STRTOK_R_DECL
  90. char *strtok_r(char *s, const char *delim, char **last);
  91. #endif
  92. #endif
  93. #if !defined(HAVE_RAND_R)
  94. PHPAPI int php_rand_r(unsigned int *seed);
  95. #else
  96. #define php_rand_r rand_r
  97. #endif
  98. END_EXTERN_C()
  99. #if !defined(ZTS)
  100. #undef PHP_NEED_REENTRANCY
  101. #endif
  102. #if defined(PHP_NEED_REENTRANCY)
  103. void reentrancy_startup(void);
  104. void reentrancy_shutdown(void);
  105. #else
  106. #define reentrancy_startup()
  107. #define reentrancy_shutdown()
  108. #endif
  109. #endif
  110. /*
  111. * Local variables:
  112. * tab-width: 4
  113. * c-basic-offset: 4
  114. * End:
  115. * vim600: sw=4 ts=4 fdm=marker
  116. * vim<600: sw=4 ts=4
  117. */