xref: /freebsd/sys/x86/include/_stdint.h (revision 66fd12cf4896eb08ad8e7a2627537f84ead84dd3)
1 /*-
2  * SPDX-License-Identifier: BSD-4-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  * 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.
26  *
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.
38  *
39  * $FreeBSD$
40  */
41 
42 #ifndef _MACHINE__STDINT_H_
43 #define	_MACHINE__STDINT_H_
44 
45 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
46 
47 #define	INT8_C(c)		(c)
48 #define	INT16_C(c)		(c)
49 #define	INT32_C(c)		(c)
50 
51 #define	UINT8_C(c)		(c)
52 #define	UINT16_C(c)		(c)
53 #define	UINT32_C(c)		(c ## U)
54 
55 #ifdef	__LP64__
56 #define	INT64_C(c)		(c ## L)
57 #define	UINT64_C(c)		(c ## UL)
58 #else
59 #define	INT64_C(c)		(c ## LL)
60 #define	UINT64_C(c)		(c ## ULL)
61 #endif
62 
63 #define	INTMAX_C(c)		INT64_C(c)
64 #define	UINTMAX_C(c)		UINT64_C(c)
65 
66 #endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
67 
68 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
69 
70 /*
71  * ISO/IEC 9899:1999
72  * 7.18.2.1 Limits of exact-width integer types
73  */
74 #define	INT8_MIN	(-0x7f-1)
75 #define	INT16_MIN	(-0x7fff-1)
76 #define	INT32_MIN	(-0x7fffffff-1)
77 
78 #define	INT8_MAX	0x7f
79 #define	INT16_MAX	0x7fff
80 #define	INT32_MAX	0x7fffffff
81 
82 #define	UINT8_MAX	0xff
83 #define	UINT16_MAX	0xffff
84 #define	UINT32_MAX	0xffffffffU
85 
86 #ifdef __LP64__
87 #define	INT64_MIN	(-0x7fffffffffffffff-1)
88 #define	INT64_MAX	0x7fffffffffffffff
89 #define	UINT64_MAX	0xffffffffffffffff
90 #else
91 #define	INT64_MIN	(-0x7fffffffffffffffLL-1)
92 #define	INT64_MAX	0x7fffffffffffffffLL
93 #define	UINT64_MAX	0xffffffffffffffffULL
94 #endif
95 
96 /*
97  * ISO/IEC 9899:1999
98  * 7.18.2.2  Limits of minimum-width integer types
99  */
100 /* Minimum values of minimum-width signed integer types. */
101 #define	INT_LEAST8_MIN	INT8_MIN
102 #define	INT_LEAST16_MIN	INT16_MIN
103 #define	INT_LEAST32_MIN	INT32_MIN
104 #define	INT_LEAST64_MIN	INT64_MIN
105 
106 /* Maximum values of minimum-width signed integer types. */
107 #define	INT_LEAST8_MAX	INT8_MAX
108 #define	INT_LEAST16_MAX	INT16_MAX
109 #define	INT_LEAST32_MAX	INT32_MAX
110 #define	INT_LEAST64_MAX	INT64_MAX
111 
112 /* Maximum values of minimum-width unsigned integer types. */
113 #define	UINT_LEAST8_MAX	 UINT8_MAX
114 #define	UINT_LEAST16_MAX UINT16_MAX
115 #define	UINT_LEAST32_MAX UINT32_MAX
116 #define	UINT_LEAST64_MAX UINT64_MAX
117 
118 /*
119  * ISO/IEC 9899:1999
120  * 7.18.2.3  Limits of fastest minimum-width integer types
121  */
122 /* Minimum values of fastest minimum-width signed integer types. */
123 #define	INT_FAST8_MIN	INT32_MIN
124 #define	INT_FAST16_MIN	INT32_MIN
125 #define	INT_FAST32_MIN	INT32_MIN
126 #define	INT_FAST64_MIN	INT64_MIN
127 
128 /* Maximum values of fastest minimum-width signed integer types. */
129 #define	INT_FAST8_MAX	INT32_MAX
130 #define	INT_FAST16_MAX	INT32_MAX
131 #define	INT_FAST32_MAX	INT32_MAX
132 #define	INT_FAST64_MAX	INT64_MAX
133 
134 /* Maximum values of fastest minimum-width unsigned integer types. */
135 #define	UINT_FAST8_MAX	UINT32_MAX
136 #define	UINT_FAST16_MAX	UINT32_MAX
137 #define	UINT_FAST32_MAX	UINT32_MAX
138 #define	UINT_FAST64_MAX	UINT64_MAX
139 
140 /*
141  * ISO/IEC 9899:1999
142  * 7.18.2.4  Limits of integer types capable of holding object pointers
143  */
144 #ifdef	__LP64__
145 #define	INTPTR_MIN	INT64_MIN
146 #define	INTPTR_MAX	INT64_MAX
147 #define	UINTPTR_MAX	UINT64_MAX
148 #else
149 #define	INTPTR_MIN	INT32_MIN
150 #define	INTPTR_MAX	INT32_MAX
151 #define	UINTPTR_MAX	UINT32_MAX
152 #endif
153 
154 /*
155  * ISO/IEC 9899:1999
156  * 7.18.2.5  Limits of greatest-width integer types
157  */
158 #define	INTMAX_MIN	INT64_MIN
159 #define	INTMAX_MAX	INT64_MAX
160 #define	UINTMAX_MAX	UINT64_MAX
161 
162 /*
163  * ISO/IEC 9899:1999
164  * 7.18.3  Limits of other integer types
165  */
166 #ifdef	__LP64__
167 /* Limits of ptrdiff_t. */
168 #define	PTRDIFF_MIN	INT64_MIN
169 #define	PTRDIFF_MAX	INT64_MAX
170 
171 /* Limits of sig_atomic_t. */
172 #define	SIG_ATOMIC_MIN	INT64_MIN
173 #define	SIG_ATOMIC_MAX	INT64_MAX
174 
175 /* Limit of size_t. */
176 #define	SIZE_MAX	UINT64_MAX
177 #else
178 #define	PTRDIFF_MIN	INT32_MIN
179 #define	PTRDIFF_MAX	INT32_MAX
180 #define	SIG_ATOMIC_MIN	INT32_MIN
181 #define	SIG_ATOMIC_MAX	INT32_MAX
182 #define	SIZE_MAX	UINT32_MAX
183 #endif
184 
185 /* Limits of wint_t. */
186 #define	WINT_MIN	INT32_MIN
187 #define	WINT_MAX	INT32_MAX
188 
189 #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
190 
191 #endif /* !_MACHINE__STDINT_H_ */
192