OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [include/] [stdint.h] - Blame information for rev 179

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * Copyright (c) 2004, 2005 by
3
 * Ralf Corsepius, Ulm/Germany. All rights reserved.
4
 *
5
 * Permission to use, copy, modify, and distribute this software
6
 * is freely granted, provided that this notice is preserved.
7
 */
8
 
9
#ifndef _STDINT_H
10
#define _STDINT_H
11
 
12
#ifdef __cplusplus
13
extern "C" {
14
#endif
15
 
16
#if defined(__GNUC__) && \
17
  ( (__GNUC__ >= 4) || \
18
    ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2) ) )
19
/* gcc > 3.2 implicitly defines the values we are interested */
20
#define __STDINT_EXP(x) __##x##__
21
#else
22
#define __STDINT_EXP(x) x
23
#include <limits.h>
24
#endif
25
 
26
/* Check if "long long" is 64bit wide */
27
/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */
28
#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
29
  || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
30
#define __have_longlong64 1
31
#endif
32
 
33
/* Check if "long" is 64bit or 32bit wide */
34
#if __STDINT_EXP(LONG_MAX) > 0x7fffffff
35
#define __have_long64 1
36
#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
37
#define __have_long32 1
38
#endif
39
 
40
#if __STDINT_EXP(SCHAR_MAX) == 0x7f
41
typedef signed char int8_t ;
42
typedef unsigned char uint8_t ;
43
#define __int8_t_defined 1
44
#endif
45
 
46
#if __int8_t_defined
47
typedef signed char int_least8_t;
48
typedef unsigned char uint_least8_t;
49
#define __int_least8_t_defined 1
50
#endif
51
 
52
#if __STDINT_EXP(SHRT_MAX) == 0x7fff
53
typedef signed short int16_t;
54
typedef unsigned short uint16_t;
55
#define __int16_t_defined 1
56
#elif __STDINT_EXP(INT_MAX) == 0x7fff
57
typedef signed int int16_t;
58
typedef unsigned int uint16_t;
59
#define __int16_t_defined 1
60
#elif __STDINT_EXP(SCHAR_MAX) == 0x7fff
61
typedef signed char int16_t;
62
typedef unsigned char uint16_t;
63
#define __int16_t_defined 1
64
#endif
65
 
66
#if __int16_t_defined
67
typedef int16_t         int_least16_t;
68
typedef uint16_t        uint_least16_t;
69
#define __int_least16_t_defined 1
70
 
71
#if !__int_least8_t_defined
72
typedef int16_t         int_least8_t;
73
typedef uint16_t        uint_least8_t;
74
#define __int_least8_t_defined 1
75
#endif
76
#endif
77
 
78
#if __have_long32
79
typedef signed long int32_t;
80
typedef unsigned long uint32_t;
81
#define __int32_t_defined 1
82
#elif __STDINT_EXP(INT_MAX) == 0x7fffffffL
83
typedef signed int int32_t;
84
typedef unsigned int uint32_t;
85
#define __int32_t_defined 1
86
#elif __STDINT_EXP(SHRT_MAX) == 0x7fffffffL
87
typedef signed short int32_t;
88
typedef unsigned short uint32_t;
89
#define __int32_t_defined 1
90
#elif __STDINT_EXP(SCHAR_MAX) == 0x7fffffffL
91
typedef signed char int32_t;
92
typedef unsigned char uint32_t;
93
#define __int32_t_defined 1
94
#endif
95
 
96
#if __int32_t_defined
97
typedef int32_t         int_least32_t;
98
typedef uint32_t        uint_least32_t;
99
#define __int_least32_t_defined 1
100
 
101
#if !__int_least8_t_defined
102
typedef int32_t         int_least8_t;
103
typedef uint32_t        uint_least8_t;
104
#define __int_least8_t_defined 1
105
#endif
106
 
107
#if !__int_least16_t_defined
108
typedef int32_t         int_least16_t;
109
typedef uint32_t        uint_least16_t;
110
#define __int_least16_t_defined 1
111
#endif
112
#endif
113
 
114
#if __have_long64
115
typedef signed long int64_t;
116
typedef unsigned long uint64_t;
117
#define __int64_t_defined 1
118
#elif __have_longlong64
119
typedef signed long long int64_t;
120
typedef unsigned long long uint64_t;
121
#define __int64_t_defined 1
122
#elif  __STDINT_EXP(INT_MAX) > 0x7fffffff
123
typedef signed int int64_t;
124
typedef unsigned int uint64_t;
125
#define __int64_t_defined 1
126
#endif
127
 
