xref: /netbsd-src/sys/arch/amd64/include/int_limits.h (revision 63587e37ee62a993fb53e201ae81ff76361b4eb6)
1*63587e37Srillig /*	$NetBSD: int_limits.h,v 1.10 2021/04/17 20:12:55 rillig Exp $	*/
281918bf8Sfvdl 
381918bf8Sfvdl /*-
481918bf8Sfvdl  * Copyright (c) 2001 The NetBSD Foundation, Inc.
581918bf8Sfvdl  * All rights reserved.
681918bf8Sfvdl  *
781918bf8Sfvdl  * This code is derived from software contributed to The NetBSD Foundation
881918bf8Sfvdl  * by Klaus Klein.
981918bf8Sfvdl  *
1081918bf8Sfvdl  * Redistribution and use in source and binary forms, with or without
1181918bf8Sfvdl  * modification, are permitted provided that the following conditions
1281918bf8Sfvdl  * are met:
1381918bf8Sfvdl  * 1. Redistributions of source code must retain the above copyright
1481918bf8Sfvdl  *    notice, this list of conditions and the following disclaimer.
1581918bf8Sfvdl  * 2. Redistributions in binary form must reproduce the above copyright
1681918bf8Sfvdl  *    notice, this list of conditions and the following disclaimer in the
1781918bf8Sfvdl  *    documentation and/or other materials provided with the distribution.
1881918bf8Sfvdl  *
1981918bf8Sfvdl  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2081918bf8Sfvdl  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2181918bf8Sfvdl  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2281918bf8Sfvdl  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2381918bf8Sfvdl  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2481918bf8Sfvdl  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2581918bf8Sfvdl  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2681918bf8Sfvdl  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2781918bf8Sfvdl  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2881918bf8Sfvdl  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2981918bf8Sfvdl  * POSSIBILITY OF SUCH DAMAGE.
3081918bf8Sfvdl  */
3181918bf8Sfvdl 
3281918bf8Sfvdl #ifndef _AMD64_INT_LIMITS_H_
3381918bf8Sfvdl #define _AMD64_INT_LIMITS_H_
3481918bf8Sfvdl 
35d87708c5Sjoerg #ifdef __SIG_ATOMIC_MAX__
36d87708c5Sjoerg #include <sys/common_int_limits.h>
37d87708c5Sjoerg #else
38d87708c5Sjoerg 
39433b5ddeSmrg #ifdef __x86_64__
40433b5ddeSmrg 
4181918bf8Sfvdl /*
4281918bf8Sfvdl  * 7.18.2 Limits of specified-width integer types
4381918bf8Sfvdl  */
4481918bf8Sfvdl 
4581918bf8Sfvdl /* 7.18.2.1 Limits of exact-width integer types */
4681918bf8Sfvdl 
4781918bf8Sfvdl /* minimum values of exact-width signed integer types */
4881918bf8Sfvdl #define	INT8_MIN	(-0x7f-1)			/* int8_t	  */
4981918bf8Sfvdl #define	INT16_MIN	(-0x7fff-1)			/* int16_t	  */
5081918bf8Sfvdl #define	INT32_MIN	(-0x7fffffff-1)			/* int32_t	  */
5181918bf8Sfvdl #define	INT64_MIN	(-0x7fffffffffffffffL-1)	/* int64_t	  */
5281918bf8Sfvdl 
5381918bf8Sfvdl /* maximum values of exact-width signed integer types */
5481918bf8Sfvdl #define	INT8_MAX	0x7f				/* int8_t	  */
5581918bf8Sfvdl #define	INT16_MAX	0x7fff				/* int16_t	  */
5681918bf8Sfvdl #define	INT32_MAX	0x7fffffff			/* int32_t	  */
5781918bf8Sfvdl #define	INT64_MAX	0x7fffffffffffffffL		/* int64_t	  */
5881918bf8Sfvdl 
5981918bf8Sfvdl /* maximum values of exact-width unsigned integer types */
600e0fe2c3Sdrochner #define	UINT8_MAX	0xff				/* uint8_t	  */
610e0fe2c3Sdrochner #define	UINT16_MAX	0xffff				/* uint16_t	  */
6281918bf8Sfvdl #define	UINT32_MAX	0xffffffffU			/* uint32_t	  */
6381918bf8Sfvdl #define	UINT64_MAX	0xffffffffffffffffUL		/* uint64_t	  */
6481918bf8Sfvdl 
6581918bf8Sfvdl /* 7.18.2.2 Limits of minimum-width integer types */
6681918bf8Sfvdl 
6781918bf8Sfvdl /* minimum values of minimum-width signed integer types */
6881918bf8Sfvdl #define	INT_LEAST8_MIN	(-0x7f-1)			/* int_least8_t	  */
6981918bf8Sfvdl #define	INT_LEAST16_MIN	(-0x7fff-1)			/* int_least16_t  */
7081918bf8Sfvdl #define	INT_LEAST32_MIN	(-0x7fffffff-1)			/* int_least32_t  */
7181918bf8Sfvdl #define	INT_LEAST64_MIN	(-0x7fffffffffffffffL-1)	/* int_least64_t  */
7281918bf8Sfvdl 
7381918bf8Sfvdl /* maximum values of minimum-width signed integer types */
7481918bf8Sfvdl #define	INT_LEAST8_MAX	0x7f				/* int_least8_t	  */
7581918bf8Sfvdl #define	INT_LEAST16_MAX	0x7fff				/* int_least16_t  */
7681918bf8Sfvdl #define	INT_LEAST32_MAX	0x7fffffff			/* int_least32_t  */
7781918bf8Sfvdl #define	INT_LEAST64_MAX	0x7fffffffffffffffL		/* int_least64_t  */
7881918bf8Sfvdl 
7981918bf8Sfvdl /* maximum values of minimum-width unsigned integer types */
800e0fe2c3Sdrochner #define	UINT_LEAST8_MAX	 0xff				/* uint_least8_t  */
810e0fe2c3Sdrochner #define	UINT_LEAST16_MAX 0xffff				/* uint_least16_t */
8281918bf8Sfvdl #define	UINT_LEAST32_MAX 0xffffffffU			/* uint_least32_t */
8381918bf8Sfvdl #define	UINT_LEAST64_MAX 0xffffffffffffffffUL		/* uint_least64_t */
8481918bf8Sfvdl 
8581918bf8Sfvdl /* 7.18.2.3 Limits of fastest minimum-width integer types */
8681918bf8Sfvdl 
8781918bf8Sfvdl /* minimum values of fastest minimum-width signed integer types */
8881918bf8Sfvdl #define	INT_FAST8_MIN	(-0x7fffffff-1)			/* int_fast8_t	  */
8981918bf8Sfvdl #define	INT_FAST16_MIN	(-0x7fffffff-1)			/* int_fast16_t	  */
9081918bf8Sfvdl #define	INT_FAST32_MIN	(-0x7fffffff-1)			/* int_fast32_t	  */
9181918bf8Sfvdl #define	INT_FAST64_MIN	(-0x7fffffffffffffffLL-1)	/* int_fast64_t	  */
9281918bf8Sfvdl 
9381918bf8Sfvdl /* maximum values of fastest minimum-width signed integer types */
9481918bf8Sfvdl #define	INT_FAST8_MAX	0x7fffffff			/* int_fast8_t	  */
9581918bf8Sfvdl #define	INT_FAST16_MAX	0x7fffffff			/* int_fast16_t	  */
9681918bf8Sfvdl #define	INT_FAST32_MAX	0x7fffffff			/* int_fast32_t	  */
9781918bf8Sfvdl #define	INT_FAST64_MAX	0x7fffffffffffffffLL		/* int_fast64_t	  */
9881918bf8Sfvdl 
9981918bf8Sfvdl /* maximum values of fastest minimum-width unsigned integer types */
10081918bf8Sfvdl #define	UINT_FAST8_MAX	0xffffffffU			/* uint_fast8_t	  */
10181918bf8Sfvdl #define	UINT_FAST16_MAX	0xffffffffU			/* uint_fast16_t  */
10281918bf8Sfvdl #define	UINT_FAST32_MAX	0xffffffffU			/* uint_fast32_t  */
10381918bf8Sfvdl #define	UINT_FAST64_MAX	0xffffffffffffffffULL		/* uint_fast64_t  */
10481918bf8Sfvdl 
10581918bf8Sfvdl /* 7.18.2.4 Limits of integer types capable of holding object pointers */
10681918bf8Sfvdl 
10781918bf8Sfvdl #define	INTPTR_MIN	(-0x7fffffffffffffffL-1)	/* intptr_t	  */
10881918bf8Sfvdl #define	INTPTR_MAX	0x7fffffffffffffffL		/* intptr_t	  */
10981918bf8Sfvdl #define	UINTPTR_MAX	0xffffffffffffffffUL		/* uintptr_t	  */
11081918bf8Sfvdl 
11181918bf8Sfvdl /* 7.18.2.5 Limits of greatest-width integer types */
11281918bf8Sfvdl 
11381918bf8Sfvdl #define	INTMAX_MIN	(-0x7fffffffffffffffL-1)	/* intmax_t	  */
11481918bf8Sfvdl #define	INTMAX_MAX	0x7fffffffffffffffL		/* intmax_t	  */
11581918bf8Sfvdl #define	UINTMAX_MAX	0xffffffffffffffffUL		/* uintmax_t	  */
11681918bf8Sfvdl 
11781918bf8Sfvdl 
11881918bf8Sfvdl /*
11981918bf8Sfvdl  * 7.18.3 Limits of other integer types
12081918bf8Sfvdl  */
12181918bf8Sfvdl 
12281918bf8Sfvdl /* limits of ptrdiff_t */
12381918bf8Sfvdl #define	PTRDIFF_MIN	(-0x7fffffffffffffffL-1)	/* ptrdiff_t	  */
12481918bf8Sfvdl #define	PTRDIFF_MAX	0x7fffffffffffffffL		/* ptrdiff_t	  */
12581918bf8Sfvdl 
12681918bf8Sfvdl /* limits of sig_atomic_t */
1272ee3a9cdSchristos #define	SIG_ATOMIC_MIN	(-0x7fffffff-1)			/* sig_atomic_t	  */
1282ee3a9cdSchristos #define	SIG_ATOMIC_MAX	0x7fffffff			/* sig_atomic_t	  */
12981918bf8Sfvdl 
13081918bf8Sfvdl /* limit of size_t */
13181918bf8Sfvdl #define	SIZE_MAX	0xffffffffffffffffUL		/* size_t	  */
13281918bf8Sfvdl 
133433b5ddeSmrg #else	/*	__x86_64__	*/
134433b5ddeSmrg 
135433b5ddeSmrg #include <i386/int_limits.h>
136433b5ddeSmrg 
137433b5ddeSmrg #endif	/*	__x86_64__	*/
138433b5ddeSmrg 
139d87708c5Sjoerg #endif
140d87708c5Sjoerg 
14181918bf8Sfvdl #endif /* !_AMD64_INT_LIMITS_H_ */
142