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