128
#if __int64_t_defined
129
typedef int64_t         int_least64_t;
130
typedef uint64_t        uint_least64_t;
131
#define __int_least64_t_defined 1
132
 
133
#if !__int_least8_t_defined
134
typedef int64_t         int_least8_t;
135
typedef uint64_t        uint_least8_t;
136
#define __int_least8_t_defined 1
137
#endif
138
 
139
#if !__int_least16_t_defined
140
typedef int64_t         int_least16_t;
141
typedef uint64_t        uint_least16_t;
142
#define __int_least16_t_defined 1
143
#endif
144
 
145
#if !__int_least32_t_defined
146
typedef int64_t         int_least32_t;
147
typedef uint64_t        uint_least32_t;
148
#define __int_least32_t_defined 1
149
#endif
150
#endif
151
 
152
/*
153
 * Fastest minimum-width integer types
154
 *
155
 * Assume int to be the fastest type for all types with a width
156
 * less than __INT_MAX__ rsp. INT_MAX
157
 */
158
#if __STDINT_EXP(INT_MAX) >= 0x7f
159
  typedef signed int int_fast8_t;
160
  typedef unsigned int uint_fast8_t;
161
#define __int_fast8_t_defined 1
162
#endif
163
 
164
#if __STDINT_EXP(INT_MAX) >= 0x7fff
165
  typedef signed int int_fast16_t;
166
  typedef unsigned int uint_fast16_t;
167
#define __int_fast16_t_defined 1
168
#endif
169
 
170
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff
171
  typedef signed int int_fast32_t;
172
  typedef unsigned int uint_fast32_t;
173
#define __int_fast32_t_defined 1
174
#endif
175
 
176
#if __STDINT_EXP(INT_MAX) > 0x7fffffff
177
  typedef signed int int_fast64_t;
178
  typedef unsigned int uint_fast64_t;
179
#define __int_fast64_t_defined 1
180
#endif
181
 
182
/*
183
 * Fall back to [u]int_least<N>_t for [u]int_fast<N>_t types
184
 * not having been defined, yet.
185
 * Leave undefined, if [u]int_least<N>_t should not be available.
186
 */
187
#if !__int_fast8_t_defined
188
#if __int_least8_t_defined
189
  typedef int_least8_t int_fast8_t;
190
  typedef uint_least8_t uint_fast8_t;
191
#define __int_fast8_t_defined 1
192
#endif
193
#endif
194
 
195
#if !__int_fast16_t_defined
196
#if __int_least16_t_defined
197
  typedef int_least16_t int_fast16_t;
198
  typedef uint_least16_t uint_fast16_t;
199
#define __int_fast16_t_defined 1
200
#endif
201
#endif
202
 
203
#if !__int_fast32_t_defined
204
#if __int_least32_t_defined
205
  typedef int_least32_t int_fast32_t;
206
  typedef uint_least32_t uint_fast32_t;
207
#define __int_fast32_t_defined 1
208
#endif
209
#endif
210
 
211
#if !__int_fast64_t_defined
212
#if __int_least64_t_defined
213
  typedef int_least64_t int_fast64_t;
214
  typedef uint_least64_t uint_fast64_t;
215
#define __int_fast64_t_defined 1
216
#endif
217
#endif
218
 
219
/* Greatest-width integer types */
220
/* Modern GCCs provide __INTMAX_TYPE__ */
221
#if defined(__INTMAX_TYPE__)
222
  typedef __INTMAX_TYPE__ intmax_t;
223
#elif __have_longlong64
224
  typedef signed long long intmax_t;
225
#else
226
  typedef signed long intmax_t;
227
#endif
228
 
229
/* Modern GCCs provide __UINTMAX_TYPE__ */
230
#if defined(__UINTMAX_TYPE__)
231
  typedef __UINTMAX_TYPE__ uintmax_t;
232
#elif __have_longlong64
233
  typedef unsigned long long uintmax_t;
234
#else
235
  typedef unsigned long uintmax_t;
236
#endif
237
 
238
/*
239
 * GCC doesn't provide an appropriate macro for [u]intptr_t
240
 * For now, use __PTRDIFF_TYPE__
241
 */
242
#if defined(__PTRDIFF_TYPE__)
243
typedef signed __PTRDIFF_TYPE__ intptr_t;
244
typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
245
#else
246
/*
247
 * Fallback to hardcoded values,
248
 * should be valid on cpu's with 32bit int/32bit void*
249
 */
250
typedef signed long intptr_t;
251
typedef unsigned long uintptr_t;
252
#endif
253
 
