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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [include/] [stdint.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_STDINT_H
2
#define CYGONCE_STDINT_H
3
/*============================================================================
4
//
5
//      stdint.h
6
//
7
//      ISO C9x  7.18  Integer types
8
//
9
// ===========================================================================
10
// ####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 2009 Free Software Foundation, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later
18
// version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT
21
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
28
//
29
// As a special exception, if other files instantiate templates or use
30
// macros or inline functions from this file, or you compile this file
31
// and link it with other works to produce a work based on this file,
32
// this file does not by itself cause the resulting work to be covered by
33
// the GNU General Public License. However the source code for this file
34
// must still be made available in accordance with section (3) of the GNU
35
// General Public License v2.
36
//
37
// This exception does not invalidate any other reasons why a work based
38
// on this file might be covered by the GNU General Public License.
39
// -------------------------------------------
40
// ####ECOSGPLCOPYRIGHTEND####
41
// ===========================================================================
42
//============================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):     Uwe Kindler
46
// Contributors:
47
// Date:          2009-07-22
48
// Purpose:
49
// Description:   eCos stdint.h header file for ISO C9x  7.18  Integer types
50
// Usage:         #include <stdint.h>
51
//
52
//####DESCRIPTIONEND####
53
//
54
//============================================================================
55
*/
56
 
57
// use the types defined in cyg_type.h to define the standard data types
58
#include <cyg/infra/cyg_type.h>
59
 
60
 
61
/*
62
 * Copyright (c) 2004, 2005 by
63
 * Ralf Corsepius, Ulm/Germany. All rights reserved.
64
 *
65
 * Permission to use, copy, modify, and distribute this software
66
 * is freely granted, provided that this notice is preserved.
67
 */
68
#ifdef __cplusplus
69
extern "C" {
70
#endif
71
 
72
#if defined(__GNUC__) && \
73
  ( (__GNUC__ >= 4) || \
74
    ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2) ) )
75
/* gcc > 3.2 implicitly defines the values we are interested */
76
#define __STDINT_EXP(x) __##x##__
77
#else
78
#define __STDINT_EXP(x) x
79
#include <limits.h>
80
#endif
81
 
82
/* Check if "long long" is 64bit wide */
83
/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */
84
#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
85
  || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
86
#define __have_longlong64 1
87
#endif
88
 
89
/* Check if "long" is 64bit or 32bit wide */
90
#if __STDINT_EXP(LONG_MAX) > 0x7fffffff
91
#define __have_long64 1
92
#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
93
#define __have_long32 1
94
#endif
95
 
96
#if __STDINT_EXP(SCHAR_MAX) == 0x7f
97
typedef signed char int8_t ;
98
typedef unsigned char uint8_t ;
99
#define __int8_t_defined 1
100
#endif
101
 
102
#if __int8_t_defined
103
typedef signed char int_least8_t;
104
typedef unsigned char uint_least8_t;
105
#define __int_least8_t_defined 1
106
#endif
107
 
108
#if __STDINT_EXP(SHRT_MAX) == 0x7fff
109
typedef signed short int16_t;
110
typedef unsigned short uint16_t;
111
#define __int16_t_defined 1
112
#elif __STDINT_EXP(INT_MAX) == 0x7fff
113
typedef signed int int16_t;
114
typedef unsigned int uint16_t;
115
#define __int16_t_defined 1
116
#elif __STDINT_EXP(SCHAR_MAX) == 0x7fff
117
typedef signed char int16_t;
118
typedef unsigned char uint16_t;
119
#define __int16_t_defined 1
120
#endif
121
 
122
#if __int16_t_defined
123
typedef int16_t         int_least16_t;
124
typedef uint16_t        uint_least16_t;
125
#define __int_least16_t_defined 1
126
 
127
#if !__int_least8_t_defined
128
typedef int16_t            int_least8_t;
129
typedef uint16_t        uint_least8_t;
130
#define __int_least8_t_defined 1
131
#endif
132
#endif
133
 
