1 /* stdint.h - Standard sized integer types. Author: Kees J. Bot
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>?
13 #ifndef _MINIX__TYPES_H
14 #include <sys/types.h>
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
23 /* Integer types of precisely the given bitsize. */
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;
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;
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 _WORD_SIZE > 2 && __L64
47 typedef int64_t int_least64_t;
50 typedef uint8_t uint_least8_t;
51 typedef uint16_t uint_least16_t;
52 typedef uint32_t uint_least32_t;
53 #if _WORD_SIZE > 2 && __L64
54 typedef uint64_t uint_least64_t;
57 /* Fast integer types of at least the given bitsize. */
59 typedef int16_t int_fast8_t;
60 typedef int16_t int_fast16_t;
62 typedef int32_t int_fast8_t;
63 typedef int32_t int_fast16_t;
65 typedef int32_t int_fast32_t;
66 #if _WORD_SIZE > 2 && __L64
67 typedef int64_t int_fast64_t;
71 typedef uint16_t uint_fast8_t;
72 typedef uint16_t uint_fast16_t;
74 typedef uint32_t uint_fast8_t;
75 typedef uint32_t uint_fast16_t;
77 typedef uint32_t uint_fast32_t;
78 #if _WORD_SIZE > 2 && __L64
79 typedef uint64_t uint_fast64_t;
82 /* Integer type capable of holding a pointer and the largest integer type. */
83 #if _PTR_SIZE == _WORD_SIZE
85 typedef unsigned uintptr_t;
86 #elif _PTR_SIZE == 2*_WORD_SIZE
87 typedef long intptr_t;
88 typedef unsigned long uintptr_t;
90 typedef long intmax_t;
91 typedef unsigned long uintmax_t;
93 #if !__cplusplus || defined(__STDC_LIMIT_MACROS)
98 /* Range definitions for each of the above types conform <limits.h>. */
99 #define INT8_MIN (-INT8_MAX-1)
100 #define INT16_MIN (-INT16_MAX-1)
101 #define INT32_MIN (-INT32_MAX-1)
102 #if _WORD_SIZE > 2 && __L64
103 #define INT64_MIN (-INT64_MAX-1)
107 #define INT16_MAX 32767
108 #define INT32_MAX 2147483647
109 #if _WORD_SIZE > 2 && __L64
110 #define INT64_MAX 9223372036854775807
113 #define UINT8_MAX 255
114 #define UINT16_MAX 65535
115 #define UINT32_MAX 4294967295
116 #if _WORD_SIZE > 2 && __L64
117 #define UINT64_MAX 18446744073709551615
120 #define INT_LEAST8_MIN INT8_MIN
121 #define INT_LEAST16_MIN INT16_MIN
122 #define INT_LEAST32_MIN INT32_MIN
123 #if _WORD_SIZE > 2 && __L64
124 #define INT_LEAST64_MIN INT64_MIN
127 #define INT_LEAST8_MAX INT8_MAX
128 #define INT_LEAST16_MAX INT16_MAX
129 #define INT_LEAST32_MAX INT32_MAX
130 #if _WORD_SIZE > 2 && __L64
131 #define INT_LEAST64_MAX INT64_MAX
134 #define UINT_LEAST8_MAX UINT8_MAX
135 #define UINT_LEAST16_MAX UINT16_MAX
136 #define UINT_LEAST32_MAX UINT32_MAX
137 #if _WORD_SIZE > 2 && __L64
138 #define UINT_LEAST64_MAX UINT64_MAX
141 #define INT_FAST8_MIN (-INT_FAST8_MAX-1)
142 #define INT_FAST16_MIN (-INT_FAST16_MAX-1)
143 #define INT_FAST32_MIN INT32_MIN
144 #if _WORD_SIZE > 2 && __L64
145 #define INT_FAST64_MIN INT64_MIN
149 #define INT_FAST8_MAX INT16_MAX
150 #define INT_FAST16_MAX INT16_MAX
152 #define INT_FAST8_MAX INT32_MAX
153 #define INT_FAST16_MAX INT32_MAX
155 #define INT_FAST32_MAX INT32_MAX
156 #if _WORD_SIZE > 2 && __L64
157 #define INT_FAST64_MAX INT64_MAX
161 #define UINT_FAST8_MAX UINT16_MAX
162 #define UINT_FAST16_MAX UINT16_MAX
164 #define UINT_FAST8_MAX UINT32_MAX
165 #define UINT_FAST16_MAX UINT32_MAX
167 #define UINT_FAST32_MAX UINT32_MAX
168 #if _WORD_SIZE > 2 && __L64
169 #define UINT_FAST64_MAX UINT64_MAX
172 #if _PTR_SIZE == _WORD_SIZE
173 #define INTPTR_MIN INT_MIN
174 #define INTPTR_MAX INT_MAX
175 #define UINTPTR_MAX UINT_MAX
176 #elif _PTR_SIZE > _WORD_SIZE
177 #define INTPTR_MIN LONG_MIN
178 #define INTPTR_MAX LONG_MAX
179 #define UINTPTR_MAX ULONG_MAX
181 #define INTMAX_MIN LONG_MIN
182 #define INTMAX_MAX LONG_MAX
183 #define UINTMAX_MAX ULONG_MAX
185 #endif /* !__cplusplus || __STDC_LIMIT_MACROS */
188 #define __CONCAT(x,y) x ## y
191 /* Constants of the proper type. */
195 #define INT32_C(c) __CONCAT(c,l)
199 #if _WORD_SIZE > 2 && __L64
200 #define INT64_C(c) __CONCAT(c,l)
203 #define UINT8_C(c) __CONCAT(c,u)
204 #define UINT16_C(c) __CONCAT(c,u)
206 #define UINT32_C(c) __CONCAT(c,lu)
208 #define UINT32_C(c) __CONCAT(c,u)
210 #if _WORD_SIZE > 2 && __L64
211 #define UINT64_C(c) __CONCAT(c,lu)
214 #if _WORD_SIZE == 2 || !__L64
215 #define INTMAX_C(c) INT32_C(c)
216 #define UINTMAX_C(c) UINT32_C(c)
218 #define INTMAX_C(c) INT64_C(c)
219 #define UINTMAX_C(c) UINT64_C(c)
222 #endif /* _STDINT_H */
225 * $PchId: stdint.h,v 1.2 2005/01/27 17:32:00 philip Exp $