88
89
#include <sys/types.h>
91
#define __EXTENSIONS__ 1 /* We want some extension */
93
92
#if defined(HAVE_STDINT_H)
94
/* Need to include this _before_ stdlib, so that all defines are right */
95
/* We are mixing C and C++, so we wan the C limit macros in the C++ too */
96
/* Enable some extra C99 extensions */
98
#define __STDC_FORMAT_MACROS
95
#error "You must have stdint!"
98
#if defined(HAVE_INTTYPES_H)
99
99
#include <inttypes.h>
101
We include the following because currently Google #$@#$ Protocol Buffers possibly break stdint defines.
102
Or I am wrong, very possible, and hope someone finds the solution.
104
Taken from /usr/include/stdint.h
107
/* 7.18.2 Limits of specified-width integer types:
108
* These #defines specify the minimum and maximum limits
109
* of each of the types declared above.
113
#if (!defined(INT16_MAX))
114
/* 7.18.2.1 Limits of exact-width integer types */
116
#define INT16_MAX 32767
117
#define INT32_MAX 2147483647
118
#define INT64_MAX 9223372036854775807
120
#define INT8_MIN -128
121
#define INT16_MIN -32768
124
Note: the literal "most negative int" cannot be written in C --
125
the rules in the standard (section 6.4.4.1 in C99) will give it
126
an unsigned type, so INT32_MIN (and the most negative member of
127
any larger signed type) must be written via a constant expression.
129
#define INT32_MIN (-INT32_MAX-1)
130
#define INT64_MIN (-INT64_MAX-1)
132
#define UINT8_MAX 255
133
#define UINT16_MAX 65535
134
#define UINT32_MAX 4294967295U
135
#define UINT64_MAX 18446744073709551615U
137
/* 7.18.2.2 Limits of minimum-width integer types */
138
#define INT_LEAST8_MIN INT8_MIN
139
#define INT_LEAST16_MIN INT16_MIN
140
#define INT_LEAST32_MIN INT32_MIN
141
#define INT_LEAST64_MIN INT64_MIN
143
#define INT_LEAST8_MAX INT8_MAX
144
#define INT_LEAST16_MAX INT16_MAX
145
#define INT_LEAST32_MAX INT32_MAX
146
#define INT_LEAST64_MAX INT64_MAX
148
#define UINT_LEAST8_MAX UINT8_MAX
149
#define UINT_LEAST16_MAX UINT16_MAX
150
#define UINT_LEAST32_MAX UINT32_MAX
151
#define UINT_LEAST64_MAX UINT64_MAX
153
/* 7.18.2.3 Limits of fastest minimum-width integer types */
154
#define INT_FAST8_MIN INT8_MIN
155
#define INT_FAST16_MIN INT16_MIN
156
#define INT_FAST32_MIN INT32_MIN
157
#define INT_FAST64_MIN INT64_MIN
159
#define INT_FAST8_MAX INT8_MAX
160
#define INT_FAST16_MAX INT16_MAX
161
#define INT_FAST32_MAX INT32_MAX
162
#define INT_FAST64_MAX INT64_MAX
164
#define UINT_FAST8_MAX UINT8_MAX
165
#define UINT_FAST16_MAX UINT16_MAX
166
#define UINT_FAST32_MAX UINT32_MAX
167
#define UINT_FAST64_MAX UINT64_MAX
169
/* 7.18.2.4 Limits of integer types capable of holding object pointers */
172
#define INTPTR_MIN INT64_MIN
173
#define INTPTR_MAX INT64_MAX
175
#define INTPTR_MIN INT32_MIN
176
#define INTPTR_MAX INT32_MAX
180
#define UINTPTR_MAX UINT64_MAX
182
#define UINTPTR_MAX UINT32_MAX
185
/* 7.18.2.5 Limits of greatest-width integer types */
186
#define INTMAX_MIN INT64_MIN
187
#define INTMAX_MAX INT64_MAX
189
#define UINTMAX_MAX UINT64_MAX
193
#define PTRDIFF_MIN INT64_MIN
194
#define PTRDIFF_MAX INT64_MAX
196
#define PTRDIFF_MIN INT32_MIN
197
#define PTRDIFF_MAX INT32_MAX
200
/* We have no sig_atomic_t yet, so no SIG_ATOMIC_{MIN,MAX}.
201
Should end up being {-127,127} or {0,255} ... or bigger.
202
My bet would be on one of {U}INT32_{MIN,MAX}. */
205
#define SIZE_MAX UINT64_MAX
207
#define SIZE_MAX UINT32_MAX
211
# ifdef __WCHAR_MAX__
212
# define WCHAR_MAX __WCHAR_MAX__
214
# define WCHAR_MAX 0x7fffffff
218
/* WCHAR_MIN should be 0 if wchar_t is an unsigned type and
219
(-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately,
220
it turns out that -fshort-wchar changes the signedness of
223
# if WCHAR_MAX == 0xffff
226
# define WCHAR_MIN (-WCHAR_MAX-1)
230
#define WINT_MIN INT32_MIN
231
#define WINT_MAX INT32_MAX
233
#define SIG_ATOMIC_MIN INT32_MIN
234
#define SIG_ATOMIC_MAX INT32_MAX
238
101
#error "You must have inttypes!"