134
// if long and int are both 32 bit then we prefer int for int32_t and uint32_t
135
// instead of long
136
#if __STDINT_EXP(INT_MAX) == 0x7fffffffL
137
typedef signed int int32_t;
138
typedef unsigned int uint32_t;
139
#define __int32_t_defined 1
140
#elif __have_long32
141
typedef signed long int32_t;
142
typedef unsigned long uint32_t;
143
#define __int32_t_defined 1
144
#elif __STDINT_EXP(SHRT_MAX) == 0x7fffffffL
145
typedef signed short int32_t;
146
typedef unsigned short uint32_t;
147
#define __int32_t_defined 1
148
#elif __STDINT_EXP(SCHAR_MAX) == 0x7fffffffL
149
typedef signed char int32_t;
150
typedef unsigned char uint32_t;
151
#define __int32_t_defined 1
152
#endif
153
 
154
#if __int32_t_defined
155
typedef int32_t         int_least32_t;
156
typedef uint32_t        uint_least32_t;
157
#define __int_least32_t_defined 1
158
 
159
#if !__int_least8_t_defined
160
typedef int32_t            int_least8_t;
161
typedef uint32_t        uint_least8_t;
162
#define __int_least8_t_defined 1
163
#endif
164
 
165
#if !__int_least16_t_defined
166
typedef int32_t            int_least16_t;
167
typedef uint32_t        uint_least16_t;
168
#define __int_least16_t_defined 1
169
#endif
170
#endif
171
 
172
#if __have_long64
173
typedef signed long int64_t;
174
typedef unsigned long uint64_t;
175
#define __int64_t_defined 1
176
#elif __have_longlong64
177
typedef signed long long int64_t;
178
typedef unsigned long long uint64_t;
179
#define __int64_t_defined 1
180
#elif  __STDINT_EXP(INT_MAX) > 0x7fffffff
181
typedef signed int int64_t;
182
typedef unsigned int uint64_t;
183
#define __int64_t_defined 1
184
#endif
185
 
186
#if __int64_t_defined
187
typedef int64_t         int_least64_t;
188
typedef uint64_t        uint_least64_t;
189
#define __int_least64_t_defined 1
190
 
191
#if !__int_least8_t_defined
192
typedef int64_t            int_least8_t;
193
typedef uint64_t        uint_least8_t;
194
#define __int_least8_t_defined 1
195
#endif
196
 
197
#if !__int_least16_t_defined
198
typedef int64_t            int_least16_t;
199
typedef uint64_t        uint_least16_t;
200
#define __int_least16_t_defined 1
201
#endif
202
 
203
#if !__int_least32_t_defined
204
typedef int64_t            int_least32_t;
205
typedef uint64_t        uint_least32_t;
206
#define __int_least32_t_defined 1
207
#endif
208
#endif
209
 
210
/*
211
 * Fastest minimum-width integer types
212
 *
213
 * Assume int to be the fastest type for all types with a width
214
 * less than __INT_MAX__ rsp. INT_MAX
215
 */
216
#if 0 // we use the cyg_halcount types here instead of the newlib implementation
217
#if __STDINT_EXP(INT_MAX) >= 0x7f
218
  typedef signed int int_fast8_t;
219
  typedef unsigned int uint_fast8_t;
220
#define __int_fast8_t_defined 1
221
#endif
222
 
223
#if __STDINT_EXP(INT_MAX) >= 0x7fff
224
  typedef signed int int_fast16_t;
225
  typedef unsigned int uint_fast16_t;
226
#define __int_fast16_t_defined 1
227
#endif
228
 
229
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff
230
  typedef signed int int_fast32_t;
231
  typedef unsigned int uint_fast32_t;
232
#define __int_fast32_t_defined 1
233
#endif
234
 
235
#if __STDINT_EXP(INT_MAX) > 0x7fffffff
236
  typedef signed int int_fast64_t;
237
  typedef unsigned int uint_fast64_t;
238
#define __int_fast64_t_defined 1
239
#endif
240
 
241
 
242
/*
243
 * Fall back to [u]int_least<N>_t for [u]int_fast<N>_t types
244
 * not having been defined, yet.
245
 * Leave undefined, if [u]int_least<N>_t should not be available.
246
 */
247
#if !__int_fast8_t_defined
248
#if __int_least8_t_defined
249
  typedef int_least8_t int_fast8_t;
250
  typedef uint_least8_t uint_fast8_t;
