limits.h revision 87567
187567Sobrien/*
287567Sobrien * Copyright (c) 1988, 1993
387567Sobrien *	The Regents of the University of California.  All rights reserved.
487567Sobrien *
587567Sobrien * Redistribution and use in source and binary forms, with or without
687567Sobrien * modification, are permitted provided that the following conditions
787567Sobrien * are met:
887567Sobrien * 1. Redistributions of source code must retain the above copyright
987567Sobrien *    notice, this list of conditions and the following disclaimer.
1087567Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1187567Sobrien *    notice, this list of conditions and the following disclaimer in the
1287567Sobrien *    documentation and/or other materials provided with the distribution.
1387567Sobrien * 3. All advertising materials mentioning features or use of this software
1487567Sobrien *    must display the following acknowledgement:
1587567Sobrien *	This product includes software developed by the University of
1687567Sobrien *	California, Berkeley and its contributors.
1787567Sobrien * 4. Neither the name of the University nor the names of its contributors
1887567Sobrien *    may be used to endorse or promote products derived from this software
1987567Sobrien *    without specific prior written permission.
2087567Sobrien *
2187567Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2287567Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2387567Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2487567Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2587567Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2687567Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2787567Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2887567Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2987567Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3087567Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3187567Sobrien * SUCH DAMAGE.
3287567Sobrien *
3387567Sobrien *	@(#)limits.h	8.3 (Berkeley) 1/4/94
3487567Sobrien * $FreeBSD: head/sys/arm/include/limits.h 87567 2001-12-09 18:30:04Z obrien $
3587567Sobrien */
3687567Sobrien
3787567Sobrien#ifndef _MACHINE_LIMITS_H_
3887567Sobrien#define	_MACHINE_LIMITS_H_
3987567Sobrien
4087567Sobrien#define	CHAR_BIT	8		/* number of bits in a char */
4187567Sobrien#define	MB_LEN_MAX	6		/* Allow 31 bit UTF2 */
4287567Sobrien
4387567Sobrien/*
4487567Sobrien * According to ANSI (section 2.2.4.2), the values below must be usable by
4587567Sobrien * #if preprocessing directives.  Additionally, the expression must have the
4687567Sobrien * same type as would an expression that is an object of the corresponding
4787567Sobrien * type converted according to the integral promotions.  The subtraction for
4887567Sobrien * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
4987567Sobrien * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
5087567Sobrien * These numbers are for the default configuration of gcc.  They work for
5187567Sobrien * some other compilers as well, but this should not be depended on.
5287567Sobrien */
5387567Sobrien#define	SCHAR_MAX	0x7f		/* max value for a signed char */
5487567Sobrien#define	SCHAR_MIN	(-0x7f - 1)	/* min value for a signed char */
5587567Sobrien
5687567Sobrien#define	UCHAR_MAX	0xff		/* max value for an unsigned char */
5787567Sobrien
5887567Sobrien#ifdef __CHAR_UNSIGNED__
5987567Sobrien#define	CHAR_MAX	UCHAR_MAX	/* max value for a char */
6087567Sobrien#define	CHAR_MIN	0		/* min value for a char */
6187567Sobrien#else
6287567Sobrien#define	CHAR_MAX	SCHAR_MAX	/* max value for a char */
6387567Sobrien#define	CHAR_MIN	SCHAR_MIN	/* min value for a char */
6487567Sobrien#endif
6587567Sobrien
6687567Sobrien#define	USHRT_MAX	0xffff		/* max value for an unsigned short */
6787567Sobrien#define	SHRT_MAX	0x7fff		/* max value for a short */
6887567Sobrien#define	SHRT_MIN	(-0x7fff - 1)	/* min value for a short */
6987567Sobrien
7087567Sobrien#define	UINT_MAX	0xffffffffU	/* max value for an unsigned int */
7187567Sobrien#define	INT_MAX		0x7fffffff	/* max value for an int */
7287567Sobrien#define	INT_MIN		(-0x7fffffff - 1)	/* min value for an int */
7387567Sobrien
7487567Sobrien/* Bad hack for gcc configured to give 64-bit longs. */
7587567Sobrien#ifdef _LARGE_LONG
7687567Sobrien#define	ULONG_MAX	0xffffffffffffffffUL
7787567Sobrien#define	LONG_MAX	0x7fffffffffffffffL
7887567Sobrien#define	LONG_MIN	(-0x7fffffffffffffffL - 1)
7987567Sobrien#else
8087567Sobrien#define	ULONG_MAX	0xffffffffUL	/* max value for an unsigned long */
8187567Sobrien#define	LONG_MAX	0x7fffffffL	/* max value for a long */
8287567Sobrien#define	LONG_MIN	(-0x7fffffffL - 1)	/* min value for a long */
8387567Sobrien#endif
8487567Sobrien
8587567Sobrien			/* max value for an unsigned long long */
8687567Sobrien#define	ULLONG_MAX	0xffffffffffffffffULL
8787567Sobrien#define	LLONG_MAX	0x7fffffffffffffffLL	/* max value for a long long */
8887567Sobrien#define	LLONG_MIN	(-0x7fffffffffffffffLL - 1)  /* min for a long long */
8987567Sobrien
9087567Sobrien#if !defined(_ANSI_SOURCE)
9187567Sobrien#define	SSIZE_MAX	INT_MAX		/* max value for a ssize_t */
9287567Sobrien
9387567Sobrien#if !defined(_POSIX_SOURCE)
9487567Sobrien#define	SIZE_T_MAX	UINT_MAX	/* max value for a size_t */
9587567Sobrien
9687567Sobrien#define	OFF_MAX		LLONG_MAX	/* max value for a off_t */
9787567Sobrien#define	OFF_MIN		LLONG_MIN	/* min value for a off_t */
9887567Sobrien
9987567Sobrien/* Quads and long longs are the same size.  Ensure they stay in sync. */
10087567Sobrien#define	UQUAD_MAX	ULLONG_MAX	/* max value for a uquad_t */
10187567Sobrien#define	QUAD_MAX	LLONG_MAX	/* max value for a quad_t */
10287567Sobrien#define	QUAD_MIN	LLONG_MIN	/* min value for a quad_t */
10387567Sobrien
10487567Sobrien#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
10587567Sobrien/*
10687567Sobrien * ISO/IEC 9899:1999
10787567Sobrien * 7.18.2.1 Limits of exact-width integer types
10887567Sobrien */
10987567Sobrien/* Minimum values of exact-width signed integer types. */
11087567Sobrien#define	INT8_MIN	(-0x7f-1)
11187567Sobrien#define	INT16_MIN	(-0x7fff-1)
11287567Sobrien#define	INT32_MIN	(-0x7fffffff-1)
11387567Sobrien#define	INT64_MIN	(-0x7fffffffffffffffLL-1)
11487567Sobrien
11587567Sobrien/* Maximum values of exact-width signed integer types. */
11687567Sobrien#define	INT8_MAX	0x7f
11787567Sobrien#define	INT16_MAX	0x7fff
11887567Sobrien#define	INT32_MAX	0x7fffffff
11987567Sobrien#define	INT64_MAX	0x7fffffffffffffffLL
12087567Sobrien
12187567Sobrien/* Maximum values of exact-width unsigned integer types. */
12287567Sobrien#define	UINT8_MAX	0xff
12387567Sobrien#define	UINT16_MAX	0xffff
12487567Sobrien#define	UINT32_MAX	0xffffffffU
12587567Sobrien#define	UINT64_MAX	0xffffffffffffffffULL
12687567Sobrien
12787567Sobrien/*
12887567Sobrien * ISO/IEC 9899:1999
12987567Sobrien * 7.18.2.2  Limits of minimum-width integer types
13087567Sobrien */
13187567Sobrien/* Minimum values of minimum-width signed integer types. */
13287567Sobrien#define	INT_LEAST8_MIN	SCHAR_MIN
13387567Sobrien#define	INT_LEAST16_MIN	SHRT_MIN
13487567Sobrien#define	INT_LEAST32_MIN	INT_MIN
13587567Sobrien#define	INT_LEAST64_MIN	LLONG_MIN
13687567Sobrien
13787567Sobrien/* Maximum values of minimum-width signed integer types. */
13887567Sobrien#define	INT_LEAST8_MAX	SCHAR_MAX
13987567Sobrien#define	INT_LEAST16_MAX	SHRT_MAX
14087567Sobrien#define	INT_LEAST32_MAX	INT_MAX
14187567Sobrien#define	INT_LEAST64_MAX	LLONG_MAX
14287567Sobrien
14387567Sobrien/* Maximum values of minimum-width unsigned integer types. */
14487567Sobrien#define	UINT_LEAST8_MAX	 UCHAR_MAX
14587567Sobrien#define	UINT_LEAST16_MAX USHRT_MAX
14687567Sobrien#define	UINT_LEAST32_MAX UINT_MAX
14787567Sobrien#define	UINT_LEAST64_MAX ULLONG_MAX
14887567Sobrien
14987567Sobrien/*
15087567Sobrien * ISO/IEC 9899:1999
15187567Sobrien * 7.18.2.3  Limits of fastest minimum-width integer types
15287567Sobrien */
15387567Sobrien/* Minimum values of fastest minimum-width signed integer types. */
15487567Sobrien#define	INT_FAST8_MIN	INT_MIN
15587567Sobrien#define	INT_FAST16_MIN	INT_MIN
15687567Sobrien#define	INT_FAST32_MIN	INT_MIN
15787567Sobrien#define	INT_FAST64_MIN	LLONG_MIN
15887567Sobrien
15987567Sobrien/* Maximum values of fastest minimum-width signed integer types. */
16087567Sobrien#define	INT_FAST8_MAX	INT_MAX
16187567Sobrien#define	INT_FAST16_MAX	INT_MAX
16287567Sobrien#define	INT_FAST32_MAX	INT_MAX
16387567Sobrien#define	INT_FAST64_MAX	LLONG_MAX
16487567Sobrien
16587567Sobrien/* Maximum values of fastest minimum-width unsigned integer types. */
16687567Sobrien#define	UINT_FAST8_MAX	UINT_MAX
16787567Sobrien#define	UINT_FAST16_MAX	UINT_MAX
16887567Sobrien#define	UINT_FAST32_MAX	UINT_MAX
16987567Sobrien#define	UINT_FAST64_MAX	ULLONG_MAX
17087567Sobrien
17187567Sobrien/*
17287567Sobrien * ISO/IEC 9899:1999
17387567Sobrien * 7.18.2.4  Limits of integer types capable of holding object pointers
17487567Sobrien */
17587567Sobrien#define	INTPTR_MIN	INT_MIN
17687567Sobrien#define	INTPTR_MAX	INT_MAX
17787567Sobrien#define	UINTPTR_MAX	UINT_MAX
17887567Sobrien
17987567Sobrien/*
18087567Sobrien * ISO/IEC 9899:1999
18187567Sobrien * 7.18.2.5  Limits of greatest-width integer types
18287567Sobrien */
18387567Sobrien#define	INTMAX_MIN	LLONG_MIN
18487567Sobrien#define	INTMAX_MAX	LLONG_MAX
18587567Sobrien#define	UINTMAX_MAX	ULLONG_MAX
18687567Sobrien
18787567Sobrien/*
18887567Sobrien * ISO/IEC 9899:1999
18987567Sobrien * 7.18.3  Limits of other integer types
19087567Sobrien */
19187567Sobrien/* Limits of ptrdiff_t. */
19287567Sobrien#define	PTRDIFF_MIN	INT_MIN
19387567Sobrien#define	PTRDIFF_MAX	INT_MAX
19487567Sobrien
19587567Sobrien/* Limits of sig_atomic_t. */
19687567Sobrien#define	SIG_ATOMIC_MIN	INT_MIN
19787567Sobrien#define	SIG_ATOMIC_MAX	INT_MAX
19887567Sobrien
19987567Sobrien/* Limit of size_t. */
20087567Sobrien#define	SIZE_MAX	UINT_MAX
20187567Sobrien
20287567Sobrien#ifndef WCHAR_MIN /* Also possibly defined in <wchar.h> */
20387567Sobrien/* Limits of wchar_t. */
20487567Sobrien#define	WCHAR_MIN	INT_MIN
20587567Sobrien#define	WCHAR_MAX	INT_MAX
20687567Sobrien
20787567Sobrien/* Limits of wint_t. */
20887567Sobrien#define	WINT_MIN	INT_MIN
20987567Sobrien#define	WINT_MAX	INT_MAX
21087567Sobrien#endif
21187567Sobrien#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
21287567Sobrien#endif /* !_POSIX_SOURCE */
21387567Sobrien#endif /* !_ANSI_SOURCE */
21487567Sobrien
21587567Sobrien#endif /* !_MACHINE_LIMITS_H_ */
216