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