source: trunk/libs/newlib/src/newlib/libc/include/sys/_intsup.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 5.5 KB
Line 
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 <sys/features.h>
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 <limits.h>
20#endif
21
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.
25   So we end up with
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
34 */
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("int")
41#pragma push_macro("long")
42#undef signed
43#undef unsigned
44#undef char
45#undef short
46#undef int
47#undef __int20
48#undef long
49#define signed +0
50#define unsigned +0
51#define char +0
52#define short +1
53#define __int20 +2
54#define int +2
55#define long +4
56#if (__INTPTR_TYPE__ == 8 || __INTPTR_TYPE__ == 10)
57#define _INTPTR_EQ_LONGLONG
58#elif (__INTPTR_TYPE__ == 4 || __INTPTR_TYPE__ == 6)
59#define _INTPTR_EQ_LONG
60/* Note - the tests for _INTPTR_EQ_INT and _INTPTR_EQ_SHORT are currently
61   redundant as the values are not used.  But one day they may be needed
62   and so the tests remain.  */
63#elif __INTPTR_TYPE__ == 2
64#define _INTPTR_EQ_INT
65#elif (__INTPTR_TYPE__ == 1 || __INTPTR_TYPE__ == 3)
66#define _INTPTR_EQ_SHORT
67#else
68#error "Unable to determine type definition of intptr_t"
69#endif
70#if (__INT32_TYPE__ == 4 || __INT32_TYPE__ == 6)
71#define _INT32_EQ_LONG
72#elif __INT32_TYPE__ == 2
73/* Nothing to define because int32_t is safe to print as an int. */
74#else
75#error "Unable to determine type definition of int32_t"
76#endif
77
78#if (__INT8_TYPE__ == 0)
79#define __INT8 "hh"
80#elif (__INT8_TYPE__ == 1 || __INT8_TYPE__ == 3)
81#define __INT8 "h"
82#elif (__INT8_TYPE__ == 2)
83#define __INT8
84#elif (__INT8_TYPE__ == 4 || __INT8_TYPE__ == 6)
85#define __INT8 "l"
86#elif (__INT8_TYPE__ == 8 || __INT8_TYPE__ == 10)
87#define __INT8 "ll"
88#endif
89#if (__INT16_TYPE__ == 1 || __INT16_TYPE__ == 3)
90#define __INT16 "h"
91#elif (__INT16_TYPE__ == 2)
92#define __INT16
93#elif (__INT16_TYPE__ == 4 || __INT16_TYPE__ == 6)
94#define __INT16 "l"
95#elif (__INT16_TYPE__ == 8 || __INT16_TYPE__ == 10)
96#define __INT16 "ll"
97#endif
98#if (__INT32_TYPE__ == 2)
99#define __INT32
100#elif (__INT32_TYPE__ == 4 || __INT32_TYPE__ == 6)
101#define __INT32 "l"
102#elif (__INT32_TYPE__ == 8 || __INT32_TYPE__ == 10)
103#define __INT32 "ll"
104#endif
105#if (__INT64_TYPE__ == 2)
106#define __INT64
107#elif (__INT64_TYPE__ == 4 || __INT64_TYPE__ == 6)
108#define __INT64 "l"
109#elif (__INT64_TYPE__ == 8 || __INT64_TYPE__ == 10)
110#define __INT64 "ll"
111#endif
112#if (__INT_FAST8_TYPE__ == 0)
113#define __FAST8 "hh"
114#elif (__INT_FAST8_TYPE__ == 1 || __INT_FAST8_TYPE__ == 3)
115#define __FAST8 "h"
116#elif (__INT_FAST8_TYPE__ == 2)
117#define __FAST8
118#elif (__INT_FAST8_TYPE__ == 4 || __INT_FAST8_TYPE__ == 6)
119#define __FAST8 "l"
120#elif (__INT_FAST8_TYPE__ == 8 || __INT_FAST8_TYPE__ == 10)
121#define __FAST8 "ll"
122#endif
123#if (__INT_FAST16_TYPE__ == 1 || __INT_FAST16_TYPE__ == 3)
124#define __FAST16 "h"
125#elif (__INT_FAST16_TYPE__ == 2)
126#define __FAST16
127#elif (__INT_FAST16_TYPE__ == 4 || __INT_FAST16_TYPE__ == 6)
128#define __FAST16 "l"
129#elif (__INT_FAST16_TYPE__ == 8 || __INT_FAST16_TYPE__ == 10)
130#define __FAST16 "ll"
131#endif
132#if (__INT_FAST32_TYPE__ == 2)
133#define __FAST32
134#elif (__INT_FAST32_TYPE__ == 4 || __INT_FAST32_TYPE__ == 6)
135#define __FAST32 "l"
136#elif (__INT_FAST32_TYPE__ == 8 || __INT_FAST32_TYPE__ == 10)
137#define __FAST32 "ll"
138#endif
139#if (__INT_FAST64_TYPE__ == 2)
140#define __FAST64
141#elif (__INT_FAST64_TYPE__ == 4 || __INT_FAST64_TYPE__ == 6)
142#define __FAST64 "l"
143#elif (__INT_FAST64_TYPE__ == 8 || __INT_FAST64_TYPE__ == 10)
144#define __FAST64 "ll"
145#endif
146
147#if (__INT_LEAST8_TYPE__ == 0)
148#define __LEAST8 "hh"
149#elif (__INT_LEAST8_TYPE__ == 1 || __INT_LEAST8_TYPE__ == 3)
150#define __LEAST8 "h"
151#elif (__INT_LEAST8_TYPE__ == 2)
152#define __LEAST8
153#elif (__INT_LEAST8_TYPE__ == 4 || __INT_LEAST8_TYPE__ == 6)
154#define __LEAST8 "l"
155#elif (__INT_LEAST8_TYPE__ == 8 || __INT_LEAST8_TYPE__ == 10)
156#define __LEAST8 "ll"
157#endif
158#if (__INT_LEAST16_TYPE__ == 1 || __INT_LEAST16_TYPE__ == 3)
159#define __LEAST16 "h"
160#elif (__INT_LEAST16_TYPE__ == 2)
161#define __LEAST16
162#elif (__INT_LEAST16_TYPE__ == 4 || __INT_LEAST16_TYPE__ == 6)
163#define __LEAST16 "l"
164#elif (__INT_LEAST16_TYPE__ == 8 || __INT_LEAST16_TYPE__ == 10)
165#define __LEAST16 "ll"
166#endif
167#if (__INT_LEAST32_TYPE__ == 2)
168#define __LEAST32
169#elif (__INT_LEAST32_TYPE__ == 4 || __INT_LEAST32_TYPE__ == 6)
170#define __LEAST32 "l"
171#elif (__INT_LEAST32_TYPE__ == 8 || __INT_LEAST32_TYPE__ == 10)
172#define __LEAST32 "ll"
173#endif
174#if (__INT_LEAST64_TYPE__ == 2)
175#define __LEAST64
176#elif (__INT_LEAST64_TYPE__ == 4 || __INT_LEAST64_TYPE__ == 6)
177#define __LEAST64 "l"
178#elif (__INT_LEAST64_TYPE__ == 8 || __INT_LEAST64_TYPE__ == 10)
179#define __LEAST64 "ll"
180#endif
181#undef signed
182#undef unsigned
183#undef char
184#undef short
185#undef int
186#undef long
187#pragma pop_macro("signed")
188#pragma pop_macro("unsigned")
189#pragma pop_macro("char")
190#pragma pop_macro("short")
191#pragma pop_macro("__int20")
192#pragma pop_macro("int")
193#pragma pop_macro("long")
194
195#endif /* _SYS__INTSUP_H */
Note: See TracBrowser for help on using the repository browser.