cis_config: /root/cis_interface/cis_interface/cis_interface/stdint.h Source File

cis_config

stdint.h
1 /* ISO C9x 7.18 Integer types <stdint.h>
2 * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
3 *
4 * THIS SOFTWARE IS NOT COPYRIGHTED
5 *
6 * Contributor: Danny Smith <danny_r_smith_2001@yahoo.co.nz>
7 *
8 * This source code is offered for use in the public domain. You may
9 * use, modify or distribute it freely.
10 *
11 * This code is distributed in the hope that it will be useful but
12 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
13 * DISCLAIMED. This includes but is not limited to warranties of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 *
16 * Date: 2000-12-02
17 *
18 * mwb: This was modified in the following ways:
19 *
20 * - make it compatible with Visual C++ 6 (which uses
21 * non-standard keywords and suffixes for 64-bit types)
22 * - some environments need stddef.h included (for wchar stuff?)
23 * - handle the fact that Microsoft's limits.h header defines
24 * SIZE_MAX
25 * - make corrections for SIZE_MAX, INTPTR_MIN, INTPTR_MAX, UINTPTR_MAX,
26 * PTRDIFF_MIN, PTRDIFF_MAX, SIG_ATOMIC_MIN, and SIG_ATOMIC_MAX
27 * to be 64-bit aware.
28 */
29
30
31 #ifndef _STDINT_H
32 #define _STDINT_H
33 #define __need_wint_t
34 #define __need_wchar_t
35 #include <wchar.h>
36 #include <stddef.h>
37
38 #if _MSC_VER && (_MSC_VER < 1300)
39 /* using MSVC 6 or earlier - no "long long" type, but might have _int64 type */
40 #define __STDINT_LONGLONG __int64
41 #define __STDINT_LONGLONG_SUFFIX i64
42 #else
43 #define __STDINT_LONGLONG long long
44 #define __STDINT_LONGLONG_SUFFIX LL
45 #endif
46
47 #if !defined( PASTE)
48 #define PASTE2( x, y) x##y
49 #define PASTE( x, y) PASTE2( x, y)
50 #endif /* PASTE */
51
52
53 /* 7.18.1.1 Exact-width integer types */
54 typedef signed char int8_t;
55 typedef unsigned char uint8_t;
56 typedef short int16_t;
57 typedef unsigned short uint16_t;
58 typedef int int32_t;
59 typedef unsigned uint32_t;
60 typedef __STDINT_LONGLONG int64_t;
61 typedef unsigned __STDINT_LONGLONG uint64_t;
62
63 /* 7.18.1.2 Minimum-width integer types */
64 typedef signed char int_least8_t;
65 typedef unsigned char uint_least8_t;
66 typedef short int_least16_t;
67 typedef unsigned short uint_least16_t;
68 typedef int int_least32_t;
69 typedef unsigned uint_least32_t;
70 typedef __STDINT_LONGLONG int_least64_t;
71 typedef unsigned __STDINT_LONGLONG uint_least64_t;
72
73 /* 7.18.1.3 Fastest minimum-width integer types
74 * Not actually guaranteed to be fastest for all purposes
75 * Here we use the exact-width types for 8 and 16-bit ints.
76 */
77 typedef char int_fast8_t;
78 typedef unsigned char uint_fast8_t;
79 typedef short int_fast16_t;
80 typedef unsigned short uint_fast16_t;
81 typedef int int_fast32_t;
82 typedef unsigned int uint_fast32_t;
83 typedef __STDINT_LONGLONG int_fast64_t;
84 typedef unsigned __STDINT_LONGLONG uint_fast64_t;
85
86 /* 7.18.1.4 Integer types capable of holding object pointers */
87 #ifndef _INTPTR_T_DEFINED
88 #define _INTPTR_T_DEFINED
89 #ifdef _WIN64
90 typedef __STDINT_LONGLONG intptr_t
91 #else
92 typedef int intptr_t;
93 #endif /* _WIN64 */
94 #endif /* _INTPTR_T_DEFINED */
95
96 #ifndef _UINTPTR_T_DEFINED
97 #define _UINTPTR_T_DEFINED
98 #ifdef _WIN64
99 typedef unsigned __STDINT_LONGLONG uintptr_t
100 #else
101 typedef unsigned int uintptr_t;
102 #endif /* _WIN64 */
103 #endif /* _UINTPTR_T_DEFINED */
104
105 /* 7.18.1.5 Greatest-width integer types */
106 typedef __STDINT_LONGLONG intmax_t;
107 typedef unsigned __STDINT_LONGLONG uintmax_t;
108
109 /* 7.18.2 Limits of specified-width integer types */
110 #if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS)
111
112 /* 7.18.2.1 Limits of exact-width integer types */
113 #define INT8_MIN (-128)
114 #define INT16_MIN (-32768)
115 #define INT32_MIN (-2147483647 - 1)
116 #define INT64_MIN (PASTE( -9223372036854775807, __STDINT_LONGLONG_SUFFIX) - 1)
117
118 #define INT8_MAX 127
119 #define INT16_MAX 32767
120 #define INT32_MAX 2147483647
121 #define INT64_MAX (PASTE( 9223372036854775807, __STDINT_LONGLONG_SUFFIX))
122
123 #define UINT8_MAX 0xff /* 255U */
124 #define UINT16_MAX 0xffff /* 65535U */
125 #define UINT32_MAX 0xffffffff /* 4294967295U */
126 #define UINT64_MAX (PASTE( 0xffffffffffffffffU, __STDINT_LONGLONG_SUFFIX)) /* 18446744073709551615ULL */
127
128 /* 7.18.2.2 Limits of minimum-width integer types */
129 #define INT_LEAST8_MIN INT8_MIN
130 #define INT_LEAST16_MIN INT16_MIN
131 #define INT_LEAST32_MIN INT32_MIN
132 #define INT_LEAST64_MIN INT64_MIN
133
134 #define INT_LEAST8_MAX INT8_MAX
135 #define INT_LEAST16_MAX INT16_MAX
136 #define INT_LEAST32_MAX INT32_MAX
137 #define INT_LEAST64_MAX INT64_MAX
138
139 #define UINT_LEAST8_MAX UINT8_MAX
140 #define UINT_LEAST16_MAX UINT16_MAX
141 #define UINT_LEAST32_MAX UINT32_MAX
142 #define UINT_LEAST64_MAX UINT64_MAX
143
144 /* 7.18.2.3 Limits of fastest minimum-width integer types */
145 #define INT_FAST8_MIN INT8_MIN
146 #define INT_FAST16_MIN INT16_MIN
147 #define INT_FAST32_MIN INT32_MIN
148 #define INT_FAST64_MIN INT64_MIN
149
150 #define INT_FAST8_MAX INT8_MAX
151 #define INT_FAST16_MAX INT16_MAX
152 #define INT_FAST32_MAX INT32_MAX
153 #define INT_FAST64_MAX INT64_MAX
154
155 #define UINT_FAST8_MAX UINT8_MAX
156 #define UINT_FAST16_MAX UINT16_MAX
157 #define UINT_FAST32_MAX UINT32_MAX
158 #define UINT_FAST64_MAX UINT64_MAX
159
160 /* 7.18.2.4 Limits of integer types capable of holding
161 object pointers */
162 #ifdef _WIN64
163 #define INTPTR_MIN INT64_MIN
164 #define INTPTR_MAX INT64_MAX
165 #define UINTPTR_MAX UINT64_MAX
166 #else
167 #define INTPTR_MIN INT32_MIN
168 #define INTPTR_MAX INT32_MAX
169 #define UINTPTR_MAX UINT32_MAX
170 #endif /* _WIN64 */
171
172 /* 7.18.2.5 Limits of greatest-width integer types */
173 #define INTMAX_MIN INT64_MIN
174 #define INTMAX_MAX INT64_MAX
175 #define UINTMAX_MAX UINT64_MAX
176
177 /* 7.18.3 Limits of other integer types */
178 #define PTRDIFF_MIN INTPTR_MIN
179 #define PTRDIFF_MAX INTPTR_MAX
180
181 #define SIG_ATOMIC_MIN INTPTR_MIN
182 #define SIG_ATOMIC_MAX INTPTR_MAX
183
184 /* we need to check for SIZE_MAX already defined because MS defines it in limits.h */
185 #ifndef SIZE_MAX
186 #define SIZE_MAX UINTPTR_MAX
187 #endif
188
189 #ifndef WCHAR_MIN /* also in wchar.h */
190 #define WCHAR_MIN 0
191 #define WCHAR_MAX ((wchar_t)-1) /* UINT16_MAX */
192 #endif
193
194 /*
195 * wint_t is unsigned short for compatibility with MS runtime
196 */
197 #define WINT_MIN 0
198 #define WINT_MAX ((wint_t)-1) /* UINT16_MAX */
199
200 #endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */
201
202
203 /* 7.18.4 Macros for integer constants */
204 #if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS)
205
206 /* 7.18.4.1 Macros for minimum-width integer constants
207
208 Accoding to Douglas Gwyn <gwyn@arl.mil>:
209 "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC
210 9899:1999 as initially published, the expansion was required
211 to be an integer constant of precisely matching type, which
212 is impossible to accomplish for the shorter types on most
213 platforms, because C99 provides no standard way to designate
214 an integer constant with width less than that of type int.
215 TC1 changed this to require just an integer constant
216 *expression* with *promoted* type."
217 */
218
219 #define INT8_C(val) ((int8_t) + (val))
220 #define UINT8_C(val) ((uint8_t) + (val##U))
221 #define INT16_C(val) ((int16_t) + (val))
222 #define UINT16_C(val) ((uint16_t) + (val##U))
223
224 #define INT32_C(val) val##L
225 #define UINT32_C(val) val##UL
226 #define INT64_C(val) (PASTE( val, __STDINT_LONGLONG_SUFFIX))
227 #define UINT64_C(val)(PASTE( PASTE( val, U), __STDINT_LONGLONG_SUFFIX))
228
229 /* 7.18.4.2 Macros for greatest-width integer constants */
230 #define INTMAX_C(val) INT64_C(val)
231 #define UINTMAX_C(val) UINT64_C(val)
232
233 #endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */
234
235 #endif