Stefan Reinauer | 7ffc71e | 2015-03-15 19:49:11 +0100 | [diff] [blame] | 1 | #ifndef X86_STDINT_H |
| 2 | #define X86_STDINT_H |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 3 | |
Stefan Reinauer | 52fc6b1 | 2009-10-24 13:06:04 +0000 | [diff] [blame] | 4 | #if defined(__GNUC__) |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 5 | #define __HAVE_LONG_LONG__ 1 |
| 6 | #else |
| 7 | #define __HAVE_LONG_LONG__ 0 |
| 8 | #endif |
| 9 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 10 | /* Exact integral types */ |
| 11 | typedef unsigned char uint8_t; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 12 | typedef signed char int8_t; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 13 | |
| 14 | typedef unsigned short uint16_t; |
| 15 | typedef signed short int16_t; |
| 16 | |
| 17 | typedef unsigned int uint32_t; |
| 18 | typedef signed int int32_t; |
| 19 | |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 20 | #if __HAVE_LONG_LONG__ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 21 | typedef unsigned long long uint64_t; |
| 22 | typedef signed long long int64_t; |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 23 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 24 | |
| 25 | /* Small types */ |
| 26 | typedef unsigned char uint_least8_t; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 27 | typedef signed char int_least8_t; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 28 | |
| 29 | typedef unsigned short uint_least16_t; |
| 30 | typedef signed short int_least16_t; |
| 31 | |
| 32 | typedef unsigned int uint_least32_t; |
| 33 | typedef signed int int_least32_t; |
| 34 | |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 35 | #if __HAVE_LONG_LONG__ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 36 | typedef unsigned long long uint_least64_t; |
| 37 | typedef signed long long int_least64_t; |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 38 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 39 | |
| 40 | /* Fast Types */ |
| 41 | typedef unsigned char uint_fast8_t; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 42 | typedef signed char int_fast8_t; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 43 | |
| 44 | typedef unsigned int uint_fast16_t; |
| 45 | typedef signed int int_fast16_t; |
| 46 | |
| 47 | typedef unsigned int uint_fast32_t; |
| 48 | typedef signed int int_fast32_t; |
| 49 | |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 50 | #if __HAVE_LONG_LONG__ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 51 | typedef unsigned long long uint_fast64_t; |
| 52 | typedef signed long long int_fast64_t; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 53 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 54 | |
| 55 | /* Types for `void *' pointers. */ |
Stefan Reinauer | 7ffc71e | 2015-03-15 19:49:11 +0100 | [diff] [blame] | 56 | typedef long intptr_t; |
| 57 | typedef unsigned long uintptr_t; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 58 | |
| 59 | /* Largest integral types */ |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 60 | #if __HAVE_LONG_LONG__ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 61 | typedef long long int intmax_t; |
| 62 | typedef unsigned long long uintmax_t; |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 63 | #else |
| 64 | typedef long int intmax_t; |
| 65 | typedef unsigned long int uintmax_t; |
| 66 | #endif |
| 67 | |
Yinghai Lu | 21332b8 | 2007-04-06 19:49:05 +0000 | [diff] [blame] | 68 | typedef uint8_t u8; |
| 69 | typedef uint16_t u16; |
| 70 | typedef uint32_t u32; |
Stefan Reinauer | 36c8340 | 2009-03-01 10:16:01 +0000 | [diff] [blame] | 71 | #if __HAVE_LONG_LONG__ |
| 72 | typedef uint64_t u64; |
| 73 | #endif |
Stefan Reinauer | ea9a1f6 | 2012-12-18 14:25:56 -0800 | [diff] [blame] | 74 | typedef int8_t s8; |
| 75 | typedef int16_t s16; |
| 76 | typedef int32_t s32; |
| 77 | |
Alexandru Gagniuc | a583924 | 2015-01-25 20:46:55 -0600 | [diff] [blame] | 78 | typedef uint8_t bool; |
| 79 | #define true 1 |
| 80 | #define false 0 |
Yinghai Lu | 21332b8 | 2007-04-06 19:49:05 +0000 | [diff] [blame] | 81 | |
Aaron Durbin | d466d75 | 2013-03-19 12:41:29 -0500 | [diff] [blame] | 82 | #ifndef UINT32_MAX |
| 83 | #define UINT32_MAX (4294967295U) |
| 84 | #endif |
| 85 | #ifndef UINT64_MAX |
| 86 | # define UINT64_MAX (18446744073709551615ULL) |
| 87 | #endif |
Stefan Reinauer | 7ffc71e | 2015-03-15 19:49:11 +0100 | [diff] [blame] | 88 | |
| 89 | #ifdef __x86_64__ |
| 90 | |
| 91 | #ifndef UINT64_C |
| 92 | #define UINT64_C(c) c ## UL |
| 93 | #endif |
| 94 | #ifndef PRIu64 |
| 95 | #define PRIu64 "lu" |
| 96 | #endif |
| 97 | |
| 98 | #else |
| 99 | |
Aaron Durbin | d466d75 | 2013-03-19 12:41:29 -0500 | [diff] [blame] | 100 | #ifndef UINT64_C |
| 101 | #define UINT64_C(c) c ## ULL |
| 102 | #endif |
| 103 | #ifndef PRIu64 |
| 104 | #define PRIu64 "llu" |
| 105 | #endif |
| 106 | |
Stefan Reinauer | 7ffc71e | 2015-03-15 19:49:11 +0100 | [diff] [blame] | 107 | #endif |
| 108 | |
Aaron Durbin | d466d75 | 2013-03-19 12:41:29 -0500 | [diff] [blame] | 109 | |
Stefan Reinauer | 36c8340 | 2009-03-01 10:16:01 +0000 | [diff] [blame] | 110 | #undef __HAVE_LONG_LONG__ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 111 | |
Stefan Reinauer | 7ffc71e | 2015-03-15 19:49:11 +0100 | [diff] [blame] | 112 | #endif /* X86_STDINT_H */ |