1 /* 2 * Copyright (c) 2008-2014 Travis Geiselbrecht 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files 6 * (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, merge, 8 * publish, distribute, sublicense, and/or sell copies of the Software, 9 * and to permit persons to whom the Software is furnished to do so, 10 * subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 #ifndef __STDINT_H 24 #define __STDINT_H 25 26 #include <limits.h> // for ULONG_MAX 27 28 typedef unsigned char uint8_t; 29 typedef unsigned short uint16_t; 30 typedef unsigned int uint32_t; 31 typedef unsigned long long uint64_t; 32 typedef signed char int8_t; 33 typedef short int16_t; 34 typedef int int32_t; 35 typedef long long int64_t; 36 37 #define INT8_MIN CHAR_MIN 38 #define INT16_MIN SHORT_MIN 39 #define INT32_MIN INT_MIN 40 41 #if defined(LLONG_MIN) 42 #define INT64_MIN LLONG_MIN 43 #elif defined(__LONG_LONG_MAX__) 44 #define INT64_MIN (-__LONG_LONG_MAX__-1LL) 45 #endif 46 47 #define INT8_MAX CHAR_MAX 48 #define INT16_MAX SHORT_MAX 49 #define INT32_MAX INT_MAX 50 51 #if defined(LLONG_MAX) 52 #define INT64_MAX LLONG_MAX 53 #elif defined(__LONG_LONG_MAX__) 54 #define INT64_MAX __LONG_LONG_MAX__ 55 #endif 56 57 #define UINT8_MAX UCHAR_MAX 58 #define UINT16_MAX USHRT_MAX 59 #define UINT32_MAX UINT_MAX 60 61 #if defined(ULLONG_MAX) 62 #define UINT64_MAX ULLONG_MAX 63 #elif defined(__LONG_LONG_MAX__) 64 #define UINT64_MAX (__LONG_LONG_MAX__*2ULL + 1ULL) 65 #endif 66 67 typedef int8_t int_least8_t; 68 typedef int16_t int_least16_t; 69 typedef int32_t int_least32_t; 70 typedef int64_t int_least64_t; 71 typedef uint8_t uint_least8_t; 72 typedef uint16_t uint_least16_t; 73 typedef uint32_t uint_least32_t; 74 typedef uint64_t uint_least64_t; 75 76 #define INT_LEAST8_MIN INT8_MIN 77 #define INT_LEAST16_MIN INT16_MIN 78 #define INT_LEAST32_MIN INT32_MIN 79 #define INT_LEAST64_MIN INT64_MIN 80 #define INT_LEAST8_MAX INT8_MAX 81 #define INT_LEAST16_MAX INT16_MAX 82 #define INT_LEAST32_MAX INT32_MAX 83 #define INT_LEAST64_MAX INT64_MAX 84 85 #define UINT_LEAST8_MAX UINT8_MAX 86 #define UINT_LEAST16_MAX UINT16_MAX 87 #define UINT_LEAST32_MAX UINT32_MAX 88 #define UINT_LEAST64_MAX UINT64_MAX 89 90 typedef int8_t int_fast8_t; 91 typedef int16_t int_fast16_t; 92 typedef int32_t int_fast32_t; 93 typedef int64_t int_fast64_t; 94 typedef uint8_t uint_fast8_t; 95 typedef uint16_t uint_fast16_t; 96 typedef uint32_t uint_fast32_t; 97 typedef uint64_t uint_fast64_t; 98 99 #define INT_FAST8_MIN INT8_MIN 100 #define INT_FAST16_MIN INT16_MIN 101 #define INT_FAST32_MIN INT32_MIN 102 #define INT_FAST64_MIN INT64_MIN 103 #define INT_FAST8_MAX INT8_MAX 104 #define INT_FAST16_MAX INT16_MAX 105 #define INT_FAST32_MAX INT32_MAX 106 #define INT_FAST64_MAX INT64_MAX 107 108 #define UINT_FAST8_MAX UINT8_MAX 109 #define UINT_FAST16_MAX UINT16_MAX 110 #define UINT_FAST32_MAX UINT32_MAX 111 #define UINT_FAST64_MAX UINT64_MAX 112 113 typedef long intptr_t; 114 typedef unsigned long uintptr_t; 115 116 #define INTPTR_MIN LONG_MIN 117 #define INTPTR_MAX LONG_MAX 118 #define UINTPTR_MAX ULONG_MAX 119 120 typedef long long intmax_t; 121 typedef unsigned long long uintmax_t; 122 123 #define INTMAX_MAX LLONG_MAX 124 #define INTMAX_MIN LLONG_MIN 125 #define UINTMAX_MAX ULLONG_MAX 126 127 #define SIZE_MAX ULONG_MAX 128 129 #define INT8_C(c) (c) 130 #define INT16_C(c) (c) 131 #define INT32_C(c) (c) 132 #define INT64_C(c) (c ## LL) 133 134 #define UINT8_C(c) (c) 135 #define UINT16_C(c) (c) 136 #define UINT32_C(c) (c ## U) 137 #define UINT64_C(c) (c ## ULL) 138 139 #define INTMAX_C(c) INT64_C(c) 140 #define UINTMAX_C(c) UINT64_C(c) 141 142 #endif 143 144