make includes fix from trunk
[minix.git] / include / stdint.h
blob601dacd66f018c7db65982082caa363e0e2772d4
1 /* stdint.h - Standard sized integer types. Author: Kees J. Bot
2 * 4 Oct 2003
4 * Assumption: Long is the biggest type.
5 * Bug: C99 requires a 64 bit type, and long isn't 64 bits yet, and
6 * will never be 64 bits under 16-bits Minix.
7 * Omission: Limits like PTR_DIFF_MAX not here yet, maybe <limits.h>?
8 */
10 #ifndef _STDINT_H
11 #define _STDINT_H
13 #ifndef _MINIX__TYPES_H
14 #include <minix/types.h>
15 #endif
16 #include <minix/sys_config.h>
18 #if (_WORD_SIZE != 2 && _WORD_SIZE != 4) || \
19 (_PTR_SIZE != _WORD_SIZE && _PTR_SIZE != 2*_WORD_SIZE)
20 #error Odd word or pointer sizes
21 #endif
23 /* Integer types of precisely the given bitsize. */
24 typedef i8_t int8_t;
25 typedef i16_t int16_t;
26 typedef i32_t int32_t;
27 #if defined(__LONG_LONG_SUPPORTED)
28 typedef long long int64_t;
29 #elif _WORD_SIZE > 2 && __L64
30 typedef i64_t int64_t;
31 #endif
33 typedef u8_t uint8_t;
34 typedef u16_t uint16_t;
35 typedef u32_t uint32_t;
36 #if defined(__LONG_LONG_SUPPORTED)
37 typedef unsigned long long uint64_t;
38 #elif _WORD_SIZE > 2 && __L64
39 typedef u64_t uint64_t;
40 #endif
42 /* Integer types of at least the given bitsize. */
43 typedef int8_t int_least8_t;
44 typedef int16_t int_least16_t;
45 typedef int32_t int_least32_t;
46 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
47 typedef int64_t int_least64_t;
48 #endif
50 typedef uint8_t uint_least8_t;
51 typedef uint16_t uint_least16_t;
52 typedef uint32_t uint_least32_t;
53 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
54 typedef uint64_t uint_least64_t;
55 #endif
57 /* Fast integer types of at least the given bitsize. */
58 #if _WORD_SIZE == 2
59 typedef int16_t int_fast8_t;
60 typedef int16_t int_fast16_t;
61 #else
62 typedef int32_t int_fast8_t;
63 typedef int32_t int_fast16_t;
64 #endif
65 typedef int32_t int_fast32_t;
66 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
67 typedef int64_t int_fast64_t;
68 #endif
70 #if _WORD_SIZE == 2
71 typedef uint16_t uint_fast8_t;
72 typedef uint16_t uint_fast16_t;
73 #else
74 typedef uint32_t uint_fast8_t;
75 typedef uint32_t uint_fast16_t;
76 #endif
77 typedef uint32_t uint_fast32_t;
78 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
79 typedef uint64_t uint_fast64_t;
80 #endif
82 /* Integer type capable of holding a pointer and the largest integer type. */
83 #if _PTR_SIZE == _WORD_SIZE
84 typedef int intptr_t;
85 typedef unsigned uintptr_t;
86 #elif _PTR_SIZE == 2*_WORD_SIZE
87 typedef long intptr_t;
88 typedef unsigned long uintptr_t;
89 #endif
91 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
92 typedef int64_t intmax_t;
93 typedef uint64_t uintmax_t;
94 #else
95 typedef long intmax_t;
96 typedef unsigned long uintmax_t;
97 #endif
99 #if !__cplusplus || defined(__STDC_LIMIT_MACROS)
100 #ifndef _LIMITS_H
101 #include <limits.h>
102 #endif
104 /* Range definitions for each of the above types conform <limits.h>. */
105 #define INT8_MIN (-INT8_MAX-1)
106 #define INT16_MIN (-INT16_MAX-1)
107 #define INT32_MIN (-INT32_MAX-1)
108 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
109 #define INT64_MIN (-INT64_MAX-1)
110 #endif
112 #define INT8_MAX 127
113 #define INT16_MAX 32767
114 #define INT32_MAX 2147483647
115 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
116 #define INT64_MAX 9223372036854775807LL
117 #endif
119 #define UINT8_MAX 255
120 #define UINT16_MAX 65535
121 #define UINT32_MAX 4294967295U
122 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
123 #define UINT64_MAX 18446744073709551615ULL
124 #endif
126 #define INT_LEAST8_MIN INT8_MIN
127 #define INT_LEAST16_MIN INT16_MIN
128 #define INT_LEAST32_MIN INT32_MIN
129 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
130 #define INT_LEAST64_MIN INT64_MIN
131 #endif
133 #define INT_LEAST8_MAX INT8_MAX
134 #define INT_LEAST16_MAX INT16_MAX
135 #define INT_LEAST32_MAX INT32_MAX
136 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
137 #define INT_LEAST64_MAX INT64_MAX
138 #endif
140 #define UINT_LEAST8_MAX UINT8_MAX
141 #define UINT_LEAST16_MAX UINT16_MAX
142 #define UINT_LEAST32_MAX UINT32_MAX
143 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
144 #define UINT_LEAST64_MAX UINT64_MAX
145 #endif
147 #define INT_FAST8_MIN (-INT_FAST8_MAX-1)
148 #define INT_FAST16_MIN (-INT_FAST16_MAX-1)
149 #define INT_FAST32_MIN INT32_MIN
150 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
151 #define INT_FAST64_MIN INT64_MIN
152 #endif
154 #if _WORD_SIZE == 2
155 #define INT_FAST8_MAX INT16_MAX
156 #define INT_FAST16_MAX INT16_MAX
157 #else
158 #define INT_FAST8_MAX INT32_MAX
159 #define INT_FAST16_MAX INT32_MAX
160 #endif
161 #define INT_FAST32_MAX INT32_MAX
162 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
163 #define INT_FAST64_MAX INT64_MAX
164 #endif
166 #if _WORD_SIZE == 2
167 #define UINT_FAST8_MAX UINT16_MAX
168 #define UINT_FAST16_MAX UINT16_MAX
169 #else
170 #define UINT_FAST8_MAX UINT32_MAX
171 #define UINT_FAST16_MAX UINT32_MAX
172 #endif
173 #define UINT_FAST32_MAX UINT32_MAX
174 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
175 #define UINT_FAST64_MAX UINT64_MAX
176 #endif
178 #if _PTR_SIZE == _WORD_SIZE
179 #define INTPTR_MIN INT_MIN
180 #define INTPTR_MAX INT_MAX
181 #define UINTPTR_MAX UINT_MAX
182 #elif _PTR_SIZE > _WORD_SIZE
183 #define INTPTR_MIN LONG_MIN
184 #define INTPTR_MAX LONG_MAX
185 #define UINTPTR_MAX ULONG_MAX
186 #endif
188 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
189 #define INTMAX_MIN INT64_MIN
190 #define INTMAX_MAX INT64_MAX
191 #define UINTMAX_MAX UINT64_MAX
192 #else
193 #define INTMAX_MIN LONG_MIN
194 #define INTMAX_MAX LONG_MAX
195 #define UINTMAX_MAX ULONG_MAX
196 #endif
198 #endif /* !__cplusplus || __STDC_LIMIT_MACROS */
200 #ifndef __CONCAT
201 #define __CONCAT(x,y) x ## y
202 #endif
204 /* Constants of the proper type. */
205 #define INT8_C(c) c
206 #define INT16_C(c) c
207 #if _WORD_SIZE == 2
208 #define INT32_C(c) __CONCAT(c,l)
209 #else
210 #define INT32_C(c) c
211 #endif
212 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
213 #define INT64_C(c) __CONCAT(c,l)
214 #endif
216 #define UINT8_C(c) __CONCAT(c,u)
217 #define UINT16_C(c) __CONCAT(c,u)
218 #if _WORD_SIZE == 2
219 #define UINT32_C(c) __CONCAT(c,lu)
220 #else
221 #define UINT32_C(c) __CONCAT(c,u)
222 #endif
223 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
224 #define UINT64_C(c) __CONCAT(c,lu)
225 #endif
227 #if !defined(__LONG_LONG_SUPPORTED) && !(_WORD_SIZE > 2 && __L64)
228 #define INTMAX_C(c) INT32_C(c)
229 #define UINTMAX_C(c) UINT32_C(c)
230 #else
231 #define INTMAX_C(c) INT64_C(c)
232 #define UINTMAX_C(c) UINT64_C(c)
233 #endif
235 #endif /* _STDINT_H */
238 * $PchId: stdint.h,v 1.2 2005/01/27 17:32:00 philip Exp $