Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 1 | /*- |
| 2 | * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org> |
| 3 | * Copyright (c) 2001 The NetBSD Foundation, Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * This code is derived from software contributed to The NetBSD Foundation |
| 7 | * by Klaus Klein. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions |
| 11 | * are met: |
| 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in the |
| 16 | * documentation and/or other materials provided with the distribution. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
| 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 20 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
| 22 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | * POSSIBILITY OF SUCH DAMAGE. |
| 29 | * |
| 30 | * $FreeBSD$ |
| 31 | */ |
| 32 | |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 33 | /* |
Soby Mathew | dc07517 | 2017-06-06 10:01:03 +0100 | [diff] [blame^] | 34 | * Portions copyright (c) 2016-2017, ARM Limited and Contributors. |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 35 | * All rights reserved. |
| 36 | */ |
| 37 | |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 38 | #ifndef _MACHINE__STDINT_H_ |
| 39 | #define _MACHINE__STDINT_H_ |
| 40 | |
| 41 | #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) |
| 42 | |
| 43 | #define INT8_C(c) (c) |
| 44 | #define INT16_C(c) (c) |
| 45 | #define INT32_C(c) (c) |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 46 | #define INT64_C(c) (c ## LL) |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 47 | |
| 48 | #define UINT8_C(c) (c) |
| 49 | #define UINT16_C(c) (c) |
| 50 | #define UINT32_C(c) (c ## U) |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 51 | #define UINT64_C(c) (c ## ULL) |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 52 | |
| 53 | #define INTMAX_C(c) INT64_C(c) |
| 54 | #define UINTMAX_C(c) UINT64_C(c) |
| 55 | |
| 56 | #endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */ |
| 57 | |
| 58 | #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) |
| 59 | |
| 60 | /* |
| 61 | * ISO/IEC 9899:1999 |
| 62 | * 7.18.2.1 Limits of exact-width integer types |
| 63 | */ |
| 64 | /* Minimum values of exact-width signed integer types. */ |
| 65 | #define INT8_MIN (-0x7f-1) |
| 66 | #define INT16_MIN (-0x7fff-1) |
| 67 | #define INT32_MIN (-0x7fffffff-1) |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 68 | #define INT64_MIN (-0x7fffffffffffffffLL-1) |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 69 | |
| 70 | /* Maximum values of exact-width signed integer types. */ |
| 71 | #define INT8_MAX 0x7f |
| 72 | #define INT16_MAX 0x7fff |
| 73 | #define INT32_MAX 0x7fffffff |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 74 | #define INT64_MAX 0x7fffffffffffffffLL |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 75 | |
| 76 | /* Maximum values of exact-width unsigned integer types. */ |
| 77 | #define UINT8_MAX 0xff |
| 78 | #define UINT16_MAX 0xffff |
| 79 | #define UINT32_MAX 0xffffffffU |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 80 | #define UINT64_MAX 0xffffffffffffffffULL |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 81 | |
| 82 | /* |
| 83 | * ISO/IEC 9899:1999 |
| 84 | * 7.18.2.2 Limits of minimum-width integer types |
| 85 | */ |
| 86 | /* Minimum values of minimum-width signed integer types. */ |
| 87 | #define INT_LEAST8_MIN INT8_MIN |
| 88 | #define INT_LEAST16_MIN INT16_MIN |
| 89 | #define INT_LEAST32_MIN INT32_MIN |
| 90 | #define INT_LEAST64_MIN INT64_MIN |
| 91 | |
| 92 | /* Maximum values of minimum-width signed integer types. */ |
| 93 | #define INT_LEAST8_MAX INT8_MAX |
| 94 | #define INT_LEAST16_MAX INT16_MAX |
| 95 | #define INT_LEAST32_MAX INT32_MAX |
| 96 | #define INT_LEAST64_MAX INT64_MAX |
| 97 | |
| 98 | /* Maximum values of minimum-width unsigned integer types. */ |
| 99 | #define UINT_LEAST8_MAX UINT8_MAX |
| 100 | #define UINT_LEAST16_MAX UINT16_MAX |
| 101 | #define UINT_LEAST32_MAX UINT32_MAX |
| 102 | #define UINT_LEAST64_MAX UINT64_MAX |
| 103 | |
| 104 | /* |
| 105 | * ISO/IEC 9899:1999 |
| 106 | * 7.18.2.3 Limits of fastest minimum-width integer types |
| 107 | */ |
| 108 | /* Minimum values of fastest minimum-width signed integer types. */ |
| 109 | #define INT_FAST8_MIN INT32_MIN |
| 110 | #define INT_FAST16_MIN INT32_MIN |
| 111 | #define INT_FAST32_MIN INT32_MIN |
| 112 | #define INT_FAST64_MIN INT64_MIN |
| 113 | |
| 114 | /* Maximum values of fastest minimum-width signed integer types. */ |
| 115 | #define INT_FAST8_MAX INT32_MAX |
| 116 | #define INT_FAST16_MAX INT32_MAX |
| 117 | #define INT_FAST32_MAX INT32_MAX |
| 118 | #define INT_FAST64_MAX INT64_MAX |
| 119 | |
| 120 | /* Maximum values of fastest minimum-width unsigned integer types. */ |
| 121 | #define UINT_FAST8_MAX UINT32_MAX |
| 122 | #define UINT_FAST16_MAX UINT32_MAX |
| 123 | #define UINT_FAST32_MAX UINT32_MAX |
| 124 | #define UINT_FAST64_MAX UINT64_MAX |
| 125 | |
| 126 | /* |
| 127 | * ISO/IEC 9899:1999 |
| 128 | * 7.18.2.4 Limits of integer types capable of holding object pointers |
| 129 | */ |
Soby Mathew | dc07517 | 2017-06-06 10:01:03 +0100 | [diff] [blame^] | 130 | #ifdef AARCH32 |
| 131 | #define INTPTR_MIN INT32_MIN |
| 132 | #define INTPTR_MAX INT32_MAX |
| 133 | #define UINTPTR_MAX UINT32_MAX |
| 134 | #else |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 135 | #define INTPTR_MIN INT64_MIN |
| 136 | #define INTPTR_MAX INT64_MAX |
| 137 | #define UINTPTR_MAX UINT64_MAX |
Soby Mathew | dc07517 | 2017-06-06 10:01:03 +0100 | [diff] [blame^] | 138 | #endif |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 139 | |
| 140 | /* |
| 141 | * ISO/IEC 9899:1999 |
| 142 | * 7.18.2.5 Limits of greatest-width integer types |
| 143 | */ |
| 144 | #define INTMAX_MIN INT64_MIN |
| 145 | #define INTMAX_MAX INT64_MAX |
| 146 | #define UINTMAX_MAX UINT64_MAX |
| 147 | |
| 148 | /* |
| 149 | * ISO/IEC 9899:1999 |
| 150 | * 7.18.3 Limits of other integer types |
| 151 | */ |
| 152 | /* Limits of ptrdiff_t. */ |
Soby Mathew | dc07517 | 2017-06-06 10:01:03 +0100 | [diff] [blame^] | 153 | #ifdef AARCH32 |
| 154 | #define PTRDIFF_MIN INT32_MIN |
| 155 | #define PTRDIFF_MAX INT32_MAX |
| 156 | #else |
| 157 | #define PTRDIFF_MIN INT64_MIN |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 158 | #define PTRDIFF_MAX INT64_MAX |
Soby Mathew | dc07517 | 2017-06-06 10:01:03 +0100 | [diff] [blame^] | 159 | #endif |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 160 | |
| 161 | /* Limits of sig_atomic_t. */ |
| 162 | #define SIG_ATOMIC_MIN INT32_MIN |
| 163 | #define SIG_ATOMIC_MAX INT32_MAX |
| 164 | |
| 165 | /* Limit of size_t. */ |
Soby Mathew | dc07517 | 2017-06-06 10:01:03 +0100 | [diff] [blame^] | 166 | #ifdef AARCH32 |
| 167 | #define SIZE_MAX UINT32_MAX |
| 168 | #else |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 169 | #define SIZE_MAX UINT64_MAX |
Soby Mathew | dc07517 | 2017-06-06 10:01:03 +0100 | [diff] [blame^] | 170 | #endif |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 171 | |
| 172 | #ifndef WCHAR_MIN /* Also possibly defined in <wchar.h> */ |
| 173 | /* Limits of wchar_t. */ |
| 174 | #define WCHAR_MIN INT32_MIN |
| 175 | #define WCHAR_MAX INT32_MAX |
| 176 | #endif |
| 177 | |
| 178 | /* Limits of wint_t. */ |
| 179 | #define WINT_MIN INT32_MIN |
| 180 | #define WINT_MAX INT32_MAX |
| 181 | |
| 182 | #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ |
| 183 | |
| 184 | #endif /* !_MACHINE__STDINT_H_ */ |