Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/stdint_.h @ 6790:f638a03c525c
Cygwin recognition fix.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 17 May 2006 10:46:10 +0000 |
parents | 296aceb85024 |
children | e896d59bd228 |
rev | line source |
---|---|
6511
23e64dcfa86c
Cosmetic tweak of SIZE_MAX.
Bruno Haible <bruno@clisp.org>
parents:
6510
diff
changeset
|
1 /* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc. |
5219 | 2 Written by Bruno Haible, Sam Steingold, Peter Burwood. |
3 This file is part of gnulib. | |
4 | |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2, or (at your option) | |
8 any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software Foundation, | |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
5713
diff
changeset
|
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
5219 | 18 |
19 #ifndef _STDINT_H | |
20 #define _STDINT_H | |
21 | |
22 /* | |
23 * ISO C 99 <stdint.h> for platforms that lack it. | |
6768 | 24 * <http://www.opengroup.org/susv3xbd/stdint.h.html> |
5219 | 25 */ |
26 | |
27 /* Get wchar_t, WCHAR_MIN, WCHAR_MAX. */ | |
28 #include <stddef.h> | |
29 /* Get CHAR_BIT, LONG_MIN, LONG_MAX, ULONG_MAX. */ | |
30 #include <limits.h> | |
31 | |
32 /* Get those types that are already defined in other system include files. */ | |
33 #if defined(__FreeBSD__) | |
34 # include <sys/inttypes.h> | |
35 #endif | |
6722 | 36 #if defined(__OpenBSD__) |
37 /* In OpenBSD 3.8, <sys/types.h> includes <machine/types.h>, which defines | |
38 int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. | |
39 <inttypes.h> includes <machine/types.h> and also defines intptr_t and | |
40 uintptr_t. */ | |
41 # include <sys/types.h> | |
42 # if HAVE_INTTYPES_H | |
43 # include <inttypes.h> | |
44 # endif | |
45 #endif | |
6510
0e8512b50591
Support for Linux libc4 and libc5.
Bruno Haible <bruno@clisp.org>
parents:
6459
diff
changeset
|
46 #if defined(__linux__) && HAVE_SYS_BITYPES_H |
0e8512b50591
Support for Linux libc4 and libc5.
Bruno Haible <bruno@clisp.org>
parents:
6459
diff
changeset
|
47 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines |
0e8512b50591
Support for Linux libc4 and libc5.
Bruno Haible <bruno@clisp.org>
parents:
6459
diff
changeset
|
48 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is |
0e8512b50591
Support for Linux libc4 and libc5.
Bruno Haible <bruno@clisp.org>
parents:
6459
diff
changeset
|
49 included by <sys/types.h>. */ |
0e8512b50591
Support for Linux libc4 and libc5.
Bruno Haible <bruno@clisp.org>
parents:
6459
diff
changeset
|
50 # include <sys/bitypes.h> |
0e8512b50591
Support for Linux libc4 and libc5.
Bruno Haible <bruno@clisp.org>
parents:
6459
diff
changeset
|
51 #endif |
5219 | 52 #if defined(__sun) && HAVE_SYS_INTTYPES_H |
53 # include <sys/inttypes.h> | |
54 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and | |
55 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. | |
56 But note that <sys/int_types.h> contains only the type definitions! */ | |
5878
2b44331388e9
Rename HAVE_SYSTEM_INTTYPES macro.
Bruno Haible <bruno@clisp.org>
parents:
5850
diff
changeset
|
57 # define _STDINT_H_HAVE_SYSTEM_INTTYPES |
5219 | 58 #endif |
59 #if (defined(__hpux) || defined(_AIX)) && HAVE_INTTYPES_H | |
60 # include <inttypes.h> | |
61 /* HP-UX 10 <inttypes.h> has nearly everything, except UINT_LEAST8_MAX, | |
62 UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */ | |
63 /* AIX 4 <inttypes.h> has nearly everything, except INTPTR_MIN, INTPTR_MAX, | |
64 UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */ | |
5878
2b44331388e9
Rename HAVE_SYSTEM_INTTYPES macro.
Bruno Haible <bruno@clisp.org>
parents:
5850
diff
changeset
|
65 # define _STDINT_H_HAVE_SYSTEM_INTTYPES |
5219 | 66 #endif |
6790 | 67 #if !((defined(__CYGWIN__) || defined(__linux__)) && defined(__BIT_TYPES_DEFINED__)) |
5879
dc26ae8b485e
Rename NEED_SIGNED_INT_TYPES macro.
Bruno Haible <bruno@clisp.org>
parents:
5878
diff
changeset
|
68 # define _STDINT_H_NEED_SIGNED_INT_TYPES |
5219 | 69 #endif |
70 | |
5878
2b44331388e9
Rename HAVE_SYSTEM_INTTYPES macro.
Bruno Haible <bruno@clisp.org>
parents:
5850
diff
changeset
|
71 #if !defined(_STDINT_H_HAVE_SYSTEM_INTTYPES) |
5219 | 72 |
73 /* 7.18.1.1. Exact-width integer types */ | |
74 | |
6722 | 75 #if !(defined(__FreeBSD__) || defined(__OpenBSD__)) |
5219 | 76 |
5879
dc26ae8b485e
Rename NEED_SIGNED_INT_TYPES macro.
Bruno Haible <bruno@clisp.org>
parents:
5878
diff
changeset
|
77 #ifdef _STDINT_H_NEED_SIGNED_INT_TYPES |
5219 | 78 typedef signed char int8_t; |
79 #endif | |
80 typedef unsigned char uint8_t; | |
81 | |
5879
dc26ae8b485e
Rename NEED_SIGNED_INT_TYPES macro.
Bruno Haible <bruno@clisp.org>
parents:
5878
diff
changeset
|
82 #ifdef _STDINT_H_NEED_SIGNED_INT_TYPES |
5219 | 83 typedef short int16_t; |
84 #endif | |
85 typedef unsigned short uint16_t; | |
86 | |
5879
dc26ae8b485e
Rename NEED_SIGNED_INT_TYPES macro.
Bruno Haible <bruno@clisp.org>
parents:
5878
diff
changeset
|
87 #ifdef _STDINT_H_NEED_SIGNED_INT_TYPES |
5219 | 88 typedef int int32_t; |
89 #endif | |
90 typedef unsigned int uint32_t; | |
91 | |
92 #if @HAVE_LONG_64BIT@ | |
5879
dc26ae8b485e
Rename NEED_SIGNED_INT_TYPES macro.
Bruno Haible <bruno@clisp.org>
parents:
5878
diff
changeset
|
93 #ifdef _STDINT_H_NEED_SIGNED_INT_TYPES |
5219 | 94 typedef long int64_t; |
95 #endif | |
96 typedef unsigned long uint64_t; | |
5880 | 97 #define _STDINT_H_HAVE_INT64 |
5713
b91d73b06792
Rename HAVE_LONGLONG_64BIT to HAVE_LONG_LONG_64BIT.
Bruno Haible <bruno@clisp.org>
parents:
5219
diff
changeset
|
98 #elif @HAVE_LONG_LONG_64BIT@ |
5879
dc26ae8b485e
Rename NEED_SIGNED_INT_TYPES macro.
Bruno Haible <bruno@clisp.org>
parents:
5878
diff
changeset
|
99 #ifdef _STDINT_H_NEED_SIGNED_INT_TYPES |
5219 | 100 typedef long long int64_t; |
101 #endif | |
102 typedef unsigned long long uint64_t; | |
5880 | 103 #define _STDINT_H_HAVE_INT64 |
5850
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
104 #elif defined(_MSC_VER) |
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
105 typedef __int64 int64_t; |
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
106 typedef unsigned __int64 uint64_t; |
5880 | 107 #define _STDINT_H_HAVE_INT64 |
5219 | 108 #endif |
109 | |
6722 | 110 #endif /* !(FreeBSD || OpenBSD) */ |
5219 | 111 |
112 /* 7.18.1.2. Minimum-width integer types */ | |
113 | |
114 typedef int8_t int_least8_t; | |
115 typedef uint8_t uint_least8_t; | |
116 typedef int16_t int_least16_t; | |
117 typedef uint16_t uint_least16_t; | |
118 typedef int32_t int_least32_t; | |
119 typedef uint32_t uint_least32_t; | |
5880 | 120 #ifdef _STDINT_H_HAVE_INT64 |
5219 | 121 typedef int64_t int_least64_t; |
122 typedef uint64_t uint_least64_t; | |
123 #endif | |
124 | |
125 /* 7.18.1.3. Fastest minimum-width integer types */ | |
126 | |
127 typedef int32_t int_fast8_t; | |
128 typedef uint32_t uint_fast8_t; | |
129 typedef int32_t int_fast16_t; | |
130 typedef uint32_t uint_fast16_t; | |
131 typedef int32_t int_fast32_t; | |
132 typedef uint32_t uint_fast32_t; | |
5880 | 133 #ifdef _STDINT_H_HAVE_INT64 |
5219 | 134 typedef int64_t int_fast64_t; |
135 typedef uint64_t uint_fast64_t; | |
136 #endif | |
137 | |
138 /* 7.18.1.4. Integer types capable of holding object pointers */ | |
139 | |
6722 | 140 #if !(defined(__FreeBSD__) || (defined(__OpenBSD__) && HAVE_INTTYPES_H)) |
5219 | 141 |
142 /* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long), | |
143 but this doesn't matter here. */ | |
144 typedef long intptr_t; | |
145 typedef unsigned long uintptr_t; | |
146 | |
6722 | 147 #endif /* !(FreeBSD || (OpenBSD && HAVE_INTTYPES_H)) */ |
5219 | 148 |
149 /* 7.18.1.5. Greatest-width integer types */ | |
150 | |
5880 | 151 #ifdef _STDINT_H_HAVE_INT64 |
6459
a7256b0c876a
* stdint_.h (intmax_t) [defined intmax_t]: Do not declare.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5880
diff
changeset
|
152 # ifndef intmax_t |
5219 | 153 typedef int64_t intmax_t; |
6459
a7256b0c876a
* stdint_.h (intmax_t) [defined intmax_t]: Do not declare.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5880
diff
changeset
|
154 # endif |
a7256b0c876a
* stdint_.h (intmax_t) [defined intmax_t]: Do not declare.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5880
diff
changeset
|
155 # ifndef uintmax_t |
5219 | 156 typedef uint64_t uintmax_t; |
6459
a7256b0c876a
* stdint_.h (intmax_t) [defined intmax_t]: Do not declare.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5880
diff
changeset
|
157 # endif |
5219 | 158 #else |
6459
a7256b0c876a
* stdint_.h (intmax_t) [defined intmax_t]: Do not declare.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5880
diff
changeset
|
159 # ifndef intmax_t |
5219 | 160 typedef int32_t intmax_t; |
6459
a7256b0c876a
* stdint_.h (intmax_t) [defined intmax_t]: Do not declare.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5880
diff
changeset
|
161 # endif |
a7256b0c876a
* stdint_.h (intmax_t) [defined intmax_t]: Do not declare.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5880
diff
changeset
|
162 # ifndef uintmax_t |
5219 | 163 typedef uint32_t uintmax_t; |
6459
a7256b0c876a
* stdint_.h (intmax_t) [defined intmax_t]: Do not declare.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5880
diff
changeset
|
164 # endif |
5219 | 165 #endif |
166 | |
167 /* 7.18.2. Limits of specified-width integer types */ | |
168 | |
169 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) | |
170 | |
171 /* 7.18.2.1. Limits of exact-width integer types */ | |
172 | |
173 #define INT8_MIN -128 | |
174 #define INT8_MAX 127 | |
175 #define UINT8_MAX 255U | |
176 #define INT16_MIN -32768 | |
177 #define INT16_MAX 32767 | |
178 #define UINT16_MAX 65535U | |
179 #define INT32_MIN (~INT32_MAX) | |
180 #define INT32_MAX 2147483647 | |
181 #define UINT32_MAX 4294967295U | |
5880 | 182 #ifdef _STDINT_H_HAVE_INT64 |
183 #define INT64_MIN (~INT64_MAX) | |
5219 | 184 #if @HAVE_LONG_64BIT@ |
185 #define INT64_MAX 9223372036854775807L | |
186 #define UINT64_MAX 18446744073709551615UL | |
5713
b91d73b06792
Rename HAVE_LONGLONG_64BIT to HAVE_LONG_LONG_64BIT.
Bruno Haible <bruno@clisp.org>
parents:
5219
diff
changeset
|
187 #elif @HAVE_LONG_LONG_64BIT@ |
5219 | 188 #define INT64_MAX 9223372036854775807LL |
189 #define UINT64_MAX 18446744073709551615ULL | |
5850
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
190 #elif defined(_MSC_VER) |
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
191 #define INT64_MAX 9223372036854775807i64 |
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
192 #define UINT64_MAX 18446744073709551615ui64 |
5219 | 193 #endif |
5880 | 194 #endif |
5219 | 195 |
196 /* 7.18.2.2. Limits of minimum-width integer types */ | |
197 | |
198 #define INT_LEAST8_MIN INT8_MIN | |
199 #define INT_LEAST8_MAX INT8_MAX | |
200 #define UINT_LEAST8_MAX UINT8_MAX | |
201 #define INT_LEAST16_MIN INT16_MIN | |
202 #define INT_LEAST16_MAX INT16_MAX | |
203 #define UINT_LEAST16_MAX UINT16_MAX | |
204 #define INT_LEAST32_MIN INT32_MIN | |
205 #define INT_LEAST32_MAX INT32_MAX | |
206 #define UINT_LEAST32_MAX UINT32_MAX | |
5880 | 207 #ifdef _STDINT_H_HAVE_INT64 |
5219 | 208 #define INT_LEAST64_MIN INT64_MIN |
209 #define INT_LEAST64_MAX INT64_MAX | |
210 #define UINT_LEAST64_MAX UINT64_MAX | |
211 #endif | |
212 | |
213 /* 7.18.2.3. Limits of fastest minimum-width integer types */ | |
214 | |
215 #define INT_FAST8_MIN INT32_MIN | |
216 #define INT_FAST8_MAX INT32_MAX | |
217 #define UINT_FAST8_MAX UINT32_MAX | |
218 #define INT_FAST16_MIN INT32_MIN | |
219 #define INT_FAST16_MAX INT32_MAX | |
220 #define UINT_FAST16_MAX UINT32_MAX | |
221 #define INT_FAST32_MIN INT32_MIN | |
222 #define INT_FAST32_MAX INT32_MAX | |
223 #define UINT_FAST32_MAX UINT32_MAX | |
5880 | 224 #ifdef _STDINT_H_HAVE_INT64 |
5219 | 225 #define INT_FAST64_MIN INT64_MIN |
226 #define INT_FAST64_MAX INT64_MAX | |
227 #define UINT_FAST64_MAX UINT64_MAX | |
228 #endif | |
229 | |
230 /* 7.18.2.4. Limits of integer types capable of holding object pointers */ | |
231 | |
232 #define INTPTR_MIN LONG_MIN | |
233 #define INTPTR_MAX LONG_MAX | |
234 #define UINTPTR_MAX ULONG_MAX | |
235 | |
236 /* 7.18.2.5. Limits of greatest-width integer types */ | |
237 | |
5880 | 238 #ifdef _STDINT_H_HAVE_INT64 |
5219 | 239 #define INTMAX_MIN INT64_MIN |
240 #define INTMAX_MAX INT64_MAX | |
241 #define UINTMAX_MAX UINT64_MAX | |
242 #else | |
243 #define INTMAX_MIN INT32_MIN | |
244 #define INTMAX_MAX INT32_MAX | |
245 #define UINTMAX_MAX UINT32_MAX | |
246 #endif | |
247 | |
248 /* 7.18.3. Limits of other integer types */ | |
249 | |
250 #define PTRDIFF_MIN (~(ptrdiff_t)0 << (sizeof(ptrdiff_t)*CHAR_BIT-1)) | |
251 #define PTRDIFF_MAX (~PTRDIFF_MIN) | |
252 | |
253 /* This may be wrong... */ | |
254 #define SIG_ATOMIC_MIN 0 | |
255 #define SIG_ATOMIC_MAX 127 | |
256 | |
6511
23e64dcfa86c
Cosmetic tweak of SIZE_MAX.
Bruno Haible <bruno@clisp.org>
parents:
6510
diff
changeset
|
257 #ifndef SIZE_MAX /* SIZE_MAX may also be defined in config.h. */ |
6552
8cf77ec96009
(SIZE_MAX): Add missing (.
Simon Josefsson <simon@josefsson.org>
parents:
6511
diff
changeset
|
258 # define SIZE_MAX ((size_t)~(size_t)0) |
6459
a7256b0c876a
* stdint_.h (intmax_t) [defined intmax_t]: Do not declare.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5880
diff
changeset
|
259 #endif |
5219 | 260 |
261 /* wchar_t limits already defined in <stddef.h>. */ | |
262 /* wint_t limits already defined in <wchar.h>. */ | |
263 | |
264 #endif | |
265 | |
266 /* 7.18.4. Macros for integer constants */ | |
267 | |
268 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) | |
269 | |
270 /* 7.18.4.1. Macros for minimum-width integer constants */ | |
271 | |
272 #define INT8_C(x) x | |
273 #define UINT8_C(x) x##U | |
274 #define INT16_C(x) x | |
275 #define UINT16_C(x) x##U | |
276 #define INT32_C(x) x | |
277 #define UINT32_C(x) x##U | |
278 #if @HAVE_LONG_64BIT@ | |
279 #define INT64_C(x) x##L | |
280 #define UINT64_C(x) x##UL | |
5713
b91d73b06792
Rename HAVE_LONGLONG_64BIT to HAVE_LONG_LONG_64BIT.
Bruno Haible <bruno@clisp.org>
parents:
5219
diff
changeset
|
281 #elif @HAVE_LONG_LONG_64BIT@ |
5219 | 282 #define INT64_C(x) x##LL |
283 #define UINT64_C(x) x##ULL | |
5850
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
284 #elif defined(_MSC_VER) |
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
285 #define INT64_C(x) x##i64 |
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
286 #define UINT64_C(x) x##ui64 |
5219 | 287 #endif |
288 | |
289 /* 7.18.4.2. Macros for greatest-width integer constants */ | |
290 | |
291 #if @HAVE_LONG_64BIT@ | |
292 #define INTMAX_C(x) x##L | |
293 #define UINTMAX_C(x) x##UL | |
5713
b91d73b06792
Rename HAVE_LONGLONG_64BIT to HAVE_LONG_LONG_64BIT.
Bruno Haible <bruno@clisp.org>
parents:
5219
diff
changeset
|
294 #elif @HAVE_LONG_LONG_64BIT@ |
5219 | 295 #define INTMAX_C(x) x##LL |
296 #define UINTMAX_C(x) x##ULL | |
5850
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
297 #elif defined(_MSC_VER) |
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
298 #define INTMAX_C(x) x##i64 |
1b7017c2d9b8
Add support for 64-bit integers in the MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
299 #define UINTMAX_C(x) x##ui64 |
5219 | 300 #else |
301 #define INTMAX_C(x) x | |
302 #define UINTMAX_C(x) x##U | |
303 #endif | |
304 | |
305 #endif | |
306 | |
5878
2b44331388e9
Rename HAVE_SYSTEM_INTTYPES macro.
Bruno Haible <bruno@clisp.org>
parents:
5850
diff
changeset
|
307 #endif /* !_STDINT_H_HAVE_SYSTEM_INTTYPES */ |
5219 | 308 |
309 #endif /* _STDINT_H */ |