xref: /dragonfly/sys/cpu/x86_64/include/int_limits.h (revision 25a2db75)
1 /*-
2  * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
3  * Copyright (c) 2001 The NetBSD Foundation, Inc.  All rights reserved.
4  * Copyright (c) 1990, 1993 The Regents of the University of California.
5  *		All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Klaus Klein.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef _CPU_INT_LIMITS_H_
40 #define _CPU_INT_LIMITS_H_
41 
42 /*
43  * ISO/IEC 9899:1999
44  * 7.18.2.1 Limits of exact-width integer types
45  */
46 /* Minimum values of exact-width signed integer types. */
47 #define	INT8_MIN	(-0x7f-1)
48 #define	INT16_MIN	(-0x7fff-1)
49 #define	INT32_MIN	(-0x7fffffff-1)
50 #define	INT64_MIN	(-0x7fffffffffffffffL-1)
51 
52 /* Maximum values of exact-width signed integer types. */
53 #define	INT8_MAX	0x7f
54 #define	INT16_MAX	0x7fff
55 #define	INT32_MAX	0x7fffffff
56 #define	INT64_MAX	0x7fffffffffffffffL
57 
58 /* Maximum values of exact-width unsigned integer types. */
59 #define	UINT8_MAX	0xff
60 #define	UINT16_MAX	0xffff
61 #define	UINT32_MAX	0xffffffffU
62 #define	UINT64_MAX	0xffffffffffffffffUL
63 
64 /*
65  * ISO/IEC 9899:1999
66  * 7.18.2.4  Limits of integer types capable of holding object pointers
67  */
68 #define	INTPTR_MIN	INT64_MIN
69 #define	INTPTR_MAX	INT64_MAX
70 #define	UINTPTR_MAX	UINT64_MAX
71 
72 /*
73  * ISO/IEC 9899:1999
74  * 7.18.2.5  Limits of greatest-width integer types
75  */
76 #define	INTMAX_MIN	INT64_MIN
77 #define	INTMAX_MAX	INT64_MAX
78 #define	UINTMAX_MAX	UINT64_MAX
79 
80 /*
81  * ISO/IEC 9899:1999
82  * 7.18.3  Limits of other integer types
83  */
84 /* Limits of ptrdiff_t. */
85 #define	PTRDIFF_MIN	INT64_MIN
86 #define	PTRDIFF_MAX	INT64_MAX
87 
88 /* Limits of sig_atomic_t. */
89 #define	SIG_ATOMIC_MIN	INT32_MIN
90 #define	SIG_ATOMIC_MAX	INT32_MAX
91 
92 /* Limit of size_t. */
93 #define	SIZE_MAX	UINT64_MAX
94 
95 /* XXX possibly should be removed from here */
96 /* Also possibly defined in <wchar.h> */
97 /* Limits of wchar_t. */
98 #ifndef WCHAR_MIN
99 #define	WCHAR_MIN	INT32_MIN
100 #endif
101 #ifndef WCHAR_MAX
102 #define	WCHAR_MAX	INT32_MAX
103 #endif
104 
105 /* Limits of wint_t. */
106 #ifndef WINT_MIN
107 #define	WINT_MIN	INT32_MIN
108 #endif
109 #ifndef WINT_MAX
110 #define	WINT_MAX	INT32_MAX
111 #endif
112 
113 /*
114  * ISO/IEC 9899:1999
115  * 7.18.2.2  Limits of minimum-width integer types
116  */
117 /* Minimum values of minimum-width signed integer types. */
118 #define	INT_LEAST8_MIN		INT8_MIN
119 #define	INT_LEAST16_MIN		INT16_MIN
120 #define	INT_LEAST32_MIN		INT32_MIN
121 #define	INT_LEAST64_MIN		INT64_MIN
122 
123 /* Maximum values of minimum-width signed integer types. */
124 #define	INT_LEAST8_MAX		INT8_MAX
125 #define	INT_LEAST16_MAX		INT16_MAX
126 #define	INT_LEAST32_MAX		INT32_MAX
127 #define	INT_LEAST64_MAX		INT64_MAX
128 
129 /* Maximum values of minimum-width unsigned integer types. */
130 #define	UINT_LEAST8_MAX		UINT8_MAX
131 #define	UINT_LEAST16_MAX	UINT16_MAX
132 #define	UINT_LEAST32_MAX	UINT32_MAX
133 #define	UINT_LEAST64_MAX	UINT64_MAX
134 
135 /*
136  * ISO/IEC 9899:1999
137  * 7.18.2.3  Limits of fastest minimum-width integer types
138  */
139 /* Minimum values of fastest minimum-width signed integer types. */
140 #define	INT_FAST8_MIN		INT32_MIN
141 #define	INT_FAST16_MIN		INT32_MIN
142 #define	INT_FAST32_MIN		INT32_MIN
143 #define	INT_FAST64_MIN		INT64_MIN
144 
145 /* Maximum values of fastest minimum-width signed integer types. */
146 #define	INT_FAST8_MAX		INT32_MAX
147 #define	INT_FAST16_MAX		INT32_MAX
148 #define	INT_FAST32_MAX		INT32_MAX
149 #define	INT_FAST64_MAX		INT64_MAX
150 
151 /* Maximum values of fastest minimum-width unsigned integer types. */
152 #define	UINT_FAST8_MAX		UINT32_MAX
153 #define	UINT_FAST16_MAX		UINT32_MAX
154 #define	UINT_FAST32_MAX		UINT32_MAX
155 #define	UINT_FAST64_MAX		UINT64_MAX
156 
157 #endif
158