limits.h revision 1.10
11.10Sskrll/*	$NetBSD: limits.h,v 1.10 2008/09/13 07:30:59 skrll Exp $	*/
21.1Sfredette
31.1Sfredette/*	$OpenBSD: limits.h,v 1.2 2000/07/31 20:06:02 millert Exp $	*/
41.1Sfredette
51.1Sfredette/*
61.1Sfredette * Copyright (c) 1992-1994, The University of Utah and
71.1Sfredette * the Computer Systems Laboratory at the University of Utah (CSL).
81.1Sfredette * All rights reserved.
91.1Sfredette *
101.1Sfredette * Permission to use, copy, modify and distribute this software is hereby
111.1Sfredette * granted provided that (1) source code retains these copyright, permission,
121.1Sfredette * and disclaimer notices, and (2) redistributions including binaries
131.1Sfredette * reproduce the notices in supporting documentation, and (3) all advertising
141.1Sfredette * materials mentioning features or use of this software display the following
151.1Sfredette * acknowledgement: ``This product includes software developed by the
161.1Sfredette * Computer Systems Laboratory at the University of Utah.''
171.1Sfredette *
181.1Sfredette * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
191.1Sfredette * IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
201.1Sfredette * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
211.1Sfredette *
221.1Sfredette * CSL requests users of this software to return to csl-dist@cs.utah.edu any
231.1Sfredette * improvements that they make and grant CSL redistribution rights.
241.1Sfredette *
251.1Sfredette * 	Utah $Hdr: limits.h 1.6 94/12/16$
261.1Sfredette */
271.1Sfredette
281.1Sfredette/*
291.1Sfredette * Copyright (c) 1988, 1993
301.1Sfredette *	The Regents of the University of California.  All rights reserved.
311.1Sfredette *
321.1Sfredette * Redistribution and use in source and binary forms, with or without
331.1Sfredette * modification, are permitted provided that the following conditions
341.1Sfredette * are met:
351.1Sfredette * 1. Redistributions of source code must retain the above copyright
361.1Sfredette *    notice, this list of conditions and the following disclaimer.
371.1Sfredette * 2. Redistributions in binary form must reproduce the above copyright
381.1Sfredette *    notice, this list of conditions and the following disclaimer in the
391.1Sfredette *    documentation and/or other materials provided with the distribution.
401.4Sagc * 3. Neither the name of the University nor the names of its contributors
411.1Sfredette *    may be used to endorse or promote products derived from this software
421.1Sfredette *    without specific prior written permission.
431.1Sfredette *
441.1Sfredette * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
451.1Sfredette * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
461.1Sfredette * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
471.1Sfredette * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
481.1Sfredette * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
491.1Sfredette * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
501.1Sfredette * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
511.1Sfredette * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
521.1Sfredette * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
531.1Sfredette * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
541.1Sfredette * SUCH DAMAGE.
551.1Sfredette *
561.1Sfredette *	@(#)limits.h	8.3 (Berkeley) 1/4/94
571.1Sfredette */
581.1Sfredette
591.9Sskrll#ifndef	_MACHINE_LIMITS_H_
601.9Sskrll#define	_MACHINE_LIMITS_H_
611.9Sskrll
621.3Sbjh21#include <sys/featuretest.h>
631.3Sbjh21
641.1Sfredette#define	CHAR_BIT	8		/* number of bits in a char */
651.1Sfredette#define	MB_LEN_MAX	6		/* Allow 31 bit UTF2 */
661.1Sfredette
671.1Sfredette
681.1Sfredette/*
691.1Sfredette * According to ANSI (section 2.2.4.2), the values below must be usable by
701.1Sfredette * #if preprocessing directives.  Additionally, the expression must have the
711.1Sfredette * same type as would an expression that is an object of the corresponding
721.1Sfredette * type converted according to the integral promotions.  The subtraction for
731.1Sfredette * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
741.1Sfredette * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
751.1Sfredette * These numbers work for pcc as well.  The UINT_MAX and ULONG_MAX values
761.1Sfredette * are written as hex so that GCC will be quiet about large integer constants.
771.1Sfredette */
781.10Sskrll#define	SCHAR_MAX	0x7f		/* max value for a signed char */
791.10Sskrll#define	SCHAR_MIN	(-0x7f-1)	/* min value for a signed char */
801.1Sfredette
811.7Sdrochner#define	UCHAR_MAX	0xff		/* max value for an unsigned char */
821.6She#define	CHAR_MAX	0x7f		/* max value for a char */
831.6She#define	CHAR_MIN	(-0x7f-1)	/* min value for a char */
841.6She
851.7Sdrochner#define	USHRT_MAX	0xffff		/* max value for an unsigned short */
861.6She#define	SHRT_MAX	0x7fff		/* max value for a short */
871.6She#define	SHRT_MIN	(-0x7fff-1)	/* min value for a short */
881.6She
891.6She#define	UINT_MAX	0xffffffffU	/* max value for an unsigned int */
901.6She#define	INT_MAX		0x7fffffff	/* max value for an int */
911.6She#define	INT_MIN		(-0x7fffffff-1)	/* min value for an int */
921.1Sfredette
931.1Sfredette#define	ULONG_MAX	0xffffffffUL	/* max value for an unsigned long */
941.6She#define	LONG_MAX	0x7fffffffL	/* max value for a long */
951.6She#define	LONG_MIN	(-0x7fffffffL-1)	/* min value for a long */
961.1Sfredette
971.3Sbjh21#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
981.3Sbjh21    defined(_NETBSD_SOURCE)
991.1Sfredette#define	SSIZE_MAX	INT_MAX		/* max value for a ssize_t */
1001.1Sfredette
1011.3Sbjh21#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
1021.1Sfredette#define	SIZE_T_MAX	UINT_MAX	/* max value for a size_t */
1031.1Sfredette
1041.1Sfredette/* GCC requires that quad constants be written as expressions. */
1051.1Sfredette#define	UQUAD_MAX	((u_quad_t)0-1)	/* max value for a uquad_t */
1061.1Sfredette					/* max value for a quad_t */
1071.1Sfredette#define	QUAD_MAX	((quad_t)(UQUAD_MAX >> 1))
1081.1Sfredette#define	QUAD_MIN	(-QUAD_MAX-1)	/* min value for a quad_t */
1091.1Sfredette#define ULLONG_MAX	(UQUAD_MAX)	/* max value for unsigned long long */
1101.1Sfredette#define LLONG_MAX	(QUAD_MAX)	/* max value for a signed long long */
1111.1Sfredette#define LLONG_MIN	(QUAD_MIN)	/* min value for a signed long long */
1121.1Sfredette
1131.3Sbjh21#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
1141.1Sfredette
1151.3Sbjh21#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */
1161.1Sfredette
1171.3Sbjh21#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
1181.1Sfredette#define LONG_BIT	32
1191.1Sfredette#define WORD_BIT	32
1201.1Sfredette
1211.1Sfredette#define DBL_DIG		15
1221.1Sfredette#define DBL_MAX		1.7976931348623157E+308
1231.1Sfredette#define DBL_MIN		2.2250738585072014E-308
1241.1Sfredette
1251.1Sfredette#define FLT_DIG         6
1261.1Sfredette#define FLT_MAX		3.40282347E+38F
1271.1Sfredette#define FLT_MIN		1.17549435E-38F
1281.1Sfredette#endif
1291.9Sskrll
1301.9Sskrll#endif /* _MACHINE_LIMITS_H_ */
131