xref: /freebsd/sys/powerpc/include/_stdint.h (revision 95ee2897)
149545b38SMike Barcroft /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-4-Clause
351369649SPedro F. Giffuni  *
449545b38SMike Barcroft  * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
549545b38SMike Barcroft  * Copyright (c) 2001 The NetBSD Foundation, Inc.
649545b38SMike Barcroft  * All rights reserved.
749545b38SMike Barcroft  *
849545b38SMike Barcroft  * This code is derived from software contributed to The NetBSD Foundation
949545b38SMike Barcroft  * by Klaus Klein.
1049545b38SMike Barcroft  *
1149545b38SMike Barcroft  * Redistribution and use in source and binary forms, with or without
1249545b38SMike Barcroft  * modification, are permitted provided that the following conditions
1349545b38SMike Barcroft  * are met:
1449545b38SMike Barcroft  * 1. Redistributions of source code must retain the above copyright
1549545b38SMike Barcroft  *    notice, this list of conditions and the following disclaimer.
1649545b38SMike Barcroft  * 2. Redistributions in binary form must reproduce the above copyright
1749545b38SMike Barcroft  *    notice, this list of conditions and the following disclaimer in the
1849545b38SMike Barcroft  *    documentation and/or other materials provided with the distribution.
1949545b38SMike Barcroft  * 3. All advertising materials mentioning features or use of this software
2049545b38SMike Barcroft  *    must display the following acknowledgement:
2149545b38SMike Barcroft  *        This product includes software developed by the NetBSD
2249545b38SMike Barcroft  *        Foundation, Inc. and its contributors.
2349545b38SMike Barcroft  * 4. Neither the name of The NetBSD Foundation nor the names of its
2449545b38SMike Barcroft  *    contributors may be used to endorse or promote products derived
2549545b38SMike Barcroft  *    from this software without specific prior written permission.
2649545b38SMike Barcroft  *
2749545b38SMike Barcroft  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2849545b38SMike Barcroft  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2949545b38SMike Barcroft  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3049545b38SMike Barcroft  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
3149545b38SMike Barcroft  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3249545b38SMike Barcroft  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3349545b38SMike Barcroft  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3449545b38SMike Barcroft  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3549545b38SMike Barcroft  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3649545b38SMike Barcroft  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3749545b38SMike Barcroft  * POSSIBILITY OF SUCH DAMAGE.
3849545b38SMike Barcroft  */
3949545b38SMike Barcroft 
4049545b38SMike Barcroft #ifndef _MACHINE__STDINT_H_
4149545b38SMike Barcroft #define	_MACHINE__STDINT_H_
4249545b38SMike Barcroft 
4349545b38SMike Barcroft #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
4449545b38SMike Barcroft 
4549545b38SMike Barcroft #define	INT8_C(c)		(c)
4649545b38SMike Barcroft #define	INT16_C(c)		(c)
4749545b38SMike Barcroft #define	INT32_C(c)		(c)
4849545b38SMike Barcroft 
4949545b38SMike Barcroft #define	UINT8_C(c)		(c)
5049545b38SMike Barcroft #define	UINT16_C(c)		(c)
5149545b38SMike Barcroft #define	UINT32_C(c)		(c ## U)
5249545b38SMike Barcroft 
53a56e818fSTijl Coosemans #ifdef __LP64__
54c3e289e1SNathan Whitehorn #define	INT64_C(c)		(c ## L)
55c3e289e1SNathan Whitehorn #define	UINT64_C(c)		(c ## UL)
56c3e289e1SNathan Whitehorn #else
57c3e289e1SNathan Whitehorn #define	INT64_C(c)		(c ## LL)
58c3e289e1SNathan Whitehorn #define	UINT64_C(c)		(c ## ULL)
59c3e289e1SNathan Whitehorn #endif
6049545b38SMike Barcroft 
61a56e818fSTijl Coosemans #define	INTMAX_C(c)		INT64_C(c)
62a56e818fSTijl Coosemans #define	UINTMAX_C(c)		UINT64_C(c)
63a56e818fSTijl Coosemans 
6449545b38SMike Barcroft #endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
6549545b38SMike Barcroft 
6649545b38SMike Barcroft #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
6749545b38SMike Barcroft 
68ce7c952aSWarner Losh #ifndef __INT64_C
6954c699c4SAndreas Tobler #ifdef __LP64__
7054c699c4SAndreas Tobler #define	__INT64_C(c)		(c ## L)
7154c699c4SAndreas Tobler #define	__UINT64_C(c)		(c ## UL)
7254c699c4SAndreas Tobler #else
7354c699c4SAndreas Tobler #define	__INT64_C(c)		(c ## LL)
7454c699c4SAndreas Tobler #define	__UINT64_C(c)		(c ## ULL)
7554c699c4SAndreas Tobler #endif
76ce7c952aSWarner Losh #endif
7754c699c4SAndreas Tobler 
7849545b38SMike Barcroft /*
7949545b38SMike Barcroft  * ISO/IEC 9899:1999
8049545b38SMike Barcroft  * 7.18.2.1 Limits of exact-width integer types
8149545b38SMike Barcroft  */
8249545b38SMike Barcroft /* Minimum values of exact-width signed integer types. */
8349545b38SMike Barcroft #define	INT8_MIN	(-0x7f-1)
8449545b38SMike Barcroft #define	INT16_MIN	(-0x7fff-1)
8549545b38SMike Barcroft #define	INT32_MIN	(-0x7fffffff-1)
8654c699c4SAndreas Tobler #define	INT64_MIN	(-__INT64_C(0x7fffffffffffffff)-1)
8749545b38SMike Barcroft 
8849545b38SMike Barcroft /* Maximum values of exact-width signed integer types. */
8949545b38SMike Barcroft #define	INT8_MAX	0x7f
9049545b38SMike Barcroft #define	INT16_MAX	0x7fff
9149545b38SMike Barcroft #define	INT32_MAX	0x7fffffff
9254c699c4SAndreas Tobler #define	INT64_MAX	__INT64_C(0x7fffffffffffffff)
9349545b38SMike Barcroft 
9449545b38SMike Barcroft /* Maximum values of exact-width unsigned integer types. */
9549545b38SMike Barcroft #define	UINT8_MAX	0xff
9649545b38SMike Barcroft #define	UINT16_MAX	0xffff
97a56e818fSTijl Coosemans #define	UINT32_MAX	0xffffffff
9854c699c4SAndreas Tobler #define	UINT64_MAX	__UINT64_C(0xffffffffffffffff)
9949545b38SMike Barcroft 
10049545b38SMike Barcroft /*
10149545b38SMike Barcroft  * ISO/IEC 9899:1999
10249545b38SMike Barcroft  * 7.18.2.2  Limits of minimum-width integer types
10349545b38SMike Barcroft  */
10449545b38SMike Barcroft /* Minimum values of minimum-width signed integer types. */
10549545b38SMike Barcroft #define	INT_LEAST8_MIN	INT8_MIN
10649545b38SMike Barcroft #define	INT_LEAST16_MIN	INT16_MIN
10749545b38SMike Barcroft #define	INT_LEAST32_MIN	INT32_MIN
10849545b38SMike Barcroft #define	INT_LEAST64_MIN	INT64_MIN
10949545b38SMike Barcroft 
11049545b38SMike Barcroft /* Maximum values of minimum-width signed integer types. */
11149545b38SMike Barcroft #define	INT_LEAST8_MAX	INT8_MAX
11249545b38SMike Barcroft #define	INT_LEAST16_MAX	INT16_MAX
11349545b38SMike Barcroft #define	INT_LEAST32_MAX	INT32_MAX
11449545b38SMike Barcroft #define	INT_LEAST64_MAX	INT64_MAX
11549545b38SMike Barcroft 
11649545b38SMike Barcroft /* Maximum values of minimum-width unsigned integer types. */
11749545b38SMike Barcroft #define	UINT_LEAST8_MAX	 UINT8_MAX
11849545b38SMike Barcroft #define	UINT_LEAST16_MAX UINT16_MAX
11949545b38SMike Barcroft #define	UINT_LEAST32_MAX UINT32_MAX
12049545b38SMike Barcroft #define	UINT_LEAST64_MAX UINT64_MAX
12149545b38SMike Barcroft 
12249545b38SMike Barcroft /*
12349545b38SMike Barcroft  * ISO/IEC 9899:1999
12449545b38SMike Barcroft  * 7.18.2.3  Limits of fastest minimum-width integer types
12549545b38SMike Barcroft  */
12649545b38SMike Barcroft /* Minimum values of fastest minimum-width signed integer types. */
12749545b38SMike Barcroft #define	INT_FAST8_MIN	INT32_MIN
12849545b38SMike Barcroft #define	INT_FAST16_MIN	INT32_MIN
12949545b38SMike Barcroft #define	INT_FAST32_MIN	INT32_MIN
13049545b38SMike Barcroft #define	INT_FAST64_MIN	INT64_MIN
13149545b38SMike Barcroft 
13249545b38SMike Barcroft /* Maximum values of fastest minimum-width signed integer types. */
13349545b38SMike Barcroft #define	INT_FAST8_MAX	INT32_MAX
13449545b38SMike Barcroft #define	INT_FAST16_MAX	INT32_MAX
13549545b38SMike Barcroft #define	INT_FAST32_MAX	INT32_MAX
13649545b38SMike Barcroft #define	INT_FAST64_MAX	INT64_MAX
13749545b38SMike Barcroft 
13849545b38SMike Barcroft /* Maximum values of fastest minimum-width unsigned integer types. */
13949545b38SMike Barcroft #define	UINT_FAST8_MAX	UINT32_MAX
14049545b38SMike Barcroft #define	UINT_FAST16_MAX	UINT32_MAX
14149545b38SMike Barcroft #define	UINT_FAST32_MAX	UINT32_MAX
14249545b38SMike Barcroft #define	UINT_FAST64_MAX	UINT64_MAX
14349545b38SMike Barcroft 
14449545b38SMike Barcroft /*
14549545b38SMike Barcroft  * ISO/IEC 9899:1999
14649545b38SMike Barcroft  * 7.18.2.4  Limits of integer types capable of holding object pointers
14749545b38SMike Barcroft  */
148a56e818fSTijl Coosemans #ifdef __LP64__
149c3e289e1SNathan Whitehorn #define	INTPTR_MIN	INT64_MIN
150c3e289e1SNathan Whitehorn #define	INTPTR_MAX	INT64_MAX
151c3e289e1SNathan Whitehorn #define	UINTPTR_MAX	UINT64_MAX
152c3e289e1SNathan Whitehorn #else
15349545b38SMike Barcroft #define	INTPTR_MIN	INT32_MIN
15449545b38SMike Barcroft #define	INTPTR_MAX	INT32_MAX
15549545b38SMike Barcroft #define	UINTPTR_MAX	UINT32_MAX
156c3e289e1SNathan Whitehorn #endif
15749545b38SMike Barcroft 
15849545b38SMike Barcroft /*
15949545b38SMike Barcroft  * ISO/IEC 9899:1999
16049545b38SMike Barcroft  * 7.18.2.5  Limits of greatest-width integer types
16149545b38SMike Barcroft  */
16249545b38SMike Barcroft #define	INTMAX_MIN	INT64_MIN
16349545b38SMike Barcroft #define	INTMAX_MAX	INT64_MAX
16449545b38SMike Barcroft #define	UINTMAX_MAX	UINT64_MAX
16549545b38SMike Barcroft 
16649545b38SMike Barcroft /*
16749545b38SMike Barcroft  * ISO/IEC 9899:1999
16849545b38SMike Barcroft  * 7.18.3  Limits of other integer types
16949545b38SMike Barcroft  */
170a56e818fSTijl Coosemans #ifdef __LP64__
171c3e289e1SNathan Whitehorn /* Limits of ptrdiff_t. */
172c3e289e1SNathan Whitehorn #define	PTRDIFF_MIN	INT64_MIN
173c3e289e1SNathan Whitehorn #define	PTRDIFF_MAX	INT64_MAX
174c3e289e1SNathan Whitehorn 
175c3e289e1SNathan Whitehorn /* Limits of sig_atomic_t. */
176c3e289e1SNathan Whitehorn #define	SIG_ATOMIC_MIN	INT64_MIN
177c3e289e1SNathan Whitehorn #define	SIG_ATOMIC_MAX	INT64_MAX
178c3e289e1SNathan Whitehorn 
179c3e289e1SNathan Whitehorn /* Limit of size_t. */
180c3e289e1SNathan Whitehorn #define	SIZE_MAX	UINT64_MAX
181c3e289e1SNathan Whitehorn #else
18249545b38SMike Barcroft /* Limits of ptrdiff_t. */
18349545b38SMike Barcroft #define	PTRDIFF_MIN	INT32_MIN
18449545b38SMike Barcroft #define	PTRDIFF_MAX	INT32_MAX
18549545b38SMike Barcroft 
18649545b38SMike Barcroft /* Limits of sig_atomic_t. */
18749545b38SMike Barcroft #define	SIG_ATOMIC_MIN	INT32_MIN
18849545b38SMike Barcroft #define	SIG_ATOMIC_MAX	INT32_MAX
18949545b38SMike Barcroft 
19049545b38SMike Barcroft /* Limit of size_t. */
19149545b38SMike Barcroft #define	SIZE_MAX	UINT32_MAX
192c3e289e1SNathan Whitehorn #endif
19349545b38SMike Barcroft 
19449545b38SMike Barcroft /* Limits of wint_t. */
19549545b38SMike Barcroft #define	WINT_MIN	INT32_MIN
19649545b38SMike Barcroft #define	WINT_MAX	INT32_MAX
19749545b38SMike Barcroft 
19849545b38SMike Barcroft #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
19949545b38SMike Barcroft 
20049545b38SMike Barcroft #endif /* !_MACHINE__STDINT_H_ */
201