Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6099 serge 1
/*
2
 * Copyright (c) 2004, 2005 by
3
 * Ralf Corsepius, Ulm/Germany. All rights reserved.
4
 *
5
 * Permission to use, copy, modify, and distribute this software
6
 * is freely granted, provided that this notice is preserved.
7
 */
8
 
9
#ifndef _SYS__INTSUP_H
10
#define _SYS__INTSUP_H
11
 
12
#include 
13
 
14
#if __GNUC_PREREQ (3, 2)
15
/* gcc > 3.2 implicitly defines the values we are interested */
16
#define __STDINT_EXP(x) __##x##__
17
#else
18
#define __STDINT_EXP(x) x
19
#include 
20
#endif
21
 
22
/* Check if "long long" is 64bit wide */
23
/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */
24
#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
25
  || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
26
#define __have_longlong64 1
27
#endif
28
 
29
/* Check if "long" is 64bit or 32bit wide */
30
#if __STDINT_EXP(LONG_MAX) > 0x7fffffff
31
#define __have_long64 1
32
#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
33
#define __have_long32 1
34
#endif
35
 
36
/* Determine how intptr_t and intN_t fastN_t and leastN_t are defined by gcc
37
   for this target.  This is used to determine the correct printf() constant in
38
   inttypes.h and other  constants in stdint.h.
39
   So we end up with
40
   ?(signed|unsigned) char == 0
41
   ?(signed|unsigned) short == 1
42
   ?(signed|unsigned) int == 2
43
   ?(signed|unsigned) short int == 3
44
   ?(signed|unsigned) long == 4
45
   ?(signed|unsigned) long int == 6
46
   ?(signed|unsigned) long long == 8
47
   ?(signed|unsigned) long long int == 10
48
 */
49
#pragma push_macro("signed")
50
#pragma push_macro("unsigned")
51
#pragma push_macro("char")
52
#pragma push_macro("short")
53
#pragma push_macro("__int20")
54
#pragma push_macro("int")
55
#pragma push_macro("long")
56
#undef signed
57
#undef unsigned
58
#undef char
59
#undef short
60
#undef int
61
#undef __int20
62
#undef long
63
#define signed +0
64
#define unsigned +0
65
#define char +0
66
#define short +1
67
#define __int20 +2
68
#define int +2
69
#define long +4
70
#if (__INTPTR_TYPE__ == 8 || __INTPTR_TYPE__ == 10)
71
#define _INTPTR_EQ_LONGLONG
72
#elif (__INTPTR_TYPE__ == 4 || __INTPTR_TYPE__ == 6)
73
#define _INTPTR_EQ_LONG
74
/* Note - the tests for _INTPTR_EQ_INT and _INTPTR_EQ_SHORT are currently
75
   redundant as the values are not used.  But one day they may be needed
76
   and so the tests remain.  */
77
#elif __INTPTR_TYPE__ == 2
78
#define _INTPTR_EQ_INT
79
#elif (__INTPTR_TYPE__ == 1 || __INTPTR_TYPE__ == 3)
80
#define _INTPTR_EQ_SHORT
81
#else
82
#error "Unable to determine type definition of intptr_t"
83
#endif
84
#if (__INT32_TYPE__ == 4 || __INT32_TYPE__ == 6)
85
#define _INT32_EQ_LONG
86
#elif __INT32_TYPE__ == 2
87
/* Nothing to define because int32_t is safe to print as an int. */
88
#else
89
#error "Unable to determine type definition of int32_t"
90
#endif
91
 
