nlib
StdInt.h
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_STDINT_H_
4 #define INCLUDE_NN_NLIB_STDINT_H_
5 
6 typedef signed char int8_t;
7 typedef short int16_t; // NOLINT
8 typedef int int32_t;
9 typedef long long int64_t; // NOLINT
10 typedef unsigned char uint8_t;
11 typedef unsigned short uint16_t; // NOLINT
12 typedef unsigned int uint32_t;
13 typedef unsigned long long uint64_t; // NOLINT
14 
15 typedef signed char int_least8_t;
16 typedef short int_least16_t; // NOLINT
17 typedef int int_least32_t;
18 typedef long long int_least64_t; // NOLINT
19 typedef unsigned char uint_least8_t;
20 typedef unsigned short uint_least16_t; // NOLINT
21 typedef unsigned int uint_least32_t;
22 typedef unsigned long long uint_least64_t; // NOLINT
23 
24 typedef signed char int_fast8_t;
25 typedef short int_fast16_t; // NOLINT
26 typedef int int_fast32_t;
27 typedef long long int_fast64_t; // NOLINT
28 typedef unsigned char uint_fast8_t;
29 typedef unsigned short uint_fast16_t; // NOLINT
30 typedef unsigned int uint_fast32_t;
31 typedef unsigned long long uint_fast64_t; // NOLINT
32 
33 // NOTE:
34 // boost/cstdint.hpp may have defined them.
35 #ifndef INT8_MIN
36 #define INT8_MIN (-127 - 1)
37 #endif
38 #ifndef INT16_MIN
39 #define INT16_MIN (-32767 - 1)
40 #endif
41 #ifndef INT32_MIN
42 #define INT32_MIN (-2147483647 - 1)
43 #endif
44 #ifndef INT64_MIN
45 #define INT64_MIN (-9223372036854775807LL - 1LL)
46 #endif
47 #ifndef INT8_MAX
48 #define INT8_MAX +127
49 #endif
50 #ifndef INT16_MAX
51 #define INT16_MAX +32767
52 #endif
53 #ifndef INT32_MAX
54 #define INT32_MAX +2147483647
55 #endif
56 #ifndef INT64_MAX
57 #define INT64_MAX +9223372036854775807LL
58 #endif
59 #ifndef UINT8_MAX
60 #define UINT8_MAX 255
61 #endif
62 #ifndef UINT16_MAX
63 #define UINT16_MAX 65535
64 #endif
65 #ifndef UINT32_MAX
66 #define UINT32_MAX 4294967295U
67 #endif
68 #ifndef UINT64_MAX
69 #define UINT64_MAX 18446744073709551615ULL
70 #endif
71 
72 #ifndef INT_LEAST8_MIN
73 #define INT_LEAST8_MIN INT8_MIN
74 #endif
75 #ifndef INT_LEAST16_MIN
76 #define INT_LEAST16_MIN INT16_MIN
77 #endif
78 #ifndef INT_LEAST32_MIN
79 #define INT_LEAST32_MIN INT32_MIN
80 #endif
81 #ifndef INT_LEAST64_MIN
82 #define INT_LEAST64_MIN INT64_MIN
83 #endif
84 #ifndef INT_LEAST8_MAX
85 #define INT_LEAST8_MAX INT8_MAX
86 #endif
87 #ifndef INT_LEAST16_MAX
88 #define INT_LEAST16_MAX INT16_MAX
89 #endif
90 #ifndef INT_LEAST32_MAX
91 #define INT_LEAST32_MAX INT32_MAX
92 #endif
93 #ifndef INT_LEAST64_MAX
94 #define INT_LEAST64_MAX INT64_MAX
95 #endif
96 #ifndef UINT_LEAST8_MAX
97 #define UINT_LEAST8_MAX UINT8_MAX
98 #endif
99 #ifndef UINT_LEAST16_MAX
100 #define UINT_LEAST16_MAX UINT16_MAX
101 #endif
102 #ifndef UINT_LEAST32_MAX
103 #define UINT_LEAST32_MAX UINT32_MAX
104 #endif
105 #ifndef UINT_LEAST64_MAX
106 #define UINT_LEAST64_MAX UINT64_MAX
107 #endif
108 
109 #ifndef INT_FAST8_MIN
110 #define INT_FAST8_MIN INT8_MIN
111 #endif
112 #ifndef INT_FAST16_MIN
113 #define INT_FAST16_MIN INT32_MIN
114 #endif
115 #ifndef INT_FAST32_MIN
116 #define INT_FAST32_MIN INT32_MIN
117 #endif
118 #ifndef INT_FAST64_MIN
119 #define INT_FAST64_MIN INT64_MIN
120 #endif
121 #ifndef INT_FAST8_MAX
122 #define INT_FAST8_MAX INT8_MAX
123 #endif
124 #ifndef INT_FAST16_MAX
125 #define INT_FAST16_MAX INT32_MAX
126 #endif
127 #ifndef INT_FAST32_MAX
128 #define INT_FAST32_MAX INT32_MAX
129 #endif
130 #ifndef INT_FAST64_MAX
131 #define INT_FAST64_MAX INT64_MAX
132 #endif
133 #ifndef UINT_FAST8_MAX
134 #define UINT_FAST8_MAX UINT8_MAX
135 #endif
136 #ifndef UINT_FAST16_MAX
137 #define UINT_FAST16_MAX UINT32_MAX
138 #endif
139 #ifndef UINT_FAST32_MAX
140 #define UINT_FAST32_MAX UINT32_MAX
141 #endif
142 #ifndef UINT_FAST64_MAX
143 #define UINT_FAST64_MAX UINT64_MAX
144 #endif
145 
146 #ifndef INTMAX_MIN
147 #define INTMAX_MIN INT64_MIN
148 #endif
149 #ifndef INTMAX_MAX
150 #define INTMAX_MAX INT64_MAX
151 #endif
152 #ifndef UINTMAX_MAX
153 #define UINTMAX_MAX UINT64_MAX
154 #endif
155 
156 #ifndef SIG_ATOMIC_MIN
157 #define SIG_ATOMIC_MIN INT32_MIN
158 #endif
159 #ifndef SIG_ATOMIC_MAX
160 #define SIG_ATOMIC_MAX INT32_MAX
161 #endif
162 
163 #ifndef INT8_C
164 #define INT8_C(x) (x)
165 #endif
166 #ifndef INT16_C
167 #define INT16_C(x) (x)
168 #endif
169 #ifndef INT32_C
170 #define INT32_C(x) (x)
171 #endif
172 #ifndef INT64_C
173 #define INT64_C(x) (x##LL)
174 #endif
175 #ifndef UINT8_C
176 #define UINT8_C(x) (x)
177 #endif
178 #ifndef UINT16_C
179 #define UINT16_C(x) (x)
180 #endif
181 #ifndef UINT32_C
182 #define UINT32_C(x) (x##U)
183 #endif
184 #ifndef UINT64_C
185 #define UINT64_C(x) (x##ULL)
186 #endif
187 #ifndef INTMAX_C
188 #define INTMAX_C(x) INT64_C(x)
189 #endif
190 #ifndef UINTMAX_C
191 #define UINTMAX_C(x) UINT64_C(x)
192 #endif
193 
194 #ifndef WINT_MIN
195 #define WINT_MIN 0x0000
196 #endif
197 #ifndef WINT_MAX
198 #define WINT_MAX 0xffff
199 #endif
200 
201 #ifdef _MSC_VER
202 #ifdef _WIN64
203 typedef long long intptr_t; // NOLINT
204 typedef unsigned long long uintptr_t; // NOLINT
205 #define INTPTR_MIN INT64_MIN
206 #define INTPTR_MAX INT64_MAX
207 #define UINTPTR_MAX UINT64_MAX
208 #else
209 typedef __w64 int intptr_t;
210 typedef __w64 unsigned int uintptr_t;
211 #define INTPTR_MIN INT32_MIN
212 #define INTPTR_MAX INT32_MAX
213 #define UINTPTR_MAX UINT32_MAX
214 #endif
215 #elif defined(NLIB_64BIT)
216 typedef long long intptr_t; // NOLINT
217 typedef unsigned long long uintptr_t; // NOLINT
218 #define INTPTR_MIN INT64_MIN
219 #define INTPTR_MAX INT64_MAX
220 #define UINTPTR_MAX UINT64_MAX
221 #else
222 typedef int intptr_t;
223 typedef unsigned int uintptr_t;
224 #define INTPTR_MIN INT32_MIN
225 #define INTPTR_MAX INT32_MAX
226 #define UINTPTR_MAX UINT32_MAX
227 #endif
228 
229 typedef long long intmax_t; // NOLINT
230 typedef unsigned long long uintmax_t; // NOLINT
231 
232 #ifndef SIZE_MAX
233 #define SIZE_MAX UINTPTR_MAX
234 #endif
235 
236 #ifndef PTRDIFF_MIN
237 #define PTRDIFF_MIN INTPTR_MIN
238 #endif
239 #ifndef PTRDIFF_MAX
240 #define PTRDIFF_MAX INTPTR_MAX
241 #endif
242 
243 #endif // INCLUDE_NN_NLIB_STDINT_H_