3 * Copyright 2012, 2013 MinGW.org project
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
24 /* Created by Danny Smith <danny_r_smith_2001@yahoo.co.nz> */
27 #pragma GCC system_header
30 /* ISO C9x 7.18 Integer types <stdint.h>
31 * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
35 #define __need_wchar_t
38 /* 7.18.1.1 Exact-width integer types */
39 typedef signed char int8_t;
40 typedef unsigned char uint8_t;
41 typedef short int16_t;
42 typedef unsigned short uint16_t;
44 typedef unsigned uint32_t;
45 typedef long long int64_t;
46 typedef unsigned long long uint64_t;
48 /* 7.18.1.2 Minimum-width integer types */
49 typedef signed char int_least8_t;
50 typedef unsigned char uint_least8_t;
51 typedef short int_least16_t;
52 typedef unsigned short uint_least16_t;
53 typedef int int_least32_t;
54 typedef unsigned uint_least32_t;
55 typedef long long int_least64_t;
56 typedef unsigned long long uint_least64_t;
58 /* 7.18.1.3 Fastest minimum-width integer types
59 * Not actually guaranteed to be fastest for all purposes
60 * Here we use the exact-width types for 8 and 16-bit ints.
62 typedef signed char int_fast8_t;
63 typedef unsigned char uint_fast8_t;
64 typedef short int_fast16_t;
65 typedef unsigned short uint_fast16_t;
66 typedef int int_fast32_t;
67 typedef unsigned int uint_fast32_t;
68 typedef long long int_fast64_t;
69 typedef unsigned long long uint_fast64_t;
71 /* 7.18.1.4 Integer types capable of holding object pointers */
73 #ifndef _INTPTR_T_DEFINED
74 #define _INTPTR_T_DEFINED
76 typedef __int64 intptr_t;
82 #ifndef _UINTPTR_T_DEFINED
83 #define _UINTPTR_T_DEFINED
85 typedef unsigned __int64 uintptr_t;
87 typedef unsigned int uintptr_t;
91 /* 7.18.1.5 Greatest-width integer types */
92 typedef long long intmax_t;
93 typedef unsigned long long uintmax_t;
95 /* 7.18.2 Limits of specified-width integer types */
96 #if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS)
98 /* 7.18.2.1 Limits of exact-width integer types */
99 #define INT8_MIN (-128)
100 #define INT16_MIN (-32768)
101 #define INT32_MIN (-2147483647 - 1)
102 #define INT64_MIN (-9223372036854775807LL - 1)
105 #define INT16_MAX 32767
106 #define INT32_MAX 2147483647
107 #define INT64_MAX 9223372036854775807LL
109 #define UINT8_MAX 0xff /* 255U */
110 #define UINT16_MAX 0xffff /* 65535U */
111 #define UINT32_MAX 0xffffffff /* 4294967295U */
112 #define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
114 /* 7.18.2.2 Limits of minimum-width integer types */
115 #define INT_LEAST8_MIN INT8_MIN
116 #define INT_LEAST16_MIN INT16_MIN
117 #define INT_LEAST32_MIN INT32_MIN
118 #define INT_LEAST64_MIN INT64_MIN
120 #define INT_LEAST8_MAX INT8_MAX
121 #define INT_LEAST16_MAX INT16_MAX
122 #define INT_LEAST32_MAX INT32_MAX
123 #define INT_LEAST64_MAX INT64_MAX
125 #define UINT_LEAST8_MAX UINT8_MAX
126 #define UINT_LEAST16_MAX UINT16_MAX
127 #define UINT_LEAST32_MAX UINT32_MAX
128 #define UINT_LEAST64_MAX UINT64_MAX
130 /* 7.18.2.3 Limits of fastest minimum-width integer types */
131 #define INT_FAST8_MIN INT8_MIN
132 #define INT_FAST16_MIN INT16_MIN
133 #define INT_FAST32_MIN INT32_MIN
134 #define INT_FAST64_MIN INT64_MIN
136 #define INT_FAST8_MAX INT8_MAX
137 #define INT_FAST16_MAX INT16_MAX
138 #define INT_FAST32_MAX INT32_MAX
139 #define INT_FAST64_MAX INT64_MAX
141 #define UINT_FAST8_MAX UINT8_MAX
142 #define UINT_FAST16_MAX UINT16_MAX
143 #define UINT_FAST32_MAX UINT32_MAX
144 #define UINT_FAST64_MAX UINT64_MAX
146 /* 7.18.2.4 Limits of integer types capable of holding
149 #define INTPTR_MIN INT64_MIN
150 #define INTPTR_MAX INT64_MAX
151 #define UINTPTR_MAX UINT64_MAX
153 #define INTPTR_MIN INT32_MIN
154 #define INTPTR_MAX INT32_MAX
155 #define UINTPTR_MAX UINT32_MAX
158 /* 7.18.2.5 Limits of greatest-width integer types */
159 #define INTMAX_MIN INT64_MIN
160 #define INTMAX_MAX INT64_MAX
161 #define UINTMAX_MAX UINT64_MAX
163 /* 7.18.3 Limits of other integer types */
164 #define PTRDIFF_MIN INTPTR_MIN
165 #define PTRDIFF_MAX INTPTR_MAX
167 #define SIG_ATOMIC_MIN INTPTR_MIN
168 #define SIG_ATOMIC_MAX INTPTR_MAX
170 #define SIZE_MAX UINTPTR_MAX
172 #ifndef WCHAR_MIN /* also in wchar.h */
174 #define WCHAR_MAX 0xffff /* UINT16_MAX */
178 * wint_t is unsigned short for compatibility with MS runtime
181 #define WINT_MAX 0xffff /* UINT16_MAX */
183 #endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */
186 /* 7.18.4 Macros for integer constants */
187 #if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS)
189 /* 7.18.4.1 Macros for minimum-width integer constants
191 Accoding to Douglas Gwyn <gwyn@arl.mil>:
192 "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC
193 9899:1999 as initially published, the expansion was required
194 to be an integer constant of precisely matching type, which
195 is impossible to accomplish for the shorter types on most
196 platforms, because C99 provides no standard way to designate
197 an integer constant with width less than that of type int.
198 TC1 changed this to require just an integer constant
199 *expression* with *promoted* type."
202 #define INT8_C(val) val
203 #define UINT8_C(val) val
204 #define INT16_C(val) val
205 #define UINT16_C(val) val
207 #define INT32_C(val) val
208 #define UINT32_C(val) val##U
209 #define INT64_C(val) val##LL
210 #define UINT64_C(val) val##ULL
212 /* 7.18.4.2 Macros for greatest-width integer constants */
213 #define INTMAX_C(val) INT64_C(val)
214 #define UINTMAX_C(val) UINT64_C(val)
216 #endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */