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