|
| 1 | +/* |
| 2 | +** Command & Conquer Generals Zero Hour(tm) |
| 3 | +** Copyright 2025 TheSuperHackers |
| 4 | +** |
| 5 | +** This program is free software: you can redistribute it and/or modify |
| 6 | +** it under the terms of the GNU General Public License as published by |
| 7 | +** the Free Software Foundation, either version 3 of the License, or |
| 8 | +** (at your option) any later version. |
| 9 | +** |
| 10 | +** This program is distributed in the hope that it will be useful, |
| 11 | +** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +** GNU General Public License for more details. |
| 14 | +** |
| 15 | +** You should have received a copy of the GNU General Public License |
| 16 | +** along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | +*/ |
| 18 | + |
| 19 | +#pragma once |
| 20 | + |
| 21 | +#if defined(USING_STLPORT) || (defined(_MSC_VER) && _MSC_VER < 1300) |
| 22 | +/* 7.18.1.4 Integer types capable of holding object pointers */ |
| 23 | +#ifdef _WIN64 |
| 24 | + typedef __int64 intptr_t; |
| 25 | + typedef unsigned __int64 uintptr_t; |
| 26 | +#else |
| 27 | + typedef int intptr_t; |
| 28 | + typedef unsigned int uintptr_t; |
| 29 | +#endif |
| 30 | + |
| 31 | +/* 7.18.1.1 Exact-width integer types */ |
| 32 | +typedef signed char int8_t; |
| 33 | +typedef unsigned char uint8_t; |
| 34 | +typedef short int16_t; |
| 35 | +typedef unsigned short uint16_t; |
| 36 | +typedef int int32_t; |
| 37 | +typedef unsigned int uint32_t; |
| 38 | +typedef __int64 int64_t; |
| 39 | +typedef unsigned __int64 uint64_t; |
| 40 | +/* 7.18.1.2 Minimum-width integer types */ |
| 41 | +typedef signed char int_least8_t; |
| 42 | +typedef unsigned char uint_least8_t; |
| 43 | +typedef short int_least16_t; |
| 44 | +typedef unsigned short uint_least16_t; |
| 45 | +typedef int int_least32_t; |
| 46 | +typedef unsigned uint_least32_t; |
| 47 | +typedef __int64 int_least64_t; |
| 48 | +typedef unsigned __int64 uint_least64_t; |
| 49 | +/* 7.18.1.3 Fastest minimum-width integer types |
| 50 | + * Not actually guaranteed to be fastest for all purposes |
| 51 | + * Here we use the exact-width types for 8 and 16-bit ints. |
| 52 | + */ |
| 53 | +typedef signed char int_fast8_t; |
| 54 | +typedef unsigned char uint_fast8_t; |
| 55 | +typedef short int_fast16_t; |
| 56 | +typedef unsigned short uint_fast16_t; |
| 57 | +typedef int int_fast32_t; |
| 58 | +typedef unsigned int uint_fast32_t; |
| 59 | +typedef __int64 int_fast64_t; |
| 60 | +typedef unsigned __int64 uint_fast64_t; |
| 61 | +/* 7.18.1.5 Greatest-width integer types */ |
| 62 | +typedef __int64 intmax_t; |
| 63 | +typedef unsigned __int64 uintmax_t; |
| 64 | +/* 7.18.2 Limits of specified-width integer types */ |
| 65 | +/* 7.18.2.1 Limits of exact-width integer types */ |
| 66 | +#define INT8_MIN (-128) |
| 67 | +#define INT16_MIN (-32768) |
| 68 | +#define INT32_MIN (-2147483647 - 1) |
| 69 | +#define INT64_MIN (-9223372036854775807i64 - 1) |
| 70 | +#define INT8_MAX 127 |
| 71 | +#define INT16_MAX 32767 |
| 72 | +#define INT32_MAX 2147483647 |
| 73 | +#define INT64_MAX 9223372036854775807i64 |
| 74 | +#define UINT8_MAX 255 |
| 75 | +#define UINT16_MAX 65535 |
| 76 | +#define UINT32_MAX 0xffffffffU /* 4294967295U */ |
| 77 | +#define UINT64_MAX 0xffffffffffffffffUi64 /* 18446744073709551615ULL */ |
| 78 | +/* 7.18.2.2 Limits of minimum-width integer types */ |
| 79 | +#define INT_LEAST8_MIN INT8_MIN |
| 80 | +#define INT_LEAST16_MIN INT16_MIN |
| 81 | +#define INT_LEAST32_MIN INT32_MIN |
| 82 | +#define INT_LEAST64_MIN INT64_MIN |
| 83 | +#define INT_LEAST8_MAX INT8_MAX |
| 84 | +#define INT_LEAST16_MAX INT16_MAX |
| 85 | +#define INT_LEAST32_MAX INT32_MAX |
| 86 | +#define INT_LEAST64_MAX INT64_MAX |
| 87 | +#define UINT_LEAST8_MAX UINT8_MAX |
| 88 | +#define UINT_LEAST16_MAX UINT16_MAX |
| 89 | +#define UINT_LEAST32_MAX UINT32_MAX |
| 90 | +#define UINT_LEAST64_MAX UINT64_MAX |
| 91 | +/* 7.18.2.3 Limits of fastest minimum-width integer types */ |
| 92 | +#define INT_FAST8_MIN INT8_MIN |
| 93 | +#define INT_FAST16_MIN INT16_MIN |
| 94 | +#define INT_FAST32_MIN INT32_MIN |
| 95 | +#define INT_FAST64_MIN INT64_MIN |
| 96 | +#define INT_FAST8_MAX INT8_MAX |
| 97 | +#define INT_FAST16_MAX INT16_MAX |
| 98 | +#define INT_FAST32_MAX INT32_MAX |
| 99 | +#define INT_FAST64_MAX INT64_MAX |
| 100 | +#define UINT_FAST8_MAX UINT8_MAX |
| 101 | +#define UINT_FAST16_MAX UINT16_MAX |
| 102 | +#define UINT_FAST32_MAX UINT32_MAX |
| 103 | +#define UINT_FAST64_MAX UINT64_MAX |
| 104 | +/* 7.18.2.4 Limits of integer types capable of holding |
| 105 | + object pointers */ |
| 106 | +#ifdef _WIN64 |
| 107 | +#define INTPTR_MIN INT64_MIN |
| 108 | +#define INTPTR_MAX INT64_MAX |
| 109 | +#define UINTPTR_MAX UINT64_MAX |
| 110 | +#else |
| 111 | +#define INTPTR_MIN INT32_MIN |
| 112 | +#define INTPTR_MAX INT32_MAX |
| 113 | +#define UINTPTR_MAX UINT32_MAX |
| 114 | +#endif |
| 115 | +/* 7.18.2.5 Limits of greatest-width integer types */ |
| 116 | +#define INTMAX_MIN INT64_MIN |
| 117 | +#define INTMAX_MAX INT64_MAX |
| 118 | +#define UINTMAX_MAX UINT64_MAX |
| 119 | +/* 7.18.3 Limits of other integer types */ |
| 120 | +#ifdef _WIN64 |
| 121 | +#define PTRDIFF_MIN INT64_MIN |
| 122 | +#define PTRDIFF_MAX INT64_MAX |
| 123 | +#else |
| 124 | +#define PTRDIFF_MIN INT32_MIN |
| 125 | +#define PTRDIFF_MAX INT32_MAX |
| 126 | +#endif |
| 127 | +#define SIG_ATOMIC_MIN INT32_MIN |
| 128 | +#define SIG_ATOMIC_MAX INT32_MAX |
| 129 | +#ifndef SIZE_MAX |
| 130 | +#ifdef _WIN64 |
| 131 | +#define SIZE_MAX UINT64_MAX |
| 132 | +#else |
| 133 | +#define SIZE_MAX UINT32_MAX |
| 134 | +#endif |
| 135 | +#endif |
| 136 | + |
| 137 | +#define WCHAR_MIN 0 |
| 138 | +#define WCHAR_MAX ((wchar_t)-1) |
| 139 | +/* |
| 140 | + * wint_t is unsigned short for compatibility with MS runtime |
| 141 | + */ |
| 142 | +#define WINT_MIN 0U |
| 143 | +#define WINT_MAX 0xffffU |
| 144 | +/* 7.18.4 Macros for integer constants */ |
| 145 | +/* 7.18.4.1 Macros for minimum-width integer constants |
| 146 | + Accoding to Douglas Gwyn <gwyn@arl.mil>: |
| 147 | + "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC |
| 148 | + 9899:1999 as initially published, the expansion was required |
| 149 | + to be an integer constant of precisely matching type, which |
| 150 | + is impossible to accomplish for the shorter types on most |
| 151 | + platforms, because C99 provides no standard way to designate |
| 152 | + an integer constant with width less than that of type int. |
| 153 | + TC1 changed this to require just an integer constant |
| 154 | + *expression* with *promoted* type." |
| 155 | + The trick used here is from Clive D W Feather. |
| 156 | +*/ |
| 157 | +#define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val)) |
| 158 | +#define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val)) |
| 159 | +#define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val)) |
| 160 | +/* The 'trick' doesn't work in C89 for long long because, without |
| 161 | + suffix, (val) will be evaluated as int, not intmax_t */ |
| 162 | +#define INT64_C(val) val##i64 |
| 163 | +#define UINT8_C(val) (val) |
| 164 | +#define UINT16_C(val) (val) |
| 165 | +#define UINT32_C(val) (val##i32) |
| 166 | +#define UINT64_C(val) val##ui64 |
| 167 | +/* 7.18.4.2 Macros for greatest-width integer constants */ |
| 168 | +#define INTMAX_C(val) val##i64 |
| 169 | +#define UINTMAX_C(val) val##ui64 |
| 170 | + |
| 171 | +#else |
| 172 | + |
| 173 | +#include <cstdint> |
| 174 | + |
| 175 | +#endif |
0 commit comments