xref: /freebsd/sys/riscv/include/_stdint.h (revision 9137c66c2ea6cc09e3a6f8a042ecdc5a62e0f39e)
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 
31 #ifndef _MACHINE__STDINT_H_
32 #define	_MACHINE__STDINT_H_
33 
34 #define	INT8_C(c)		(c)
35 #define	INT16_C(c)		(c)
36 #define	INT32_C(c)		(c)
37 #define	INT64_C(c)		(c ## L)
38 
39 #define	UINT8_C(c)		(c)
40 #define	UINT16_C(c)		(c)
41 #define	UINT32_C(c)		(c ## U)
42 #define	UINT64_C(c)		(c ## UL)
43 
44 #define	INTMAX_C(c)		INT64_C(c)
45 #define	UINTMAX_C(c)		UINT64_C(c)
46 
47 /*
48  * ISO/IEC 9899:1999
49  * 7.18.2.1 Limits of exact-width integer types
50  */
51 /* Minimum values of exact-width signed integer types. */
52 #define	INT8_MIN	(-0x7f-1)
53 #define	INT16_MIN	(-0x7fff-1)
54 #define	INT32_MIN	(-0x7fffffff-1)
55 #define	INT64_MIN	(-0x7fffffffffffffffL-1)
56 
57 /* Maximum values of exact-width signed integer types. */
58 #define	INT8_MAX	0x7f
59 #define	INT16_MAX	0x7fff
60 #define	INT32_MAX	0x7fffffff
61 #define	INT64_MAX	0x7fffffffffffffffL
62 
63 /* Maximum values of exact-width unsigned integer types. */
64 #define	UINT8_MAX	0xff
65 #define	UINT16_MAX	0xffff
66 #define	UINT32_MAX	0xffffffffU
67 #define	UINT64_MAX	0xffffffffffffffffUL
68 
69 /*
70  * ISO/IEC 9899:1999
71  * 7.18.2.2  Limits of minimum-width integer types
72  */
73 /* Minimum values of minimum-width signed integer types. */
74 #define	INT_LEAST8_MIN	INT8_MIN
75 #define	INT_LEAST16_MIN	INT16_MIN
76 #define	INT_LEAST32_MIN	INT32_MIN
77 #define	INT_LEAST64_MIN	INT64_MIN
78 
79 /* Maximum values of minimum-width signed integer types. */
80 #define	INT_LEAST8_MAX	INT8_MAX
81 #define	INT_LEAST16_MAX	INT16_MAX
82 #define	INT_LEAST32_MAX	INT32_MAX
83 #define	INT_LEAST64_MAX	INT64_MAX
84 
85 /* Maximum values of minimum-width unsigned integer types. */
86 #define	UINT_LEAST8_MAX	 UINT8_MAX
87 #define	UINT_LEAST16_MAX UINT16_MAX
88 #define	UINT_LEAST32_MAX UINT32_MAX
89 #define	UINT_LEAST64_MAX UINT64_MAX
90 
91 /*
92  * ISO/IEC 9899:1999
93  * 7.18.2.3  Limits of fastest minimum-width integer types
94  */
95 /* Minimum values of fastest minimum-width signed integer types. */
96 #define	INT_FAST8_MIN	INT32_MIN
97 #define	INT_FAST16_MIN	INT32_MIN
98 #define	INT_FAST32_MIN	INT32_MIN
99 #define	INT_FAST64_MIN	INT64_MIN
100 
101 /* Maximum values of fastest minimum-width signed integer types. */
102 #define	INT_FAST8_MAX	INT32_MAX
103 #define	INT_FAST16_MAX	INT32_MAX
104 #define	INT_FAST32_MAX	INT32_MAX
105 #define	INT_FAST64_MAX	INT64_MAX
106 
107 /* Maximum values of fastest minimum-width unsigned integer types. */
108 #define	UINT_FAST8_MAX	UINT32_MAX
109 #define	UINT_FAST16_MAX	UINT32_MAX
110 #define	UINT_FAST32_MAX	UINT32_MAX
111 #define	UINT_FAST64_MAX	UINT64_MAX
112 
113 /*
114  * ISO/IEC 9899:1999
115  * 7.18.2.4  Limits of integer types capable of holding object pointers
116  */
117 #define	INTPTR_MIN	INT64_MIN
118 #define	INTPTR_MAX	INT64_MAX
119 #define	UINTPTR_MAX	UINT64_MAX
120 
121 /*
122  * ISO/IEC 9899:1999
123  * 7.18.2.5  Limits of greatest-width integer types
124  */
125 #define	INTMAX_MIN	INT64_MIN
126 #define	INTMAX_MAX	INT64_MAX
127 #define	UINTMAX_MAX	UINT64_MAX
128 
129 /*
130  * ISO/IEC 9899:1999
131  * 7.18.3  Limits of other integer types
132  */
133 /* Limits of ptrdiff_t. */
134 #define	PTRDIFF_MIN	INT64_MIN
135 #define	PTRDIFF_MAX	INT64_MAX
136 
137 /* Limits of sig_atomic_t. */
138 #define	SIG_ATOMIC_MIN	INT64_MIN
139 #define	SIG_ATOMIC_MAX	INT64_MAX
140 
141 /* Limit of size_t. */
142 #define	SIZE_MAX	UINT64_MAX
143 
144 /* Limits of wint_t. */
145 #define	WINT_MIN	INT32_MIN
146 #define	WINT_MAX	INT32_MAX
147 
148 #if __ISO_C_VISIBLE >= 2023
149 /*
150  * ISO/IEC 9899:2023
151  * 7.22.2 Widths of specified-width integer types
152  */
153 #define INT_FAST8_WIDTH		INT32_WIDTH
154 #define INT_FAST16_WIDTH	INT32_WIDTH
155 #define INT_FAST32_WIDTH	INT32_WIDTH
156 #define INT_FAST64_WIDTH	INT64_WIDTH
157 #define INTPTR_WIDTH		INT64_WIDTH
158 #define INTMAX_WIDTH		INT64_WIDTH
159 
160 /*
161  * ISO/IEC 9899:2023
162  * 7.22.3 Width of other integer types
163  */
164 #define PTRDIFF_WIDTH		INT64_WIDTH
165 #define SIG_ATOMIC_WIDTH	INT64_WIDTH
166 #define SIZE_WIDTH		INT64_WIDTH
167 #define WCHAR_WIDTH		INT32_WIDTH
168 #define WINT_WIDTH		INT32_WIDTH
169 #endif /* __ISO_C_VISIBLE >= 2023 */
170 
171 #endif /* !_MACHINE__STDINT_H_ */
172