xref: /freebsd/sys/i386/include/limits.h (revision 26f9a767)
15b81b6b3SRodney W. Grimes /*
226f9a767SRodney W. Grimes  * Copyright (c) 1988, 1993
326f9a767SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
45b81b6b3SRodney W. Grimes  *
55b81b6b3SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
65b81b6b3SRodney W. Grimes  * modification, are permitted provided that the following conditions
75b81b6b3SRodney W. Grimes  * are met:
85b81b6b3SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
95b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
105b81b6b3SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
115b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
125b81b6b3SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
135b81b6b3SRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
145b81b6b3SRodney W. Grimes  *    must display the following acknowledgement:
155b81b6b3SRodney W. Grimes  *	This product includes software developed by the University of
165b81b6b3SRodney W. Grimes  *	California, Berkeley and its contributors.
175b81b6b3SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
185b81b6b3SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
195b81b6b3SRodney W. Grimes  *    without specific prior written permission.
205b81b6b3SRodney W. Grimes  *
215b81b6b3SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
225b81b6b3SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
235b81b6b3SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
245b81b6b3SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
255b81b6b3SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
265b81b6b3SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
275b81b6b3SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
285b81b6b3SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
295b81b6b3SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
305b81b6b3SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
315b81b6b3SRodney W. Grimes  * SUCH DAMAGE.
325b81b6b3SRodney W. Grimes  *
3326f9a767SRodney W. Grimes  *	@(#)limits.h	8.3 (Berkeley) 1/4/94
345b81b6b3SRodney W. Grimes  */
355b81b6b3SRodney W. Grimes 
366e393973SGarrett Wollman #ifndef _MACHINE_LIMITS_H_
376e393973SGarrett Wollman #define _MACHINE_LIMITS_H_ 1
386e393973SGarrett Wollman 
395b81b6b3SRodney W. Grimes #define	CHAR_BIT	8		/* number of bits in a char */
4026f9a767SRodney W. Grimes #define	MB_LEN_MAX	6		/* Allow 31 bit UTF2 */
415b81b6b3SRodney W. Grimes 
425b81b6b3SRodney W. Grimes 
4326f9a767SRodney W. Grimes #define	CLK_TCK		128		/* ticks per second */
445b81b6b3SRodney W. Grimes 
4526f9a767SRodney W. Grimes /*
4626f9a767SRodney W. Grimes  * According to ANSI (section 2.2.4.2), the values below must be usable by
4726f9a767SRodney W. Grimes  * #if preprocessing directives.  Additionally, the expression must have the
4826f9a767SRodney W. Grimes  * same type as would an expression that is an object of the corresponding
4926f9a767SRodney W. Grimes  * type converted according to the integral promotions.  The subtraction for
5026f9a767SRodney W. Grimes  * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
5126f9a767SRodney W. Grimes  * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
5226f9a767SRodney W. Grimes  * These numbers work for pcc as well.  The UINT_MAX and ULONG_MAX values
5326f9a767SRodney W. Grimes  * are written as hex so that GCC will be quiet about large integer constants.
5426f9a767SRodney W. Grimes  */
5526f9a767SRodney W. Grimes #define	SCHAR_MAX	127		/* min value for a signed char */
5626f9a767SRodney W. Grimes #define	SCHAR_MIN	(-128)		/* max value for a signed char */
5726f9a767SRodney W. Grimes 
5826f9a767SRodney W. Grimes #define	UCHAR_MAX	255		/* max value for an unsigned char */
5926f9a767SRodney W. Grimes #define	CHAR_MAX	127		/* max value for a char */
6026f9a767SRodney W. Grimes #define	CHAR_MIN	(-128)		/* min value for a char */
6126f9a767SRodney W. Grimes 
6226f9a767SRodney W. Grimes #define	USHRT_MAX	65535		/* max value for an unsigned short */
6326f9a767SRodney W. Grimes #define	SHRT_MAX	32767		/* max value for a short */
6426f9a767SRodney W. Grimes #define	SHRT_MIN	(-32768)	/* min value for a short */
655b81b6b3SRodney W. Grimes 
665b81b6b3SRodney W. Grimes #define	UINT_MAX	0xffffffff	/* max value for an unsigned int */
6726f9a767SRodney W. Grimes #define	INT_MAX		2147483647	/* max value for an int */
6826f9a767SRodney W. Grimes #define	INT_MIN		(-2147483647-1)	/* min value for an int */
695b81b6b3SRodney W. Grimes 
705b81b6b3SRodney W. Grimes #define	ULONG_MAX	0xffffffff	/* max value for an unsigned long */
7126f9a767SRodney W. Grimes #define	LONG_MAX	2147483647	/* max value for a long */
7226f9a767SRodney W. Grimes #define	LONG_MIN	(-2147483647-1)	/* min value for a long */
7390d795a1SAndrew Moore 
7426f9a767SRodney W. Grimes #if !defined(_ANSI_SOURCE)
7526f9a767SRodney W. Grimes #define	SSIZE_MAX	INT_MAX		/* max value for a ssize_t */
7626f9a767SRodney W. Grimes 
7726f9a767SRodney W. Grimes #if !defined(_POSIX_SOURCE)
7826f9a767SRodney W. Grimes #define	SIZE_T_MAX	UINT_MAX	/* max value for a size_t */
7926f9a767SRodney W. Grimes 
8026f9a767SRodney W. Grimes /* GCC requires that quad constants be written as expressions. */
8126f9a767SRodney W. Grimes #define	UQUAD_MAX	((u_quad_t)0-1)	/* max value for a uquad_t */
8226f9a767SRodney W. Grimes 					/* max value for a quad_t */
8326f9a767SRodney W. Grimes #define	QUAD_MAX	((quad_t)(UQUAD_MAX >> 1))
8426f9a767SRodney W. Grimes #define	QUAD_MIN	(-QUAD_MAX-1)	/* min value for a quad_t */
8526f9a767SRodney W. Grimes 
8626f9a767SRodney W. Grimes #endif /* !_POSIX_SOURCE */
8726f9a767SRodney W. Grimes #endif /* !_ANSI_SOURCE */
8890d795a1SAndrew Moore 
896e393973SGarrett Wollman #endif /* _MACHINE_LIMITS_H_ */
90