1 | /* |
2 | +----------------------------------------------------------------------+ |
3 | | PHP Version 5 | |
4 | +----------------------------------------------------------------------+ |
5 | | Copyright (c) 1997-2015 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: Michael Wallner <mike@php.net> | |
16 | +----------------------------------------------------------------------+ |
17 | */ |
18 | |
19 | #ifndef PHP_STDINT_H |
20 | #define PHP_STDINT_H |
21 | |
22 | #if defined(_MSC_VER) |
23 | /* Make sure the regular stdint.h wasn't included already and prevent it to be |
24 | included afterwards. Though if some other library needs some stuff from |
25 | stdint.h included afterwards and misses it, we'd have to extend ours. On |
26 | the other hand, if stdint.h was included before, some conflicts might |
27 | happen so we'd likewise have to fix ours. */ |
28 | # if !defined(_STDINT) |
29 | # define _STDINT |
30 | # include "win32/php_stdint.h" |
31 | # endif |
32 | # define HAVE_INT8_T 1 |
33 | # define HAVE_UINT8_T 1 |
34 | # define HAVE_INT16_T 1 |
35 | # define HAVE_UINT16_T 1 |
36 | # define HAVE_INT32_T 1 |
37 | # define HAVE_UINT32_T 1 |
38 | # define HAVE_INT64_T 1 |
39 | # define HAVE_UINT64_T 1 |
40 | #else |
41 | |
42 | #include "php_config.h" |
43 | |
44 | #if HAVE_SYS_TYPES_H |
45 | # include <sys/types.h> |
46 | #endif |
47 | |
48 | #if HAVE_INTTYPES_H |
49 | # include <inttypes.h> |
50 | #endif |
51 | |
52 | #if HAVE_STDINT_H |
53 | # include <stdint.h> |
54 | #endif |
55 | |
56 | #ifndef HAVE_INT8_T |
57 | # ifdef HAVE_INT8 |
58 | typedef int8 int8_t; |
59 | # else |
60 | typedef signed char int8_t; |
61 | # endif |
62 | #endif |
63 | |
64 | #ifndef INT8_C |
65 | # define INT8_C(c) c |
66 | #endif |
67 | |
68 | #ifndef HAVE_UINT8_T |
69 | # ifdef HAVE_UINT8 |
70 | typedef uint8 uint8_t |
71 | # elif HAVE_U_INT8_T |
72 | typedef u_int8_t uint8_t; |
73 | # else |
74 | typedef unsigned char uint8_t; |
75 | # endif |
76 | #endif |
77 | |
78 | #ifndef UINT8_C |
79 | # define UINT8_C(c) c |
80 | #endif |
81 | |
82 | #ifndef HAVE_INT16_T |
83 | # ifdef HAVE_INT16 |
84 | typedef int16 int16_t; |
85 | # elif SIZEOF_SHORT >= 2 |
86 | typedef signed short int16_t; |
87 | # else |
88 | # error "No suitable 16bit integer type found" |
89 | # endif |
90 | #endif |
91 | |
92 | #ifndef INT16_C |
93 | # define INT16_C(c) c |
94 | #endif |
95 | |
96 | #ifndef HAVE_UINT16_T |
97 | # ifdef HAVE_UINT16 |
98 | typedef uint16 uint16_t |
99 | # elif HAVE_U_INT16_T |
100 | typedef u_int16_t uint16_t; |
101 | # elif SIZEOF_SHORT >= 2 |
102 | typedef unsigned short uint16_t; |
103 | # else |
104 | # error "No suitable 16bit integer type found" |
105 | # endif |
106 | #endif |
107 | |
108 | #ifndef UINT16_C |
109 | # define UINT16_C(c) c |
110 | #endif |
111 | |
112 | #ifndef HAVE_INT32_T |
113 | # ifdef HAVE_INT32 |
114 | typedef int32 int32_t; |
115 | # elif SIZEOF_INT >= 4 |
116 | typedef int int32_t; |
117 | # elif SIZEOF_LONG >= 4 |
118 | typedef long int32_t; |
119 | # else |
120 | # error "No suitable 32bit integer type found" |
121 | # endif |
122 | #endif |
123 | |
124 | #ifndef INT32_C |
125 | # define INT32_C(c) c |
126 | #endif |
127 | |
128 | #ifndef HAVE_UINT32_T |
129 | # ifdef HAVE_UINT32 |
130 | typedef uint32 uint32_t |
131 | # elif HAVE_U_INT32_T |
132 | typedef u_int32_t uint32_t; |
133 | # elif SIZEOF_INT >= 4 |
134 | typedef unsigned int uint32_t; |
135 | # elif SIZEOF_LONG >= 4 |
136 | typedef unsigned long uint32_t; |
137 | # else |
138 | # error "No suitable 32bit integer type found" |
139 | # endif |
140 | #endif |
141 | |
142 | #ifndef UINT32_C |
143 | # define UINT32_C(c) c ## U |
144 | #endif |
145 | |
146 | #ifndef HAVE_INT64_T |
147 | # ifdef HAVE_INT64 |
148 | typedef int64 int64_t; |
149 | # elif SIZEOF_INT >= 8 |
150 | typedef int int64_t; |
151 | # elif SIZEOF_LONG >= 8 |
152 | typedef long int64_t; |
153 | # elif SIZEOF_LONG_LONG >= 8 |
154 | typedef long long int64_t; |
155 | # else |
156 | # error "No suitable 64bit integer type found" |
157 | # endif |
158 | #endif |
159 | |
160 | #ifndef INT64_C |
161 | # if SIZEOF_INT >= 8 |
162 | # define INT64_C(c) c |
163 | # elif SIZEOF_LONG >= 8 |
164 | # define INT64_C(c) c ## L |
165 | # elif SIZEOF_LONG_LONG >= 8 |
166 | # define INT64_C(c) c ## LL |
167 | # endif |
168 | #endif |
169 | |
170 | #ifndef HAVE_UINT64_T |
171 | # ifdef HAVE_UINT64 |
172 | typedef uint64 uint64_t |
173 | # elif HAVE_U_INT64_T |
174 | typedef u_int64_t uint64_t; |
175 | # elif SIZEOF_INT >= 8 |
176 | typedef unsigned int uint64_t; |
177 | # elif SIZEOF_LONG >= 8 |
178 | typedef unsigned long uint64_t; |
179 | # elif SIZEOF_LONG_LONG >= 8 |
180 | typedef unsigned long long uint64_t; |
181 | # else |
182 | # error "No suitable 64bit integer type found" |
183 | # endif |
184 | #endif |
185 | |
186 | #ifndef UINT64_C |
187 | # if SIZEOF_INT >= 8 |
188 | # define UINT64_C(c) c ## U |
189 | # elif SIZEOF_LONG >= 8 |
190 | # define UINT64_C(c) c ## UL |
191 | # elif SIZEOF_LONG_LONG >= 8 |
192 | # define UINT64_C(c) c ## ULL |
193 | # endif |
194 | #endif |
195 | |
196 | #endif /* !PHP_WIN32 */ |
197 | #endif /* PHP_STDINT_H */ |
198 | |
199 | /* |
200 | * Local variables: |
201 | * tab-width: 4 |
202 | * c-basic-offset: 4 |
203 | * End: |
204 | * vim600: sw=4 ts=4 fdm=marker |
205 | * vim<600: sw=4 ts=4 |
206 | */ |
207 | |