2 * Copyright (c) 2004, 2005 by
3 * Ralf Corsepius, Ulm/Germany. All rights reserved.
5 * Permission to use, copy, modify, and distribute this software
6 * is freely granted, provided that this notice is preserved.
10 #define _SYS__INTSUP_H
12 #include <sys/features.h>
14 #if __GNUC_PREREQ (3, 2)
15 /* gcc > 3.2 implicitly defines the values we are interested */
16 #define __STDINT_EXP(x) __##x##__
18 #define __STDINT_EXP(x) x
22 /* Determine how intptr_t and intN_t fastN_t and leastN_t are defined by gcc
23 for this target. This is used to determine the correct printf() constant in
24 inttypes.h and other constants in stdint.h.
26 ?(signed|unsigned) char == 0
27 ?(signed|unsigned) short == 1
28 ?(signed|unsigned) int == 2
29 ?(signed|unsigned) short int == 3
30 ?(signed|unsigned) long == 4
31 ?(signed|unsigned) long int == 6
32 ?(signed|unsigned) long long == 8
33 ?(signed|unsigned) long long int == 10
35 #pragma push_macro("signed")
36 #pragma push_macro("unsigned")
37 #pragma push_macro("char")
38 #pragma push_macro("short")
39 #pragma push_macro("__int20")
40 #pragma push_macro("__int20__")
41 #pragma push_macro("int")
42 #pragma push_macro("long")
59 #if (__INTPTR_TYPE__ == 8 || __INTPTR_TYPE__ == 10)
60 #define _INTPTR_EQ_LONGLONG
61 #elif (__INTPTR_TYPE__ == 4 || __INTPTR_TYPE__ == 6)
62 #define _INTPTR_EQ_LONG
63 /* Note - the tests for _INTPTR_EQ_INT and _INTPTR_EQ_SHORT are currently
64 redundant as the values are not used. But one day they may be needed
65 and so the tests remain. */
66 #elif __INTPTR_TYPE__ == 2
67 #define _INTPTR_EQ_INT
68 #elif (__INTPTR_TYPE__ == 1 || __INTPTR_TYPE__ == 3)
69 #define _INTPTR_EQ_SHORT
71 #error "Unable to determine type definition of intptr_t"
73 #if (__INT32_TYPE__ == 4 || __INT32_TYPE__ == 6)
74 #define _INT32_EQ_LONG
75 #elif __INT32_TYPE__ == 2
76 /* Nothing to define because int32_t is safe to print as an int. */
78 #error "Unable to determine type definition of int32_t"
81 #if (__INT8_TYPE__ == 0)
83 #elif (__INT8_TYPE__ == 1 || __INT8_TYPE__ == 3)
85 #elif (__INT8_TYPE__ == 2)
87 #elif (__INT8_TYPE__ == 4 || __INT8_TYPE__ == 6)
89 #elif (__INT8_TYPE__ == 8 || __INT8_TYPE__ == 10)
92 #if (__INT16_TYPE__ == 1 || __INT16_TYPE__ == 3)
94 #elif (__INT16_TYPE__ == 2)
96 #elif (__INT16_TYPE__ == 4 || __INT16_TYPE__ == 6)
98 #elif (__INT16_TYPE__ == 8 || __INT16_TYPE__ == 10)
101 #if (__INT32_TYPE__ == 2)
103 #elif (__INT32_TYPE__ == 4 || __INT32_TYPE__ == 6)
105 #elif (__INT32_TYPE__ == 8 || __INT32_TYPE__ == 10)
108 #if (__INT64_TYPE__ == 2)
110 #elif (__INT64_TYPE__ == 4 || __INT64_TYPE__ == 6)
112 #elif (__INT64_TYPE__ == 8 || __INT64_TYPE__ == 10)
115 #if (__INT_FAST8_TYPE__ == 0)
117 #elif (__INT_FAST8_TYPE__ == 1 || __INT_FAST8_TYPE__ == 3)
119 #elif (__INT_FAST8_TYPE__ == 2)
121 #elif (__INT_FAST8_TYPE__ == 4 || __INT_FAST8_TYPE__ == 6)
123 #elif (__INT_FAST8_TYPE__ == 8 || __INT_FAST8_TYPE__ == 10)
126 #if (__INT_FAST16_TYPE__ == 1 || __INT_FAST16_TYPE__ == 3)
128 #elif (__INT_FAST16_TYPE__ == 2)
130 #elif (__INT_FAST16_TYPE__ == 4 || __INT_FAST16_TYPE__ == 6)
132 #elif (__INT_FAST16_TYPE__ == 8 || __INT_FAST16_TYPE__ == 10)
133 #define __FAST16 "ll"
135 #if (__INT_FAST32_TYPE__ == 2)
137 #elif (__INT_FAST32_TYPE__ == 4 || __INT_FAST32_TYPE__ == 6)
139 #elif (__INT_FAST32_TYPE__ == 8 || __INT_FAST32_TYPE__ == 10)
140 #define __FAST32 "ll"
142 #if (__INT_FAST64_TYPE__ == 2)
144 #elif (__INT_FAST64_TYPE__ == 4 || __INT_FAST64_TYPE__ == 6)
146 #elif (__INT_FAST64_TYPE__ == 8 || __INT_FAST64_TYPE__ == 10)
147 #define __FAST64 "ll"
150 #if (__INT_LEAST8_TYPE__ == 0)
151 #define __LEAST8 "hh"
152 #elif (__INT_LEAST8_TYPE__ == 1 || __INT_LEAST8_TYPE__ == 3)
154 #elif (__INT_LEAST8_TYPE__ == 2)
156 #elif (__INT_LEAST8_TYPE__ == 4 || __INT_LEAST8_TYPE__ == 6)
158 #elif (__INT_LEAST8_TYPE__ == 8 || __INT_LEAST8_TYPE__ == 10)
159 #define __LEAST8 "ll"
161 #if (__INT_LEAST16_TYPE__ == 1 || __INT_LEAST16_TYPE__ == 3)
162 #define __LEAST16 "h"
163 #elif (__INT_LEAST16_TYPE__ == 2)
165 #elif (__INT_LEAST16_TYPE__ == 4 || __INT_LEAST16_TYPE__ == 6)
166 #define __LEAST16 "l"
167 #elif (__INT_LEAST16_TYPE__ == 8 || __INT_LEAST16_TYPE__ == 10)
168 #define __LEAST16 "ll"
170 #if (__INT_LEAST32_TYPE__ == 2)
172 #elif (__INT_LEAST32_TYPE__ == 4 || __INT_LEAST32_TYPE__ == 6)
173 #define __LEAST32 "l"
174 #elif (__INT_LEAST32_TYPE__ == 8 || __INT_LEAST32_TYPE__ == 10)
175 #define __LEAST32 "ll"
177 #if (__INT_LEAST64_TYPE__ == 2)
179 #elif (__INT_LEAST64_TYPE__ == 4 || __INT_LEAST64_TYPE__ == 6)
180 #define __LEAST64 "l"
181 #elif (__INT_LEAST64_TYPE__ == 8 || __INT_LEAST64_TYPE__ == 10)
182 #define __LEAST64 "ll"
190 #pragma pop_macro("signed")
191 #pragma pop_macro("unsigned")
192 #pragma pop_macro("char")
193 #pragma pop_macro("short")
194 #pragma pop_macro("__int20")
195 #pragma pop_macro("__int20__")
196 #pragma pop_macro("int")
197 #pragma pop_macro("long")
199 #endif /* _SYS__INTSUP_H */