251
#define __int_fast8_t_defined 1
252
#endif
253
#endif
254
 
255
#if !__int_fast16_t_defined
256
#if __int_least16_t_defined
257
  typedef int_least16_t int_fast16_t;
258
  typedef uint_least16_t uint_fast16_t;
259
#define __int_fast16_t_defined 1
260
#endif
261
#endif
262
 
263
#if !__int_fast32_t_defined
264
#if __int_least32_t_defined
265
  typedef int_least32_t int_fast32_t;
266
  typedef uint_least32_t uint_fast32_t;
267
#define __int_fast32_t_defined 1
268
#endif
269
#endif
270
 
271
#if !__int_fast64_t_defined
272
#if __int_least64_t_defined
273
  typedef int_least64_t int_fast64_t;
274
  typedef uint_least64_t uint_fast64_t;
275
#define __int_fast64_t_defined 1
276
#endif
277
#endif
278
#endif // 0
279
 
280
/*  7.18.1.3  Fastest minimum-width integer types
281
 *  Not actually guaranteed to be fastest for all purposes
282
 *  Here we use the cyg_halcount types from <cyg/infra/cyg_type.h>
283
 */
284
typedef          cyg_halcount8   int_fast8_t;
285
typedef unsigned cyg_halcount8   uint_fast8_t;
286
typedef          cyg_halcount16  int_fast16_t;
287
typedef unsigned cyg_halcount16  uint_fast16_t;
288
typedef          cyg_halcount32  int_fast32_t;
289
typedef unsigned cyg_halcount32  uint_fast32_t;
290
typedef          cyg_halcount64  int_fast64_t;
291
typedef unsigned cyg_halcount64  uint_fast64_t;
292
 
293
 
294
/* Greatest-width integer types */
295
/* Modern GCCs provide __INTMAX_TYPE__ */
296
#if defined(__INTMAX_TYPE__)
297
  typedef __INTMAX_TYPE__ intmax_t;
298
#elif __have_longlong64
299
  typedef signed long long intmax_t;
300
#else
301
  typedef signed long intmax_t;
302
#endif
303
 
304
/* Modern GCCs provide __UINTMAX_TYPE__ */
305
#if defined(__UINTMAX_TYPE__)
306
  typedef __UINTMAX_TYPE__ uintmax_t;
307
#elif __have_longlong64
308
  typedef unsigned long long uintmax_t;
309
#else
310
  typedef unsigned long uintmax_t;
311
#endif
312
 
313
/*
314
 * GCC doesn't provide an appropriate macro for [u]intptr_t
315
 * For now, use __PTRDIFF_TYPE__
316
 */
317
#if defined(__PTRDIFF_TYPE__)
318
typedef signed __PTRDIFF_TYPE__ intptr_t;
319
typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
320
#define INTPTR_MAX PTRDIFF_MAX
321
#define INTPTR_MIN PTRDIFF_MIN
322
#ifdef __UINTPTR_MAX__
323
#define UINTPTR_MAX __UINTPTR_MAX__
324
#else
325
#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1)
326
#endif
327
#else
328
/*
329
 * Fallback to hardcoded values,
330
 * should be valid on cpu's with 32bit int/32bit void*
331
 */
332
typedef signed long intptr_t;
333
typedef unsigned long uintptr_t;
334
#define INTPTR_MAX __STDINT_EXP(LONG_MAX)
335
#define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1)
336
#define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
337
#endif
338
 
339
/* Limits of Specified-Width Integer Types */
340
 
341
#if __int8_t_defined
342
#define INT8_MIN        -128
343
#define INT8_MAX         127
344
#define UINT8_MAX        255
345
#endif
346
 
347
#if __int_least8_t_defined
348
#define INT_LEAST8_MIN  -128
349
#define INT_LEAST8_MAX   127
350
#define UINT_LEAST8_MAX  255
351
#else
352
#error required type int_least8_t missing
353
#endif
354
 
355
#if __int16_t_defined
356
#define INT16_MIN       -32768
357
#define INT16_MAX        32767
358
#define UINT16_MAX       65535
359
#endif
360
 
