Add chmod o-w /usr
[minix3.git] / include / stdint.h
blob0cbf33b81010e810882a02f146877ca99a7cb112
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 #include <sys/cdefs.h>
14 #ifndef _MINIX__TYPES_H
15 #include <minix/types.h>
16 #endif
17 #include <minix/sys_config.h>
19 #if (_WORD_SIZE != 2 && _WORD_SIZE != 4) || \
20 (_PTR_SIZE != _WORD_SIZE && _PTR_SIZE != 2*_WORD_SIZE)
21 #error Odd word or pointer sizes
22 #endif
24 /* Integer types of precisely the given bitsize. */
25 typedef i8_t int8_t;
26 typedef i16_t int16_t;
27 typedef i32_t int32_t;
28 #if defined(__LONG_LONG_SUPPORTED)
29 typedef long long int64_t;
30 #elif _WORD_SIZE > 2 && __L64
31 typedef i64_t int64_t;
32 #endif
34 typedef u8_t uint8_t;
35 typedef u16_t uint16_t;
36 typedef u32_t uint32_t;
37 #if defined(__LONG_LONG_SUPPORTED)
38 typedef unsigned long long uint64_t;
39 #elif _WORD_SIZE > 2 && __L64
40 typedef u64_t uint64_t;
41 #endif
43 /* Integer types of at least the given bitsize. */
44 typedef int8_t int_least8_t;
45 typedef int16_t int_least16_t;
46 typedef int32_t int_least32_t;
47 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
48 typedef int64_t int_least64_t;
49 #endif
51 typedef uint8_t uint_least8_t;
52 typedef uint16_t uint_least16_t;
53 typedef uint32_t uint_least32_t;
54 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
55 typedef uint64_t uint_least64_t;
56 #endif
58 /* Fast integer types of at least the given bitsize. */
59 #if _WORD_SIZE == 2
60 typedef int16_t int_fast8_t;
61 typedef int16_t int_fast16_t;
62 #else
63 typedef int32_t int_fast8_t;
64 typedef int32_t int_fast16_t;
65 #endif
66 typedef int32_t int_fast32_t;
67 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
68 typedef int64_t int_fast64_t;
69 #endif
71 #if _WORD_SIZE == 2
72 typedef uint16_t uint_fast8_t;
73 typedef uint16_t uint_fast16_t;
74 #else
75 typedef uint32_t uint_fast8_t;
76 typedef uint32_t uint_fast16_t;
77 #endif
78 typedef uint32_t uint_fast32_t;
79 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
80 typedef uint64_t uint_fast64_t;
81 #endif
83 /* Integer type capable of holding a pointer and the largest integer type. */
84 #if _PTR_SIZE == _WORD_SIZE
85 typedef int intptr_t;
86 typedef unsigned uintptr_t;
87 #elif _PTR_SIZE == 2*_WORD_SIZE
88 typedef long intptr_t;
89 typedef unsigned long uintptr_t;
90 #endif
92 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
93 typedef int64_t intmax_t;
94 typedef uint64_t uintmax_t;
95 #else
96 typedef long intmax_t;
97 typedef unsigned long uintmax_t;
98 #endif
100 #if !__cplusplus || defined(__STDC_LIMIT_MACROS)
101 #ifndef _LIMITS_H
102 #include <limits.h>
103 #endif
105 /* Range definitions for each of the above types conform <limits.h>. */
106 #define INT8_MIN (-INT8_MAX-1)
107 #define INT16_MIN (-INT16_MAX-1)
108 #define INT32_MIN (-INT32_MAX-1)
109 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
110 #define INT64_MIN (-INT64_MAX-1)
111 #endif
113 #define INT8_MAX 127
114 #define INT16_MAX 32767
115 #define INT32_MAX 2147483647
116 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
117 #define INT64_MAX 9223372036854775807LL
118 #endif
120 #define UINT8_MAX 255
121 #define UINT16_MAX 65535
122 #define UINT32_MAX 4294967295U
123 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
124 #define UINT64_MAX 18446744073709551615ULL
125 #endif
127 #define INT_LEAST8_MIN INT8_MIN
128 #define INT_LEAST16_MIN INT16_MIN
129 #define INT_LEAST32_MIN INT32_MIN
130 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
131 #define INT_LEAST64_MIN INT64_MIN
132 #endif
134 #define INT_LEAST8_MAX INT8_MAX
135 #define INT_LEAST16_MAX INT16_MAX
136 #define INT_LEAST32_MAX INT32_MAX
137 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
138 #define INT_LEAST64_MAX INT64_MAX
139 #endif
141 #define UINT_LEAST8_MAX UINT8_MAX
142 #define UINT_LEAST16_MAX UINT16_MAX
143 #define UINT_LEAST32_MAX UINT32_MAX
144 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
145 #define UINT_LEAST64_MAX UINT64_MAX
146 #endif
148 #define INT_FAST8_MIN (-INT_FAST8_MAX-1)
149 #define INT_FAST16_MIN (-INT_FAST16_MAX-1)
150 #define INT_FAST32_MIN INT32_MIN
151 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
152 #define INT_FAST64_MIN INT64_MIN
153 #endif
155 #if _WORD_SIZE == 2
156 #define INT_FAST8_MAX INT16_MAX
157 #define INT_FAST16_MAX INT16_MAX
158 #else
159 #define INT_FAST8_MAX INT32_MAX
160 #define INT_FAST16_MAX INT32_MAX
161 #endif
162 #define INT_FAST32_MAX INT32_MAX
163 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
164 #define INT_FAST64_MAX INT64_MAX
165 #endif
167 #if _WORD_SIZE == 2
168 #define UINT_FAST8_MAX UINT16_MAX
169 #define UINT_FAST16_MAX UINT16_MAX
170 #else
171 #define UINT_FAST8_MAX UINT32_MAX
172 #define UINT_FAST16_MAX UINT32_MAX
173 #endif
174 #define UINT_FAST32_MAX UINT32_MAX
175 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
176 #define UINT_FAST64_MAX UINT64_MAX
177 #endif
179 #if _PTR_SIZE == _WORD_SIZE
180 #define INTPTR_MIN INT_MIN
181 #define INTPTR_MAX INT_MAX
182 #define UINTPTR_MAX UINT_MAX
183 #elif _PTR_SIZE > _WORD_SIZE
184 #define INTPTR_MIN LONG_MIN
185 #define INTPTR_MAX LONG_MAX
186 #define UINTPTR_MAX ULONG_MAX
187 #endif
189 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
190 #define INTMAX_MIN INT64_MIN
191 #define INTMAX_MAX INT64_MAX
192 #define UINTMAX_MAX UINT64_MAX
193 #else
194 #define INTMAX_MIN LONG_MIN
195 #define INTMAX_MAX LONG_MAX
196 #define UINTMAX_MAX ULONG_MAX
197 #endif
199 #endif /* !__cplusplus || __STDC_LIMIT_MACROS */
201 /* Constants of the proper type. */
202 #define INT8_C(c) c
203 #define INT16_C(c) c
204 #if _WORD_SIZE == 2
205 #define INT32_C(c) __CONCAT(c,l)
206 #else
207 #define INT32_C(c) c
208 #endif
209 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
210 #define INT64_C(c) __CONCAT(c,l)
211 #endif
213 #define UINT8_C(c) __CONCAT(c,u)
214 #define UINT16_C(c) __CONCAT(c,u)
215 #if _WORD_SIZE == 2
216 #define UINT32_C(c) __CONCAT(c,lu)
217 #else
218 #define UINT32_C(c) __CONCAT(c,u)
219 #endif
220 #if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
221 #define UINT64_C(c) __CONCAT(c,lu)
222 #endif
224 #if !defined(__LONG_LONG_SUPPORTED) && !(_WORD_SIZE > 2 && __L64)
225 #define INTMAX_C(c) INT32_C(c)
226 #define UINTMAX_C(c) UINT32_C(c)
227 #else
228 #define INTMAX_C(c) INT64_C(c)
229 #define UINTMAX_C(c) UINT64_C(c)
230 #endif
232 #endif /* _STDINT_H */
235 * $PchId: stdint.h,v 1.2 2005/01/27 17:32:00 philip Exp $