OSDN Git Service

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