361
#if __int_least16_t_defined
362
#define INT_LEAST16_MIN -32768
363
#define INT_LEAST16_MAX  32767
364
#define UINT_LEAST16_MAX 65535
365
#else
366
#error required type int_least16_t missing
367
#endif
368
 
369
#if __int32_t_defined
370
#if __have_long32
371
#define INT32_MIN        (-2147483647L-1)
372
#define INT32_MAX        2147483647L
373
#define UINT32_MAX       4294967295UL
374
#else
375
#define INT32_MIN        (-2147483647-1)
376
#define INT32_MAX        2147483647
377
#define UINT32_MAX       4294967295U
378
#endif
379
#endif
380
 
381
#if __int_least32_t_defined
382
#if __have_long32
383
#define INT_LEAST32_MIN  (-2147483647L-1)
384
#define INT_LEAST32_MAX  2147483647L
385
#define UINT_LEAST32_MAX 4294967295UL
386
#else
387
#define INT_LEAST32_MIN  (-2147483647-1)
388
#define INT_LEAST32_MAX  2147483647
389
#define UINT_LEAST32_MAX 4294967295U
390
#endif
391
#else
392
#error required type int_least32_t missing
393
#endif
394
 
395
#if __int64_t_defined
396
#if __have_long64
397
#define INT64_MIN       (-9223372036854775807L-1L)
398
#define INT64_MAX        9223372036854775807L
399
#define UINT64_MAX      18446744073709551615U
400
#elif __have_longlong64
401
#define INT64_MIN       (-9223372036854775807LL-1LL)
402
#define INT64_MAX        9223372036854775807LL
403
#define UINT64_MAX      18446744073709551615ULL
404
#endif
405
#endif
406
 
407
#if __int_least64_t_defined
408
#if __have_long64
409
#define INT_LEAST64_MIN  (-9223372036854775807L-1L)
410
#define INT_LEAST64_MAX  9223372036854775807L
411
#define UINT_LEAST64_MAX 18446744073709551615U
412
#elif __have_longlong64
413
#define INT_LEAST64_MIN  (-9223372036854775807LL-1LL)
414
#define INT_LEAST64_MAX  9223372036854775807LL
415
#define UINT_LEAST64_MAX 18446744073709551615ULL
416
#endif
417
#endif
418
 
419
#if __int_fast8_t_defined
420
#if __STDINT_EXP(INT_MAX) >= 0x7f
421
#define INT_FAST8_MIN   (-__STDINT_EXP(INT_MAX)-1)
422
#define INT_FAST8_MAX   __STDINT_EXP(INT_MAX)
423
#define UINT_FAST8_MAX  (__STDINT_EXP(INT_MAX)*2U+1U)
424
#else
425
#define INT_FAST8_MIN   INT_LEAST8_MIN
426
#define INT_FAST8_MAX   INT_LEAST8_MAX
427
#define UINT_FAST8_MAX  UINT_LEAST8_MAX
428
#endif
429
#endif
430
 
431
#if __int_fast16_t_defined
432
#if __STDINT_EXP(INT_MAX) >= 0x7fff
433
#define INT_FAST16_MIN  (-__STDINT_EXP(INT_MAX)-1)
434
#define INT_FAST16_MAX  __STDINT_EXP(INT_MAX)
435
#define UINT_FAST16_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
436
#else
437
#define INT_FAST16_MIN  INT_LEAST16_MIN
438
#define INT_FAST16_MAX  INT_LEAST16_MAX
439
#define UINT_FAST16_MAX UINT_LEAST16_MAX
440
#endif
441
#endif
442
 
443
#if __int_fast32_t_defined
444
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff
445
#define INT_FAST32_MIN  (-__STDINT_EXP(INT_MAX)-1)
446
#define INT_FAST32_MAX  __STDINT_EXP(INT_MAX)
447
#define UINT_FAST32_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
448
#else
449
#define INT_FAST32_MIN  INT_LEAST32_MIN
450
#define INT_FAST32_MAX  INT_LEAST32_MAX
451
#define UINT_FAST32_MAX UINT_LEAST32_MAX
452
#endif
453
#endif
454
 
