source: rtems/cpukit/libcsupport/include/stdint.h @ d2b4fcd

4.104.114.84.95
Last change on this file since d2b4fcd was f10a999, checked in by Ralf Corsepius <ralf.corsepius@…>, on Nov 20, 2004 at 2:57:19 AM

2004-11-20 Ralf Corsepius <ralf.corsepiu@…>

  • libcsupport/include/stdint.h: Move mal-placed comment.
  • Property mode set to 100644
File size: 6.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 2004.
3 *  Ralf Corsepius, Ulm/Germany.
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12/** @file  stdint.h
13 * Newlib specific stdint.h
14 *
15 * @todo - Add fast<N>_t types.
16 * @todo - Add support for wint_t types.
17 */
18
19#ifndef _STDINT_H
20#define _STDINT_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#if defined(__GNUC__) && (__GNUC__ >= 3 ) \
27  && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 )
28#define __EXP(x) __##x##__
29#else
30#define __EXP(x) x
31#include <limits.h>
32#endif
33
34#if __EXP(SCHAR_MAX) == 0x7f
35typedef signed char int8_t ;
36typedef unsigned char uint8_t ;
37#define __int8_t_defined 1
38#endif
39
40#if __int8_t_defined
41typedef signed char int_least8_t;
42typedef unsigned char uint_least8_t;
43#define __int_least8_t_defined 1
44#endif
45
46#if __EXP(SHRT_MAX) == 0x7fff
47typedef signed short int16_t;
48typedef unsigned short uint16_t;
49#define __int16_t_defined 1
50#elif __EXP(INT_MAX) == 0x7fff
51typedef signed int int16_t;
52typedef unsigned int uint16_t;
53#define __int16_t_defined 1
54#elif __EXP(SCHAR_MAX) == 0x7fff
55typedef signed char int16_t;
56typedef unsigned char uint16_t;
57#define __int16_t_defined 1
58#endif
59
60#if __int16_t_defined
61typedef int16_t         int_least16_t;
62typedef uint16_t        uint_least16_t;
63#define __int_least16_t_defined 1
64
65#ifndef __int_least8_t_defined
66typedef int16_t         int_least8_t;
67typedef uint16_t        uint_least8_t;
68#define __int_least8_t_defined 1
69#endif
70#endif
71
72#if __EXP(INT_MAX) == 0x7fffffffL
73typedef signed int int32_t;
74typedef unsigned int uint32_t;
75#define __int32_t_defined 1
76#elif __EXP(LONG_MAX) == 0x7fffffffL
77typedef signed long int32_t;
78typedef unsigned long uint32_t;
79#define __int32_t_defined 1
80#define __rtems_long32 1
81#elif __EXP(SHRT_MAX) == 0x7fffffffL
82typedef signed short int32_t;
83typedef unsigned short uint32_t;
84#define __int32_t_defined 1
85#elif __EXP(SCHAR_MAX) == 0x7fffffffL
86typedef signed char int32_t;
87typedef unsigned char uint32_t;
88#define __int32_t_defined 1
89#endif
90
91#if __int32_t_defined
92typedef int32_t         int_least32_t;
93typedef uint32_t        uint_least32_t;
94#define __int_least32_t_defined 1
95
96#ifndef __int_least8_t_defined
97typedef int32_t         int_least8_t;
98typedef uint32_t        uint_least8_t;
99#define __int_least8_t_defined 1
100#endif
101
102#ifndef __int_least16_t_defined
103typedef int32_t         int_least16_t;
104typedef uint32_t        uint_least16_t;
105#define __int_least16_t_defined 1
106#endif
107#endif
108
109#if __EXP(LONG_MAX) > 0x7fffffff
110typedef signed long int64_t;
111typedef unsigned long uint64_t;
112#define __int64_t_defined 1
113#define __rtems_long64 1
114#elif  defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff)
115typedef signed long long int64_t;
116typedef unsigned long long uint64_t;
117#define __int64_t_defined 1
118#define __rtems_longlong64 1
119#elif  defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff)
120typedef signed long long int64_t;
121typedef unsigned long long uint64_t;
122#define __int64_t_defined 1
123#define __rtems_longlong64 1
124#elif  __EXP(INT_MAX) > 0x7fffffff
125typedef signed int int64_t;
126typedef unsigned int uint64_t;
127#define __int64_t_defined 1
128#endif
129
130#if __int64_t_defined
131typedef int64_t         int_least64_t;
132typedef uint64_t        uint_least64_t;
133#define __int_least64_t_defined 1
134
135#ifndef __int_least8_t_defined
136typedef int64_t         int_least8_t;
137typedef uint64_t        uint_least8_t;
138#define __int_least8_t_defined 1
139#endif
140
141#ifndef __int_least16_t_defined
142typedef int64_t         int_least16_t;
143typedef uint64_t        uint_least16_t;
144#define __int_least16_t_defined 1
145#endif
146
147#ifndef __int_least32_t_defined
148typedef int64_t         int_least32_t;
149typedef uint64_t        uint_least32_t;
150#define __int_least32_t_defined 1
151#endif
152#endif
153
154#if __rtems_longlong64
155typedef signed long long intmax_t;
156typedef unsigned long long uintmax_t;
157#else
158typedef signed long intmax_t;
159typedef unsigned long uintmax_t;
160#endif
161
162typedef signed long intptr_t;
163typedef unsigned long uintptr_t;
164
165/* Limits of Specified-Width Integer Types */
166
167#if __int8_t_defined
168#define INT8_MIN        -128
169#define INT8_MAX         127
170#define UINT8_MAX        255
171#endif
172
173#if __int_least8_t_defined
174#define INTLEAST8_MIN   -128
175#define INTLEAST8_MAX    127
176#define UINTLEAST8_MAX   255
177#else
178#error required type int_least8_t missing
179#endif
180
181#if __int16_t_defined
182#define INT16_MIN       -32768
183#define INT16_MAX        32767
184#define UINT16_MAX       65535
185#endif
186
187#if __int_least16_t_defined
188#define INTLEAST16_MIN  -32768
189#define INTLEAST16_MAX   32767
190#define UINTLEAST16_MAX  65535
191#else
192#error required type int_least16_t missing
193#endif
194
195#if __int32_t_defined
196#define INT32_MIN       -2147483648
197#define INT32_MAX        2147483647
198#define UINT32_MAX       4294967295
199#endif
200
201#if __int_least32_t_defined
202#define INTLEAST32_MIN  -2147483648
203#define INTLEAST32_MAX   2147483647
204#define UINTLEAST32_MAX  4294967295
205#else
206#error required type int_least32_t missing
207#endif
208
209#if __int64_t_defined
210#define INT64_MIN       -9223372036854775808
211#define INT64_MAX        9223372036854775807
212#define UINT64_MAX      18446744073709551615
213#endif
214
215#if __int_least64_t_defined
216#define INTLEAST64_MIN  -9223372036854775808
217#define INTLEAST64_MAX   9223372036854775807
218#define UINTLEAST64_MAX 18446744073709551615
219#endif
220
221/* This must match size_t in stddef.h, currently long unsigned int */
222#define SIZE_MIN (-__EXP(LONG_MAX) - 1L)
223#define SIZE_MAX __EXP(LONG_MAX)
224
225/* This must match sig_atomic_t in <signal.h> (currently int) */
226#define SIG_ATOMIC_MIN (-__EXP(INT_MAX) - 1)
227#define SIG_ATOMIC_MAX __EXP(INT_MAX)
228
229/* This must match ptrdiff_t  in <stddef.h> (currently long int) */
230#define PTRDIFF_MIN (-__EXP(LONG_MAX) - 1L)
231#define PTHDIFF_MAX __EXT(LONG_MAX)
232
233#undef __EXP
234
235/** Macros for minimum-width integer constant expressions */
236#define INT8_C(x)       x
237#define UINT8_C(x)      x##U
238
239#define INT16_C(x)      x
240#define UINT16_C(x)     x##U
241
242#if __rtems_long32
243#define INT32_C(x)      x##L
244#define UINT32_C(x)     x##UL
245#else
246#define INT32_C(x)      x
247#define UINT32_C(x)     x##U
248#endif
249
250#if __int64_t_defined
251#if __rtems_longlong64
252#define INT64_C(x)      x##LL
253#define UINT64_C(x)     x##ULL
254#else
255#define INT64_C(x)      x##L
256#define UINT64_C(x)     x##UL
257#endif
258#endif
259
260/** Macros for greatest-width integer constant expression */
261#if __rtems_longlong64
262#define INTMAX_C(x)     x##LL
263#define UINTMAX_C(x)    x##ULL
264#else
265#define INTMAX_C(x)     x##L
266#define UINTMAX_C(x)    x##UL
267#endif
268
269
270#ifdef __cplusplus
271}
272#endif
273
274#endif /* _STDINT_H */
Note: See TracBrowser for help on using the repository browser.