254
/* Limits of Specified-Width Integer Types */
255
 
256
#if __int8_t_defined
257
#define INT8_MIN        -128
258
#define INT8_MAX         127
259
#define UINT8_MAX        255
260
#endif
261
 
262
#if __int_least8_t_defined
263
#define INT_LEAST8_MIN  -128
264
#define INT_LEAST8_MAX   127
265
#define UINT_LEAST8_MAX  255
266
#else
267
#error required type int_least8_t missing
268
#endif
269
 
270
#if __int16_t_defined
271
#define INT16_MIN       -32768
272
#define INT16_MAX        32767
273
#define UINT16_MAX       65535
274
#endif
275
 
276
#if __int_least16_t_defined
277
#define INT_LEAST16_MIN -32768
278
#define INT_LEAST16_MAX  32767
279
#define UINT_LEAST16_MAX 65535
280
#else
281
#error required type int_least16_t missing
282
#endif
283
 
284
#if __int32_t_defined
285
#if __have_long32
286
#define INT32_MIN        (-2147483647L-1)
287
#define INT32_MAX        2147483647L
288
#define UINT32_MAX       4294967295UL
289
#else
290
#define INT32_MIN        (-2147483647-1)
291
#define INT32_MAX        2147483647
292
#define UINT32_MAX       4294967295U
293
#endif
294
#endif
295
 
296
#if __int_least32_t_defined
297
#if __have_long32
298
#define INT_LEAST32_MIN  (-2147483647L-1)
299
#define INT_LEAST32_MAX  2147483647L
300
#define UINT_LEAST32_MAX 4294967295UL
301
#else
302
#define INT_LEAST32_MIN  (-2147483647-1)
303
#define INT_LEAST32_MAX  2147483647
304
#define UINT_LEAST32_MAX 4294967295U
305
#endif
306
#else
307
#error required type int_least32_t missing
308
#endif
309
 
310
#if __int64_t_defined
311
#if __have_long64
312
#define INT64_MIN       (-9223372036854775807L-1L)
313
#define INT64_MAX        9223372036854775807L
314
#define UINT64_MAX      18446744073709551615U
315
#elif __have_longlong64
316
#define INT64_MIN       (-9223372036854775807LL-1LL)
317
#define INT64_MAX        9223372036854775807LL
318
#define UINT64_MAX      18446744073709551615ULL
319
#endif
320
#endif
321
 
322
#if __int_least64_t_defined
323
#if __have_long64
324
#define INT_LEAST64_MIN  (-9223372036854775807L-1L)
325
#define INT_LEAST64_MAX  9223372036854775807L
326
#define UINT_LEAST64_MAX 18446744073709551615U
327
#elif __have_longlong64
328
#define INT_LEAST64_MIN  (-9223372036854775807LL-1LL)
329
#define INT_LEAST64_MAX  9223372036854775807LL
330
#define UINT_LEAST64_MAX 18446744073709551615ULL
331
#endif
332
#endif
333
 
334
#if __int_fast8_t_defined
335
#if __STDINT_EXP(INT_MAX) >= 0x7f
336
#define INT_FAST8_MIN   (-__STDINT_EXP(INT_MAX)-1)
337
#define INT_FAST8_MAX   __STDINT_EXP(INT_MAX)
338
#define UINT_FAST8_MAX  (__STDINT_EXP(INT_MAX)*2U+1U)
339
#else
340
#define INT_FAST8_MIN   INT_LEAST8_MIN
341
#define INT_FAST8_MAX   INT_LEAST8_MAX
342
#define UINT_FAST8_MAX  UINT_LEAST8_MAX
343
#endif
344
#endif
345
 
346
#if __int_fast16_t_defined
347
#if __STDINT_EXP(INT_MAX) >= 0x7fff
348
#define INT_FAST16_MIN  (-__STDINT_EXP(INT_MAX)-1)
349
#define INT_FAST16_MAX  __STDINT_EXP(INT_MAX)
350
#define UINT_FAST16_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
351
#else
352
#define INT_FAST16_MIN  INT_LEAST16_MIN
353
#define INT_FAST16_MAX  INT_LEAST16_MAX
354
#define UINT_FAST16_MAX UINT_LEAST16_MAX
355
#endif
356
#endif
357
 
358
#if __int_fast32_t_defined
359
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff
360
#define INT_FAST32_MIN  (-__STDINT_EXP(INT_MAX)-1)
361
#define INT_FAST32_MAX  __STDINT_EXP(INT_MAX)
362
#define UINT_FAST32_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
363
#else
364
#define INT_FAST32_MIN  INT_LEAST32_MIN
365
#define INT_FAST32_MAX  INT_LEAST32_MAX
366
#define UINT_FAST32_MAX UINT_LEAST32_MAX
367
#endif
368
#endif
369
 
