limits.h revision 1817
1155408Srwatson/*
2155408Srwatson * Copyright (c) 1988, 1993
3155408Srwatson *	The Regents of the University of California.  All rights reserved.
4155408Srwatson *
5155408Srwatson * Redistribution and use in source and binary forms, with or without
6155408Srwatson * modification, are permitted provided that the following conditions
7155408Srwatson * are met:
8155408Srwatson * 1. Redistributions of source code must retain the above copyright
9155408Srwatson *    notice, this list of conditions and the following disclaimer.
10155408Srwatson * 2. Redistributions in binary form must reproduce the above copyright
11155408Srwatson *    notice, this list of conditions and the following disclaimer in the
12155408Srwatson *    documentation and/or other materials provided with the distribution.
13155408Srwatson * 3. All advertising materials mentioning features or use of this software
14155408Srwatson *    must display the following acknowledgement:
15155408Srwatson *	This product includes software developed by the University of
16155408Srwatson *	California, Berkeley and its contributors.
17155408Srwatson * 4. Neither the name of the University nor the names of its contributors
18155408Srwatson *    may be used to endorse or promote products derived from this software
19155408Srwatson *    without specific prior written permission.
20155408Srwatson *
21155408Srwatson * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22155408Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23155408Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24155408Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25155408Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26155408Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27155408Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28155408Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29155408Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30155408Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31155408Srwatson * SUCH DAMAGE.
32155408Srwatson *
33155408Srwatson *	@(#)limits.h	8.3 (Berkeley) 1/4/94
34155408Srwatson * $Id$
35155408Srwatson */
36155408Srwatson
37155408Srwatson#ifndef _MACHINE_LIMITS_H_
38155408Srwatson#define _MACHINE_LIMITS_H_ 1
39155408Srwatson
40155408Srwatson#define	CHAR_BIT	8		/* number of bits in a char */
41155408Srwatson#define	MB_LEN_MAX	6		/* Allow 31 bit UTF2 */
42155408Srwatson
43155408Srwatson
44155408Srwatson#define	CLK_TCK		128		/* ticks per second */
45155408Srwatson
46155408Srwatson/*
47155408Srwatson * According to ANSI (section 2.2.4.2), the values below must be usable by
48155408Srwatson * #if preprocessing directives.  Additionally, the expression must have the
49155408Srwatson * same type as would an expression that is an object of the corresponding
50155408Srwatson * type converted according to the integral promotions.  The subtraction for
51156880Srwatson * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
52155408Srwatson * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
53155408Srwatson * These numbers work for pcc as well.  The UINT_MAX and ULONG_MAX values
54155408Srwatson * are written as hex so that GCC will be quiet about large integer constants.
55155408Srwatson */
56155408Srwatson#define	SCHAR_MAX	127		/* min value for a signed char */
57155408Srwatson#define	SCHAR_MIN	(-128)		/* max value for a signed char */
58159269Srwatson
59159269Srwatson#define	UCHAR_MAX	255		/* max value for an unsigned char */
60155408Srwatson#define	CHAR_MAX	127		/* max value for a char */
61155408Srwatson#define	CHAR_MIN	(-128)		/* min value for a char */
62155408Srwatson
63155408Srwatson#define	USHRT_MAX	65535		/* max value for an unsigned short */
64155408Srwatson#define	SHRT_MAX	32767		/* max value for a short */
65155408Srwatson#define	SHRT_MIN	(-32768)	/* min value for a short */
66155408Srwatson
67155408Srwatson#define	UINT_MAX	0xffffffff	/* max value for an unsigned int */
68159269Srwatson#define	INT_MAX		2147483647	/* max value for an int */
69159269Srwatson#define	INT_MIN		(-2147483647-1)	/* min value for an int */
70155408Srwatson
71155408Srwatson#define	ULONG_MAX	0xffffffff	/* max value for an unsigned long */
72155408Srwatson#define	LONG_MAX	2147483647	/* max value for a long */
73155408Srwatson#define	LONG_MIN	(-2147483647-1)	/* min value for a long */
74156883Srwatson
75156880Srwatson#if !defined(_ANSI_SOURCE)
76155408Srwatson#define	SSIZE_MAX	INT_MAX		/* max value for a ssize_t */
77155408Srwatson
78155408Srwatson#if !defined(_POSIX_SOURCE)
79155408Srwatson#define	SIZE_T_MAX	UINT_MAX	/* max value for a size_t */
80155408Srwatson
81155408Srwatson/* GCC requires that quad constants be written as expressions. */
82155408Srwatson#define	UQUAD_MAX	((u_quad_t)0-1)	/* max value for a uquad_t */
83155408Srwatson					/* max value for a quad_t */
84155408Srwatson#define	QUAD_MAX	((quad_t)(UQUAD_MAX >> 1))
85155408Srwatson#define	QUAD_MIN	(-QUAD_MAX-1)	/* min value for a quad_t */
86155408Srwatson
87155408Srwatson#endif /* !_POSIX_SOURCE */
88159269Srwatson#endif /* !_ANSI_SOURCE */
89159269Srwatson
90159269Srwatson#endif /* _MACHINE_LIMITS_H_ */
91159269Srwatson