Antonio Nino Diaz | cf0f805 | 2018-08-17 10:45:47 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012-2017 Roberto E. Vargas Caballero |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
Antonio Nino Diaz | 6ef1612 | 2018-08-15 19:51:09 +0100 | [diff] [blame] | 6 | /* |
Govindraj Raja | eee28e7 | 2023-08-01 15:52:40 -0500 | [diff] [blame] | 7 | * Portions copyright (c) 2018-2019, Arm Limited and Contributors. |
Antonio Nino Diaz | 6ef1612 | 2018-08-15 19:51:09 +0100 | [diff] [blame] | 8 | * All rights reserved. |
| 9 | */ |
Antonio Nino Diaz | cf0f805 | 2018-08-17 10:45:47 +0100 | [diff] [blame] | 10 | |
Antonio Nino Diaz | 17605e7 | 2018-08-14 13:39:29 +0100 | [diff] [blame] | 11 | #ifndef STDINT_H |
| 12 | #define STDINT_H |
Antonio Nino Diaz | cf0f805 | 2018-08-17 10:45:47 +0100 | [diff] [blame] | 13 | |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 14 | #include <limits.h> |
Scott Branden | e5dcf98 | 2020-08-25 13:49:32 -0700 | [diff] [blame] | 15 | #include <stdint_.h> |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 16 | |
| 17 | #define INT8_MAX CHAR_MAX |
| 18 | #define INT8_MIN CHAR_MIN |
| 19 | #define UINT8_MAX UCHAR_MAX |
| 20 | |
| 21 | #define INT16_MAX SHRT_MAX |
| 22 | #define INT16_MIN SHRT_MIN |
| 23 | #define UINT16_MAX USHRT_MAX |
| 24 | |
| 25 | #define INT32_MAX INT_MAX |
| 26 | #define INT32_MIN INT_MIN |
| 27 | #define UINT32_MAX UINT_MAX |
| 28 | |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 29 | #define INT_LEAST8_MIN INT8_MIN |
| 30 | #define INT_LEAST8_MAX INT8_MAX |
| 31 | #define UINT_LEAST8_MAX UINT8_MAX |
| 32 | |
| 33 | #define INT_LEAST16_MIN INT16_MIN |
| 34 | #define INT_LEAST16_MAX INT16_MAX |
| 35 | #define UINT_LEAST16_MAX UINT16_MAX |
| 36 | |
| 37 | #define INT_LEAST32_MIN INT32_MIN |
| 38 | #define INT_LEAST32_MAX INT32_MAX |
| 39 | #define UINT_LEAST32_MAX UINT32_MAX |
| 40 | |
| 41 | #define INT_LEAST64_MIN INT64_MIN |
| 42 | #define INT_LEAST64_MAX INT64_MAX |
| 43 | #define UINT_LEAST64_MAX UINT64_MAX |
| 44 | |
| 45 | #define INT_FAST8_MIN INT32_MIN |
| 46 | #define INT_FAST8_MAX INT32_MAX |
| 47 | #define UINT_FAST8_MAX UINT32_MAX |
| 48 | |
| 49 | #define INT_FAST16_MIN INT32_MIN |
| 50 | #define INT_FAST16_MAX INT32_MAX |
| 51 | #define UINT_FAST16_MAX UINT32_MAX |
| 52 | |
| 53 | #define INT_FAST32_MIN INT32_MIN |
| 54 | #define INT_FAST32_MAX INT32_MAX |
| 55 | #define UINT_FAST32_MAX UINT32_MAX |
| 56 | |
| 57 | #define INT_FAST64_MIN INT64_MIN |
| 58 | #define INT_FAST64_MAX INT64_MAX |
| 59 | #define UINT_FAST64_MAX UINT64_MAX |
| 60 | |
| 61 | #define INTPTR_MIN LONG_MIN |
| 62 | #define INTPTR_MAX LONG_MAX |
| 63 | #define UINTPTR_MAX ULONG_MAX |
| 64 | |
| 65 | #define INTMAX_MIN LLONG_MIN |
| 66 | #define INTMAX_MAX LLONG_MAX |
| 67 | #define UINTMAX_MAX ULLONG_MAX |
| 68 | |
| 69 | #define PTRDIFF_MIN LONG_MIN |
| 70 | #define PTRDIFF_MAX LONG_MAX |
| 71 | |
Bence Szépkúti | cf17578 | 2019-12-16 14:57:40 +0100 | [diff] [blame] | 72 | #define SIZE_MAX ULONG_MAX |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 73 | |
| 74 | #define INT8_C(x) x |
| 75 | #define INT16_C(x) x |
| 76 | #define INT32_C(x) x |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 77 | |
| 78 | #define UINT8_C(x) x |
| 79 | #define UINT16_C(x) x |
| 80 | #define UINT32_C(x) x ## U |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 81 | |
| 82 | #define INTMAX_C(x) x ## LL |
| 83 | #define UINTMAX_C(x) x ## ULL |
| 84 | |
| 85 | typedef signed char int8_t; |
| 86 | typedef short int16_t; |
| 87 | typedef int int32_t; |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 88 | |
| 89 | typedef unsigned char uint8_t; |
| 90 | typedef unsigned short uint16_t; |
| 91 | typedef unsigned int uint32_t; |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 92 | |
| 93 | typedef signed char int8_least_t; |
| 94 | typedef short int16_least_t; |
| 95 | typedef int int32_least_t; |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 96 | |
| 97 | typedef unsigned char uint8_least_t; |
| 98 | typedef unsigned short uint16_least_t; |
| 99 | typedef unsigned int uint32_least_t; |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 100 | |
| 101 | typedef int int8_fast_t; |
| 102 | typedef int int16_fast_t; |
| 103 | typedef int int32_fast_t; |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 104 | |
| 105 | typedef unsigned int uint8_fast_t; |
| 106 | typedef unsigned int uint16_fast_t; |
| 107 | typedef unsigned int uint32_fast_t; |
Bence Szépkúti | fddf518 | 2019-10-25 17:48:20 +0200 | [diff] [blame] | 108 | |
| 109 | typedef long intptr_t; |
| 110 | typedef unsigned long uintptr_t; |
| 111 | |
| 112 | /* |
| 113 | * Conceptually, these are supposed to be the largest integers representable in C, |
| 114 | * but GCC and Clang define them as long long for compatibility. |
| 115 | */ |
| 116 | typedef long long intmax_t; |
| 117 | typedef unsigned long long uintmax_t; |
| 118 | |
| 119 | typedef long register_t; |
| 120 | typedef unsigned long u_register_t; |
| 121 | |
Antonio Nino Diaz | 17605e7 | 2018-08-14 13:39:29 +0100 | [diff] [blame] | 122 | #endif /* STDINT_H */ |