nckernel  0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
stdint.h
Go to the documentation of this file.
1 
5 /* Copyright (C) 1997,1998,1999,2000,2001,2006 Free Software Foundation, Inc.
6  This file is part of the GNU C Library.
7 
8  The GNU C Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  The GNU C Library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with the GNU C Library; if not, write to the Free
20  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21  02111-1307 USA. */
22 
23 /*
24  * ISO C99: 7.18 Integer types <stdint.h>
25  */
26 
27 /* Exact integral types. */
28 
29 /* Signed. */
30 
31 /* There is some amount of overlap with <sys/types.h> as known by inet code */
32 #ifndef __int8_t_defined
33 # define __int8_t_defined
34 typedef signed char int8_t;
35 typedef short int int16_t;
36 typedef int int32_t;
37 # if __WORDSIZE == 64
38 typedef long int int64_t;
39 # else
40 __extension__
41 typedef long long int int64_t;
42 # endif
43 #endif
44 
45 /* Unsigned. */
46 typedef unsigned char uint8_t;
47 typedef unsigned short int uint16_t;
48 #ifndef __uint32_t_defined
49 typedef unsigned int uint32_t;
50 # define __uint32_t_defined
51 #endif
52 #if __WORDSIZE == 64
53 typedef unsigned long int uint64_t;
54 #else
55 __extension__
56 typedef unsigned long long int uint64_t;
57 #endif
58 
59 
60 /* Small types. */
61 
62 /* Signed. */
63 typedef signed char int_least8_t;
64 typedef short int int_least16_t;
65 typedef int int_least32_t;
66 #if __WORDSIZE == 64
67 typedef long int int_least64_t;
68 #else
69 __extension__
70 typedef long long int int_least64_t;
71 #endif
72 
73 /* Unsigned. */
74 typedef unsigned char uint_least8_t;
75 typedef unsigned short int uint_least16_t;
76 typedef unsigned int uint_least32_t;
77 #if __WORDSIZE == 64
78 typedef unsigned long int uint_least64_t;
79 #else
80 __extension__
81 typedef unsigned long long int uint_least64_t;
82 #endif
83 
84 
85 /* Fast types. */
86 
87 /* Signed. */
88 typedef signed char int_fast8_t;
89 #if __WORDSIZE == 64
90 typedef long int int_fast16_t;
91 typedef long int int_fast32_t;
92 typedef long int int_fast64_t;
93 #else
94 typedef int int_fast16_t;
95 typedef int int_fast32_t;
96 __extension__
97 typedef long long int int_fast64_t;
98 #endif
99 
100 /* Unsigned. */
101 typedef unsigned char uint_fast8_t;
102 #if __WORDSIZE == 64
103 typedef unsigned long int uint_fast16_t;
104 typedef unsigned long int uint_fast32_t;
105 typedef unsigned long int uint_fast64_t;
106 #else
107 typedef unsigned int uint_fast16_t;
108 typedef unsigned int uint_fast32_t;
109 __extension__
110 typedef unsigned long long int uint_fast64_t;
111 #endif
112 
113 
114 /* Types for `void *' pointers. */
115 #if __WORDSIZE == 64
116 # ifndef __intptr_t_defined
117 typedef long int intptr_t;
118 # define __intptr_t_defined
119 # endif
120 typedef unsigned long int uintptr_t;
121 #else
122 # ifndef __intptr_t_defined
123 typedef int intptr_t;
124 # define __intptr_t_defined
125 # endif
126 typedef unsigned int uintptr_t;
127 #endif
128 
129 
130 /* Largest integral types. */
131 #if __WORDSIZE == 64
132 typedef long int intmax_t;
133 typedef unsigned long int uintmax_t;
134 #else
135 __extension__
136 typedef long long int intmax_t;
137 __extension__
138 typedef unsigned long long int uintmax_t;
139 #endif
140 
141 
142 /* The ISO C99 standard specifies that in C++ implementations these
143  macros should only be defined if explicitly requested. */
144 #if !defined __cplusplus || defined __STDC_LIMIT_MACROS
145 
146 # if __WORDSIZE == 64
147 # define __INT64_C(c) c ## L
148 # define __UINT64_C(c) c ## UL
149 # else
150 # define __INT64_C(c) c ## LL
151 # define __UINT64_C(c) c ## ULL
152 # endif
153 
154 /* Limits of integral types. */
155 
156 /* Minimum of signed integral types. */
157 # define INT8_MIN (-128)
158 # define INT16_MIN (-32767-1)
159 # define INT32_MIN (-2147483647-1)
160 # define INT64_MIN (-__INT64_C(9223372036854775807)-1)
161 /* Maximum of signed integral types. */
162 # define INT8_MAX (127)
163 # define INT16_MAX (32767)
164 # define INT32_MAX (2147483647)
165 # define INT64_MAX (__INT64_C(9223372036854775807))
166 
167 /* Maximum of unsigned integral types. */
168 # define UINT8_MAX (255)
169 # define UINT16_MAX (65535)
170 # define UINT32_MAX (4294967295U)
171 # define UINT64_MAX (__UINT64_C(18446744073709551615))
172 
173 
174 /* Minimum of signed integral types having a minimum size. */
175 # define INT_LEAST8_MIN (-128)
176 # define INT_LEAST16_MIN (-32767-1)
177 # define INT_LEAST32_MIN (-2147483647-1)
178 # define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1)
179 /* Maximum of signed integral types having a minimum size. */
180 # define INT_LEAST8_MAX (127)
181 # define INT_LEAST16_MAX (32767)
182 # define INT_LEAST32_MAX (2147483647)
183 # define INT_LEAST64_MAX (__INT64_C(9223372036854775807))
184 
185 /* Maximum of unsigned integral types having a minimum size. */
186 # define UINT_LEAST8_MAX (255)
187 # define UINT_LEAST16_MAX (65535)
188 # define UINT_LEAST32_MAX (4294967295U)
189 # define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615))
190 
191 
192 /* Minimum of fast signed integral types having a minimum size. */
193 # define INT_FAST8_MIN (-128)
194 # if __WORDSIZE == 64
195 # define INT_FAST16_MIN (-9223372036854775807L-1)
196 # define INT_FAST32_MIN (-9223372036854775807L-1)
197 # else
198 # define INT_FAST16_MIN (-2147483647-1)
199 # define INT_FAST32_MIN (-2147483647-1)
200 # endif
201 # define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1)
202 /* Maximum of fast signed integral types having a minimum size. */
203 # define INT_FAST8_MAX (127)
204 # if __WORDSIZE == 64
205 # define INT_FAST16_MAX (9223372036854775807L)
206 # define INT_FAST32_MAX (9223372036854775807L)
207 # else
208 # define INT_FAST16_MAX (2147483647)
209 # define INT_FAST32_MAX (2147483647)
210 # endif
211 # define INT_FAST64_MAX (__INT64_C(9223372036854775807))
212 
213 /* Maximum of fast unsigned integral types having a minimum size. */
214 # define UINT_FAST8_MAX (255)
215 # if __WORDSIZE == 64
216 # define UINT_FAST16_MAX (18446744073709551615UL)
217 # define UINT_FAST32_MAX (18446744073709551615UL)
218 # else
219 # define UINT_FAST16_MAX (4294967295U)
220 # define UINT_FAST32_MAX (4294967295U)
221 # endif
222 # define UINT_FAST64_MAX (__UINT64_C(18446744073709551615))
223 
224 
225 /* Values to test for integral types holding `void *' pointer. */
226 # if __WORDSIZE == 64
227 # define INTPTR_MIN (-9223372036854775807L-1)
228 # define INTPTR_MAX (9223372036854775807L)
229 # define UINTPTR_MAX (18446744073709551615UL)
230 # else
231 # define INTPTR_MIN (-2147483647-1)
232 # define INTPTR_MAX (2147483647)
233 # define UINTPTR_MAX (4294967295U)
234 # endif
235 
236 
237 /* Minimum for largest signed integral type. */
238 # define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
239 /* Maximum for largest signed integral type. */
240 # define INTMAX_MAX (__INT64_C(9223372036854775807))
241 
242 /* Maximum for largest unsigned integral type. */
243 # define UINTMAX_MAX (__UINT64_C(18446744073709551615))
244 
245 
246 /* Limits of other integer types. */
247 
248 /* Limits of `ptrdiff_t' type. */
249 # if __WORDSIZE == 64
250 # define PTRDIFF_MIN (-9223372036854775807L-1)
251 # define PTRDIFF_MAX (9223372036854775807L)
252 # else
253 # define PTRDIFF_MIN (-2147483647-1)
254 # define PTRDIFF_MAX (2147483647)
255 # endif
256 
257 /* Limits of `sig_atomic_t'. */
258 # define SIG_ATOMIC_MIN (-2147483647-1)
259 # define SIG_ATOMIC_MAX (2147483647)
260 
261 /* Limit of `size_t' type. */
262 # if __WORDSIZE == 64
263 # define SIZE_MAX (18446744073709551615UL)
264 # else
265 # define SIZE_MAX (4294967295U)
266 # endif
267 
268 /* Limits of `wchar_t'. */
269 # ifndef WCHAR_MIN
270 /* These constants might also be defined in <wchar.h>. */
271 # define WCHAR_MIN __WCHAR_MIN
272 # define WCHAR_MAX __WCHAR_MAX
273 # endif
274 
275 /* Limits of `wint_t'. */
276 # define WINT_MIN (0u)
277 # define WINT_MAX (4294967295u)
278 
279 #endif /* C++ && limit macros */
280 
281 
282 /* The ISO C99 standard specifies that in C++ implementations these
283  should only be defined if explicitly requested. */
284 #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
285 
286 /* Signed. */
287 # define INT8_C(c) c
288 # define INT16_C(c) c
289 # define INT32_C(c) c
290 # if __WORDSIZE == 64
291 # define INT64_C(c) c ## L
292 # else
293 # define INT64_C(c) c ## LL
294 # endif
295 
296 /* Unsigned. */
297 # define UINT8_C(c) c
298 # define UINT16_C(c) c
299 # define UINT32_C(c) c ## U
300 # if __WORDSIZE == 64
301 # define UINT64_C(c) c ## UL
302 # else
303 # define UINT64_C(c) c ## ULL
304 # endif
305 
306 /* Maximal type. */
307 # if __WORDSIZE == 64
308 # define INTMAX_C(c) c ## L
309 # define UINTMAX_C(c) c ## UL
310 # else
311 # define INTMAX_C(c) c ## LL
312 # define UINTMAX_C(c) c ## ULL
313 # endif
314 
315 #endif /* C++ && constant macros */
316 
317