455
#if __int_fast64_t_defined
456
#if __STDINT_EXP(INT_MAX) > 0x7fffffff
457
#define INT_FAST64_MIN  (-__STDINT_EXP(INT_MAX)-1)
458
#define INT_FAST64_MAX  __STDINT_EXP(INT_MAX)
459
#define UINT_FAST64_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
460
#else
461
#define INT_FAST64_MIN  INT_LEAST64_MIN
462
#define INT_FAST64_MAX  INT_LEAST64_MAX
463
#define UINT_FAST64_MAX UINT_LEAST64_MAX
464
#endif
465
#endif
466
 
467
#ifdef __INTMAX_MAX__
468
#define INTMAX_MAX __INTMAX_MAX__
469
#define INTMAX_MIN (-INTMAX_MAX - 1)
470
#elif defined(__INTMAX_TYPE__)
471
/* All relevant GCC versions prefer long to long long for intmax_t.  */
472
#define INTMAX_MAX INT64_MAX
473
#define INTMAX_MIN INT64_MIN
474
#endif
475
 
476
#ifdef __UINTMAX_MAX__
477
#define UINTMAX_MAX __UINTMAX_MAX__
478
#elif defined(__UINTMAX_TYPE__)
479
/* All relevant GCC versions prefer long to long long for intmax_t.  */
480
#define UINTMAX_MAX UINT64_MAX
481
#endif
482
 
483
/* This must match size_t in stddef.h, currently long unsigned int */
484
#ifdef __SIZE_MAX__
485
#define SIZE_MAX __SIZE_MAX__
486
#else
487
#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
488
#endif
489
 
490
/* This must match sig_atomic_t in <signal.h> (currently int) */
491
#define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1)
492
#define SIG_ATOMIC_MAX __STDINT_EXP(INT_MAX)
493
 
494
/* This must match ptrdiff_t  in <stddef.h> (currently long int) */
495
#ifdef __PTRDIFF_MAX__
496
#define PTRDIFF_MAX __PTRDIFF_MAX__
497
#else
498
#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)
499
#endif
500
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
501
 
502
#ifdef __WCHAR_MAX__
503
#define WCHAR_MAX __WCHAR_MAX__
504
#endif
505
#ifdef __WCHAR_MIN__
506
#define WCHAR_MIN __WCHAR_MIN__
507
#endif
508
 
509
/* wint_t is unsigned int on almost all GCC targets.  */
510
#ifdef __WINT_MAX__
511
#define WINT_MAX __WINT_MAX__
512
#else
513
#define WINT_MAX (__STDINT_EXP(INT_MAX) * 2U + 1U)
514
#endif
515
#ifdef __WINT_MIN__
516
#define WINT_MIN __WINT_MIN__
517
#else
518
#define WINT_MIN 0U
519
#endif
520
 
521
/** Macros for minimum-width integer constant expressions */
522
#define INT8_C(x)       x
523
#if __STDINT_EXP(INT_MAX) > 0x7f
524
#define UINT8_C(x)      x
525
#else
526
#define UINT8_C(x)      x##U
527
#endif
528
 
529
#define INT16_C(x)      x
530
#if __STDINT_EXP(INT_MAX) > 0x7fff
531
#define UINT16_C(x)     x
532
#else
533
#define UINT16_C(x)     x##U
534
#endif
535
 
536
#if __have_long32
537
#define INT32_C(x)      x##L
538
#define UINT32_C(x)     x##UL
539
#else
540
#define INT32_C(x)      x
541
#define UINT32_C(x)     x##U
542
#endif
543
 
544
#if __int64_t_defined
545
#if __have_long64
546
#define INT64_C(x)      x##L
547
#define UINT64_C(x)     x##UL
548
#else
549
#define INT64_C(x)      x##LL
550
#define UINT64_C(x)     x##ULL
551
#endif
552
#endif
553
 
554
/** Macros for greatest-width integer constant expression */
555
#if __have_long64
556
#define INTMAX_C(x)     x##L
557
#define UINTMAX_C(x)    x##UL
558
#else
559
#define INTMAX_C(x)     x##LL
560
#define UINTMAX_C(x)    x##ULL
561
#endif
562
 
563
 
564
#ifdef __cplusplus
565
}
566
#endif
567
 
568
 
569
#endif // CYGONCE_STDINT_H

powered by: WebSVN 2.1.0

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