flexint.h revision 250125
1228072Sbapt/* flex integer type definitions */
2228072Sbapt
3228072Sbapt#ifndef FLEXINT_H
4228072Sbapt#define FLEXINT_H
5228072Sbapt
6228072Sbapt/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
7228072Sbapt
8228072Sbapt#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
9228072Sbapt
10228072Sbapt/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
11228072Sbapt * if you want the limit (max/min) macros for int types.
12228072Sbapt */
13228072Sbapt#ifndef __STDC_LIMIT_MACROS
14228072Sbapt#define __STDC_LIMIT_MACROS 1
15228072Sbapt#endif
16228072Sbapt
17228072Sbapt#include <inttypes.h>
18228072Sbapttypedef int8_t flex_int8_t;
19228072Sbapttypedef uint8_t flex_uint8_t;
20228072Sbapttypedef int16_t flex_int16_t;
21228072Sbapttypedef uint16_t flex_uint16_t;
22228072Sbapttypedef int32_t flex_int32_t;
23228072Sbapttypedef uint32_t flex_uint32_t;
24228072Sbapt#else
25228072Sbapttypedef signed char flex_int8_t;
26228072Sbapttypedef short int flex_int16_t;
27228072Sbapttypedef int flex_int32_t;
28228072Sbapttypedef unsigned char flex_uint8_t;
29228072Sbapttypedef unsigned short int flex_uint16_t;
30228072Sbapttypedef unsigned int flex_uint32_t;
31228072Sbapt
32228072Sbapt/* Limits of integral types. */
33228072Sbapt#ifndef INT8_MIN
34228072Sbapt#define INT8_MIN               (-128)
35228072Sbapt#endif
36228072Sbapt#ifndef INT16_MIN
37228072Sbapt#define INT16_MIN              (-32767-1)
38228072Sbapt#endif
39228072Sbapt#ifndef INT32_MIN
40228072Sbapt#define INT32_MIN              (-2147483647-1)
41228072Sbapt#endif
42228072Sbapt#ifndef INT8_MAX
43228072Sbapt#define INT8_MAX               (127)
44228072Sbapt#endif
45228072Sbapt#ifndef INT16_MAX
46228072Sbapt#define INT16_MAX              (32767)
47228072Sbapt#endif
48228072Sbapt#ifndef INT32_MAX
49228072Sbapt#define INT32_MAX              (2147483647)
50228072Sbapt#endif
51228072Sbapt#ifndef UINT8_MAX
52228072Sbapt#define UINT8_MAX              (255U)
53228072Sbapt#endif
54228072Sbapt#ifndef UINT16_MAX
55228072Sbapt#define UINT16_MAX             (65535U)
56228072Sbapt#endif
57228072Sbapt#ifndef UINT32_MAX
58228072Sbapt#define UINT32_MAX             (4294967295U)
59228072Sbapt#endif
60228072Sbapt
61250125Sjkim#endif /* ! C99 */
62228072Sbapt
63228072Sbapt#endif /* ! FLEXINT_H */
64