xref: /freebsd/sys/x86/include/_limits.h (revision 29363fb446372cb3f10bc98664e9767c53fbb457)
18cfa93e4STijl Coosemans /*-
2*51369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
3*51369649SPedro F. Giffuni  *
48cfa93e4STijl Coosemans  * Copyright (c) 1988, 1993
58cfa93e4STijl Coosemans  *	The Regents of the University of California.  All rights reserved.
68cfa93e4STijl Coosemans  *
78cfa93e4STijl Coosemans  * Redistribution and use in source and binary forms, with or without
88cfa93e4STijl Coosemans  * modification, are permitted provided that the following conditions
98cfa93e4STijl Coosemans  * are met:
108cfa93e4STijl Coosemans  * 1. Redistributions of source code must retain the above copyright
118cfa93e4STijl Coosemans  *    notice, this list of conditions and the following disclaimer.
128cfa93e4STijl Coosemans  * 2. Redistributions in binary form must reproduce the above copyright
138cfa93e4STijl Coosemans  *    notice, this list of conditions and the following disclaimer in the
148cfa93e4STijl Coosemans  *    documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
168cfa93e4STijl Coosemans  *    may be used to endorse or promote products derived from this software
178cfa93e4STijl Coosemans  *    without specific prior written permission.
188cfa93e4STijl Coosemans  *
198cfa93e4STijl Coosemans  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
208cfa93e4STijl Coosemans  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
218cfa93e4STijl Coosemans  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
228cfa93e4STijl Coosemans  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
238cfa93e4STijl Coosemans  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
248cfa93e4STijl Coosemans  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
258cfa93e4STijl Coosemans  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
268cfa93e4STijl Coosemans  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
278cfa93e4STijl Coosemans  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
288cfa93e4STijl Coosemans  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
298cfa93e4STijl Coosemans  * SUCH DAMAGE.
308cfa93e4STijl Coosemans  */
318cfa93e4STijl Coosemans 
328cfa93e4STijl Coosemans #ifndef	_MACHINE__LIMITS_H_
338cfa93e4STijl Coosemans #define	_MACHINE__LIMITS_H_
348cfa93e4STijl Coosemans 
358cfa93e4STijl Coosemans /*
368cfa93e4STijl Coosemans  * According to ANSI (section 2.2.4.2), the values below must be usable by
378cfa93e4STijl Coosemans  * #if preprocessing directives.  Additionally, the expression must have the
388cfa93e4STijl Coosemans  * same type as would an expression that is an object of the corresponding
398cfa93e4STijl Coosemans  * type converted according to the integral promotions.  The subtraction for
408cfa93e4STijl Coosemans  * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
418cfa93e4STijl Coosemans  * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
428cfa93e4STijl Coosemans  */
438cfa93e4STijl Coosemans 
448cfa93e4STijl Coosemans #define	__CHAR_BIT	8		/* number of bits in a char */
458cfa93e4STijl Coosemans 
468cfa93e4STijl Coosemans #define	__SCHAR_MAX	0x7f		/* max value for a signed char */
478cfa93e4STijl Coosemans #define	__SCHAR_MIN	(-0x7f - 1)	/* min value for a signed char */
488cfa93e4STijl Coosemans 
498cfa93e4STijl Coosemans #define	__UCHAR_MAX	0xff		/* max value for an unsigned char */
508cfa93e4STijl Coosemans 
518cfa93e4STijl Coosemans #define	__USHRT_MAX	0xffff		/* max value for an unsigned short */
528cfa93e4STijl Coosemans #define	__SHRT_MAX	0x7fff		/* max value for a short */
538cfa93e4STijl Coosemans #define	__SHRT_MIN	(-0x7fff - 1)	/* min value for a short */
548cfa93e4STijl Coosemans 
558cfa93e4STijl Coosemans #define	__UINT_MAX	0xffffffff	/* max value for an unsigned int */
568cfa93e4STijl Coosemans #define	__INT_MAX	0x7fffffff	/* max value for an int */
578cfa93e4STijl Coosemans #define	__INT_MIN	(-0x7fffffff - 1)	/* min value for an int */
588cfa93e4STijl Coosemans 
598bed40c9SDavid E. O'Brien #ifdef	__LP64__
608cfa93e4STijl Coosemans #define	__ULONG_MAX	0xffffffffffffffff	/* max for an unsigned long */
618cfa93e4STijl Coosemans #define	__LONG_MAX	0x7fffffffffffffff	/* max for a long */
628cfa93e4STijl Coosemans #define	__LONG_MIN	(-0x7fffffffffffffff - 1) /* min for a long */
638cfa93e4STijl Coosemans #else
648cfa93e4STijl Coosemans #define	__ULONG_MAX	0xffffffffUL
658cfa93e4STijl Coosemans #define	__LONG_MAX	0x7fffffffL
668cfa93e4STijl Coosemans #define	__LONG_MIN	(-0x7fffffffL - 1)
678cfa93e4STijl Coosemans #endif
688cfa93e4STijl Coosemans 
698cfa93e4STijl Coosemans 			/* max value for an unsigned long long */
708cfa93e4STijl Coosemans #define	__ULLONG_MAX	0xffffffffffffffffULL
718cfa93e4STijl Coosemans #define	__LLONG_MAX	0x7fffffffffffffffLL	/* max value for a long long */
728cfa93e4STijl Coosemans #define	__LLONG_MIN	(-0x7fffffffffffffffLL - 1)  /* min for a long long */
738cfa93e4STijl Coosemans 
748bed40c9SDavid E. O'Brien #ifdef	__LP64__
758cfa93e4STijl Coosemans #define	__SSIZE_MAX	__LONG_MAX	/* max value for a ssize_t */
768cfa93e4STijl Coosemans #define	__SIZE_T_MAX	__ULONG_MAX	/* max value for a size_t */
778cfa93e4STijl Coosemans #define	__OFF_MAX	__LONG_MAX	/* max value for an off_t */
788cfa93e4STijl Coosemans #define	__OFF_MIN	__LONG_MIN	/* min value for an off_t */
798cfa93e4STijl Coosemans /* Quads and longs are the same on the amd64.  Ensure they stay in sync. */
808cfa93e4STijl Coosemans #define	__UQUAD_MAX	__ULONG_MAX	/* max value for a uquad_t */
818cfa93e4STijl Coosemans #define	__QUAD_MAX	__LONG_MAX	/* max value for a quad_t */
828cfa93e4STijl Coosemans #define	__QUAD_MIN	__LONG_MIN	/* min value for a quad_t */
838cfa93e4STijl Coosemans #define	__LONG_BIT	64
848cfa93e4STijl Coosemans #else
858cfa93e4STijl Coosemans #define	__SSIZE_MAX	__INT_MAX
868cfa93e4STijl Coosemans #define	__SIZE_T_MAX	__UINT_MAX
878cfa93e4STijl Coosemans #define	__OFF_MAX	__LLONG_MAX
888cfa93e4STijl Coosemans #define	__OFF_MIN	__LLONG_MIN
898cfa93e4STijl Coosemans #define	__UQUAD_MAX	__ULLONG_MAX
908cfa93e4STijl Coosemans #define	__QUAD_MAX	__LLONG_MAX
918cfa93e4STijl Coosemans #define	__QUAD_MIN	__LLONG_MIN
928cfa93e4STijl Coosemans #define	__LONG_BIT	32
938cfa93e4STijl Coosemans #endif
948cfa93e4STijl Coosemans 
958cfa93e4STijl Coosemans #define	__WORD_BIT	32
968cfa93e4STijl Coosemans 
978cfa93e4STijl Coosemans /* Minimum signal stack size. */
988cfa93e4STijl Coosemans #define	__MINSIGSTKSZ	(512 * 4)
998cfa93e4STijl Coosemans 
1008cfa93e4STijl Coosemans #endif /* !_MACHINE__LIMITS_H_ */
101