370
#if __int_fast64_t_defined
371
#if __STDINT_EXP(INT_MAX) > 0x7fffffff
372
#define INT_FAST64_MIN  (-__STDINT_EXP(INT_MAX)-1)
373
#define INT_FAST64_MAX  __STDINT_EXP(INT_MAX)
374
#define UINT_FAST64_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
375
#else
376
#define INT_FAST64_MIN  INT_LEAST64_MIN
377
#define INT_FAST64_MAX  INT_LEAST64_MAX
378
#define UINT_FAST64_MAX UINT_LEAST64_MAX
379
#endif
380
#endif
381
 
382
#ifdef __INTMAX_MAX__
383
#define INTMAX_MAX __INTMAX_MAX__
384
#define INTMAX_MIN (-INTMAX_MAX - 1)
385
#elif defined(__INTMAX_TYPE__)
386
/* All relevant GCC versions prefer long to long long for intmax_t.  */
387
#define INTMAX_MAX INT64_MAX
388
#define INTMAX_MIN INT64_MIN
389
#endif
390
 
391
#ifdef __UINTMAX_MAX__
392
#define UINTMAX_MAX __UINTMAX_MAX__
393
#elif defined(__UINTMAX_TYPE__)
394
/* All relevant GCC versions prefer long to long long for intmax_t.  */
395
#define UINTMAX_MAX UINT64_MAX
396
#endif
397
 
398
/* This must match size_t in stddef.h, currently long unsigned int */
399
#ifdef __SIZE_MAX__
400
#define SIZE_MAX __SIZE_MAX__
401
#else
402
#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
403
#endif
404
 
405
/* This must match sig_atomic_t in <signal.h> (currently int) */
406
#define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1)
407
#define SIG_ATOMIC_MAX __STDINT_EXP(INT_MAX)
408
 
409
/* This must match ptrdiff_t  in <stddef.h> (currently long int) */
410
#ifdef __PTRDIFF_MAX__
411
#define PTRDIFF_MAX __PTRDIFF_MAX__
412
#else
413
#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)
414
#endif
415
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
416
 
417
#ifdef __WCHAR_MAX__
418
#define WCHAR_MAX __WCHAR_MAX__
419
#endif
420
#ifdef __WCHAR_MIN__
421
#define WCHAR_MIN __WCHAR_MIN__
422
#endif
423
 
424
/* wint_t is unsigned int on almost all GCC targets.  */
425
#ifdef __WINT_MAX__
426
#define WINT_MAX __WINT_MAX__
427
#else
428
#define WINT_MAX (__STDINT_EXP(INT_MAX) * 2U + 1U)
429
#endif
430
#ifdef __WINT_MIN__
431
#define WINT_MIN __WINT_MIN__
432
#else
433
#define WINT_MIN 0U
434
#endif
435
 
436
/** Macros for minimum-width integer constant expressions */
437
#define INT8_C(x)       x
438
#if __STDINT_EXP(INT_MAX) > 0x7f
439
#define UINT8_C(x)      x
440
#else
441
#define UINT8_C(x)      x##U
442
#endif
443
 
444
#define INT16_C(x)      x
445
#if __STDINT_EXP(INT_MAX) > 0x7fff
446
#define UINT16_C(x)     x
447
#else
448
#define UINT16_C(x)     x##U
449
#endif
450
 
451
#if __have_long32
452
#define INT32_C(x)      x##L
453
#define UINT32_C(x)     x##UL
454
#else
455
#define INT32_C(x)      x
456
#define UINT32_C(x)     x##U
457
#endif
458
 
459
#if __int64_t_defined
460
#if __have_longlong64
461
#define INT64_C(x)      x##LL
462
#define UINT64_C(x)     x##ULL
463
#else
464
#define INT64_C(x)      x##L
465
#define UINT64_C(x)     x##UL
466
#endif
467
#endif
468
 
469
/** Macros for greatest-width integer constant expression */
470
#if __have_longlong64
471
#define INTMAX_C(x)     x##LL
472
#define UINTMAX_C(x)    x##ULL
473
#else
474
#define INTMAX_C(x)     x##L
475
#define UINTMAX_C(x)    x##UL
476
#endif
477
 
478
 
479
#ifdef __cplusplus
480
}
481
#endif
482
 
483
#endif /* _STDINT_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.