2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
5 * Copyright (c) 2001 The NetBSD Foundation, Inc.
8 * This code is derived from software contributed to The NetBSD Foundation
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
42 #ifndef _MACHINE__STDINT_H_
43 #define _MACHINE__STDINT_H_
45 #include <machine/_limits.h>
47 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
50 #define INT16_C(c) (c)
51 #define INT32_C(c) (c)
53 #define UINT8_C(c) (c)
54 #define UINT16_C(c) (c)
55 #define UINT32_C(c) (c ## U)
58 #define INT64_C(c) (c ## L)
59 #define UINT64_C(c) (c ## UL)
61 #define INT64_C(c) (c ## LL)
62 #define UINT64_C(c) (c ## ULL)
65 #define INTMAX_C(c) INT64_C(c)
66 #define UINTMAX_C(c) UINT64_C(c)
68 #endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
70 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
74 * 7.18.2.1 Limits of exact-width integer types
76 #define INT8_MIN (-0x7f-1)
77 #define INT16_MIN (-0x7fff-1)
78 #define INT32_MIN (-0x7fffffff-1)
81 #define INT16_MAX 0x7fff
82 #define INT32_MAX 0x7fffffff
84 #define UINT8_MAX 0xff
85 #define UINT16_MAX 0xffff
86 #define UINT32_MAX 0xffffffffU
89 #define INT64_MIN (-0x7fffffffffffffff-1)
90 #define INT64_MAX 0x7fffffffffffffff
91 #define UINT64_MAX 0xffffffffffffffff
93 #define INT64_MIN (-0x7fffffffffffffffLL-1)
94 #define INT64_MAX 0x7fffffffffffffffLL
95 #define UINT64_MAX 0xffffffffffffffffULL
100 * 7.18.2.2 Limits of minimum-width integer types
102 /* Minimum values of minimum-width signed integer types. */
103 #define INT_LEAST8_MIN INT8_MIN
104 #define INT_LEAST16_MIN INT16_MIN
105 #define INT_LEAST32_MIN INT32_MIN
106 #define INT_LEAST64_MIN INT64_MIN
108 /* Maximum values of minimum-width signed integer types. */
109 #define INT_LEAST8_MAX INT8_MAX
110 #define INT_LEAST16_MAX INT16_MAX
111 #define INT_LEAST32_MAX INT32_MAX
112 #define INT_LEAST64_MAX INT64_MAX
114 /* Maximum values of minimum-width unsigned integer types. */
115 #define UINT_LEAST8_MAX UINT8_MAX
116 #define UINT_LEAST16_MAX UINT16_MAX
117 #define UINT_LEAST32_MAX UINT32_MAX
118 #define UINT_LEAST64_MAX UINT64_MAX
122 * 7.18.2.3 Limits of fastest minimum-width integer types
124 /* Minimum values of fastest minimum-width signed integer types. */
125 #define INT_FAST8_MIN INT32_MIN
126 #define INT_FAST16_MIN INT32_MIN
127 #define INT_FAST32_MIN INT32_MIN
128 #define INT_FAST64_MIN INT64_MIN
130 /* Maximum values of fastest minimum-width signed integer types. */
131 #define INT_FAST8_MAX INT32_MAX
132 #define INT_FAST16_MAX INT32_MAX
133 #define INT_FAST32_MAX INT32_MAX
134 #define INT_FAST64_MAX INT64_MAX
136 /* Maximum values of fastest minimum-width unsigned integer types. */
137 #define UINT_FAST8_MAX UINT32_MAX
138 #define UINT_FAST16_MAX UINT32_MAX
139 #define UINT_FAST32_MAX UINT32_MAX
140 #define UINT_FAST64_MAX UINT64_MAX
144 * 7.18.2.4 Limits of integer types capable of holding object pointers
147 #define INTPTR_MIN INT64_MIN
148 #define INTPTR_MAX INT64_MAX
149 #define UINTPTR_MAX UINT64_MAX
151 #define INTPTR_MIN INT32_MIN
152 #define INTPTR_MAX INT32_MAX
153 #define UINTPTR_MAX UINT32_MAX
158 * 7.18.2.5 Limits of greatest-width integer types
160 #define INTMAX_MIN INT64_MIN
161 #define INTMAX_MAX INT64_MAX
162 #define UINTMAX_MAX UINT64_MAX
166 * 7.18.3 Limits of other integer types
169 /* Limits of ptrdiff_t. */
170 #define PTRDIFF_MIN INT64_MIN
171 #define PTRDIFF_MAX INT64_MAX
173 /* Limits of sig_atomic_t. */
174 #define SIG_ATOMIC_MIN __LONG_MIN
175 #define SIG_ATOMIC_MAX __LONG_MAX
177 /* Limit of size_t. */
178 #define SIZE_MAX UINT64_MAX
180 #define PTRDIFF_MIN INT32_MIN
181 #define PTRDIFF_MAX INT32_MAX
182 #define SIG_ATOMIC_MIN INT32_MIN
183 #define SIG_ATOMIC_MAX INT32_MAX
184 #define SIZE_MAX UINT32_MAX
187 /* Limits of wint_t. */
188 #define WINT_MIN INT32_MIN
189 #define WINT_MAX INT32_MAX
191 #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
193 #endif /* !_MACHINE__STDINT_H_ */