xref: /PHP-7.4/main/php_reentrancy.h (revision 2b28f718)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 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_LOCALTIME_R) && defined(HAVE_LOCALTIME)
53 #define PHP_NEED_REENTRANCY 1
54 PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm);
55 #else
56 #define php_localtime_r localtime_r
57 #ifdef MISSING_LOCALTIME_R_DECL
58 struct tm *localtime_r(const time_t *const timep, struct tm *p_tm);
59 #endif
60 #endif
61 
62 
63 #if !defined(HAVE_CTIME_R) && defined(HAVE_CTIME)
64 #define PHP_NEED_REENTRANCY 1
65 PHPAPI char *php_ctime_r(const time_t *clock, char *buf);
66 #else
67 #define php_ctime_r ctime_r
68 #ifdef MISSING_CTIME_R_DECL
69 char *ctime_r(const time_t *clock, char *buf);
70 #endif
71 #endif
72 
73 
74 #if !defined(HAVE_ASCTIME_R) && defined(HAVE_ASCTIME)
75 #define PHP_NEED_REENTRANCY 1
76 PHPAPI char *php_asctime_r(const struct tm *tm, char *buf);
77 #else
78 #define php_asctime_r asctime_r
79 #ifdef MISSING_ASCTIME_R_DECL
80 char *asctime_r(const struct tm *tm, char *buf);
81 #endif
82 #endif
83 
84 
85 #if !defined(HAVE_GMTIME_R) && defined(HAVE_GMTIME)
86 #define PHP_NEED_REENTRANCY 1
87 PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
88 #else
89 #define php_gmtime_r gmtime_r
90 #ifdef MISSING_GMTIME_R_DECL
91 struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
92 #endif
93 #endif
94 
95 #if !defined(HAVE_STRTOK_R)
96 PHPAPI char *php_strtok_r(char *s, const char *delim, char **last);
97 #else
98 #define php_strtok_r strtok_r
99 #ifdef MISSING_STRTOK_R_DECL
100 char *strtok_r(char *s, const char *delim, char **last);
101 #endif
102 #endif
103 
104 #if !defined(HAVE_RAND_R)
105 PHPAPI int php_rand_r(unsigned int *seed);
106 #else
107 #define php_rand_r rand_r
108 #endif
109 
110 END_EXTERN_C()
111 
112 #if !defined(ZTS)
113 #undef PHP_NEED_REENTRANCY
114 #endif
115 
116 #if defined(PHP_NEED_REENTRANCY)
117 void reentrancy_startup(void);
118 void reentrancy_shutdown(void);
119 #else
120 #define reentrancy_startup()
121 #define reentrancy_shutdown()
122 #endif
123 
124 #endif
125