92
#if (__INT8_TYPE__ == 0)
93
#define __INT8 "hh"
94
#elif (__INT8_TYPE__ == 1 || __INT8_TYPE__ == 3)
95
#define __INT8 "h"
96
#elif (__INT8_TYPE__ == 2)
97
#define __INT8
98
#elif (__INT8_TYPE__ == 4 || __INT8_TYPE__ == 6)
99
#define __INT8 "l"
100
#elif (__INT8_TYPE__ == 8 || __INT8_TYPE__ == 10)
101
#define __INT8 "ll"
102
#endif
103
#if (__INT16_TYPE__ == 1 || __INT16_TYPE__ == 3)
104
#define __INT16 "h"
105
#elif (__INT16_TYPE__ == 2)
106
#define __INT16
107
#elif (__INT16_TYPE__ == 4 || __INT16_TYPE__ == 6)
108
#define __INT16 "l"
109
#elif (__INT16_TYPE__ == 8 || __INT16_TYPE__ == 10)
110
#define __INT16 "ll"
111
#endif
112
#if (__INT32_TYPE__ == 2)
113
#define __INT32
114
#elif (__INT32_TYPE__ == 4 || __INT32_TYPE__ == 6)
115
#define __INT32 "l"
116
#elif (__INT32_TYPE__ == 8 || __INT32_TYPE__ == 10)
117
#define __INT32 "ll"
118
#endif
119
#if (__INT64_TYPE__ == 2)
120
#define __INT64
121
#elif (__INT64_TYPE__ == 4 || __INT64_TYPE__ == 6)
122
#define __INT64 "l"
123
#elif (__INT64_TYPE__ == 8 || __INT64_TYPE__ == 10)
124
#define __INT64 "ll"
125
#endif
126
#if (__INT_FAST8_TYPE__ == 0)
127
#define __FAST8 "hh"
128
#elif (__INT_FAST8_TYPE__ == 1 || __INT_FAST8_TYPE__ == 3)
129
#define __FAST8 "h"
130
#elif (__INT_FAST8_TYPE__ == 2)
131
#define __FAST8
132
#elif (__INT_FAST8_TYPE__ == 4 || __INT_FAST8_TYPE__ == 6)
133
#define __FAST8 "l"
134
#elif (__INT_FAST8_TYPE__ == 8 || __INT_FAST8_TYPE__ == 10)
135
#define __FAST8 "ll"
136
#endif
137
#if (__INT_FAST16_TYPE__ == 1 || __INT_FAST16_TYPE__ == 3)
138
#define __FAST16 "h"
139
#elif (__INT_FAST16_TYPE__ == 2)
140
#define __FAST16
141
#elif (__INT_FAST16_TYPE__ == 4 || __INT_FAST16_TYPE__ == 6)
142
#define __FAST16 "l"
143
#elif (__INT_FAST16_TYPE__ == 8 || __INT_FAST16_TYPE__ == 10)
144
#define __FAST16 "ll"
145
#endif
146
#if (__INT_FAST32_TYPE__ == 2)
147
#define __FAST32
148
#elif (__INT_FAST32_TYPE__ == 4 || __INT_FAST32_TYPE__ == 6)
149
#define __FAST32 "l"
150
#elif (__INT_FAST32_TYPE__ == 8 || __INT_FAST32_TYPE__ == 10)
151
#define __FAST32 "ll"
152
#endif
153
#if (__INT_FAST64_TYPE__ == 2)
154
#define __FAST64
155
#elif (__INT_FAST64_TYPE__ == 4 || __INT_FAST64_TYPE__ == 6)
156
#define __FAST64 "l"
157
#elif (__INT_FAST64_TYPE__ == 8 || __INT_FAST64_TYPE__ == 10)
158
#define __FAST64 "ll"
159
#endif
160
 
161
#if (__INT_LEAST8_TYPE__ == 0)
162
#define __LEAST8 "hh"
163
#elif (__INT_LEAST8_TYPE__ == 1 || __INT_LEAST8_TYPE__ == 3)
164
#define __LEAST8 "h"
165
#elif (__INT_LEAST8_TYPE__ == 2)
166
#define __LEAST8
167
#elif (__INT_LEAST8_TYPE__ == 4 || __INT_LEAST8_TYPE__ == 6)
168
#define __LEAST8 "l"
169
#elif (__INT_LEAST8_TYPE__ == 8 || __INT_LEAST8_TYPE__ == 10)
170
#define __LEAST8 "ll"
171
#endif
172
#if (__INT_LEAST16_TYPE__ == 1 || __INT_LEAST16_TYPE__ == 3)
173
#define __LEAST16 "h"
174
#elif (__INT_LEAST16_TYPE__ == 2)
175
#define __LEAST16
176
#elif (__INT_LEAST16_TYPE__ == 4 || __INT_LEAST16_TYPE__ == 6)
177
#define __LEAST16 "l"
178
#elif (__INT_LEAST16_TYPE__ == 8 || __INT_LEAST16_TYPE__ == 10)
179
#define __LEAST16 "ll"
180
#endif
181
#if (__INT_LEAST32_TYPE__ == 2)
182
#define __LEAST32
183
#elif (__INT_LEAST32_TYPE__ == 4 || __INT_LEAST32_TYPE__ == 6)
184
#define __LEAST32 "l"
185
#elif (__INT_LEAST32_TYPE__ == 8 || __INT_LEAST32_TYPE__ == 10)
186
#define __LEAST32 "ll"
187
#endif
188
#if (__INT_LEAST64_TYPE__ == 2)
189
#define __LEAST64
190
#elif (__INT_LEAST64_TYPE__ == 4 || __INT_LEAST64_TYPE__ == 6)
191
#define __LEAST64 "l"
192
#elif (__INT_LEAST64_TYPE__ == 8 || __INT_LEAST64_TYPE__ == 10)
193
#define __LEAST64 "ll"
194
#endif
195
#undef signed
196
#undef unsigned
197
#undef char
198
#undef short
199
#undef int
200
#undef long
201
#pragma pop_macro("signed")
202
#pragma pop_macro("unsigned")
203
#pragma pop_macro("char")
204
#pragma pop_macro("short")
205
#pragma pop_macro("__int20")
206
#pragma pop_macro("int")
207
#pragma pop_macro("long")
208
 
209
#endif /* _SYS__INTSUP_H */