limits.h revision 1.3
11.3Sbjh21/* $NetBSD: limits.h,v 1.3 2003/04/28 23:16:19 bjh21 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.1Sfredette * 3. All advertising materials mentioning features or use of this software 411.1Sfredette * must display the following acknowledgement: 421.1Sfredette * This product includes software developed by the University of 431.1Sfredette * California, Berkeley and its contributors. 441.1Sfredette * 4. Neither the name of the University nor the names of its contributors 451.1Sfredette * may be used to endorse or promote products derived from this software 461.1Sfredette * without specific prior written permission. 471.1Sfredette * 481.1Sfredette * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 491.1Sfredette * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 501.1Sfredette * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 511.1Sfredette * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 521.1Sfredette * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 531.1Sfredette * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 541.1Sfredette * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 551.1Sfredette * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 561.1Sfredette * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 571.1Sfredette * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 581.1Sfredette * SUCH DAMAGE. 591.1Sfredette * 601.1Sfredette * @(#)limits.h 8.3 (Berkeley) 1/4/94 611.1Sfredette */ 621.1Sfredette 631.3Sbjh21#include <sys/featuretest.h> 641.3Sbjh21 651.1Sfredette#define CHAR_BIT 8 /* number of bits in a char */ 661.1Sfredette#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */ 671.1Sfredette 681.1Sfredette 691.1Sfredette/* 701.1Sfredette * According to ANSI (section 2.2.4.2), the values below must be usable by 711.1Sfredette * #if preprocessing directives. Additionally, the expression must have the 721.1Sfredette * same type as would an expression that is an object of the corresponding 731.1Sfredette * type converted according to the integral promotions. The subtraction for 741.1Sfredette * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an 751.1Sfredette * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). 761.1Sfredette * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values 771.1Sfredette * are written as hex so that GCC will be quiet about large integer constants. 781.1Sfredette */ 791.1Sfredette#define SCHAR_MAX 127 /* min value for a signed char */ 801.1Sfredette#define SCHAR_MIN (-128) /* max value for a signed char */ 811.1Sfredette 821.1Sfredette#define UCHAR_MAX 255 /* max value for an unsigned char */ 831.1Sfredette#define CHAR_MAX 127 /* max value for a char */ 841.1Sfredette#define CHAR_MIN (-128) /* min value for a char */ 851.1Sfredette 861.1Sfredette#define USHRT_MAX 65535 /* max value for an unsigned short */ 871.1Sfredette#define SHRT_MAX 32767 /* max value for a short */ 881.1Sfredette#define SHRT_MIN (-32768) /* min value for a short */ 891.1Sfredette 901.1Sfredette#define UINT_MAX 0xffffffff /* max value for an unsigned int */ 911.1Sfredette#define INT_MAX 2147483647 /* max value for an int */ 921.1Sfredette#define INT_MIN (-2147483647-1) /* min value for an int */ 931.1Sfredette 941.1Sfredette#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ 951.1Sfredette#define LONG_MAX 2147483647L /* max value for a long */ 961.1Sfredette#define LONG_MIN (-2147483647-1) /* min value for a long */ 971.1Sfredette 981.3Sbjh21#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 991.3Sbjh21 defined(_NETBSD_SOURCE) 1001.1Sfredette#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ 1011.1Sfredette 1021.3Sbjh21#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 1031.1Sfredette#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ 1041.1Sfredette 1051.1Sfredette/* GCC requires that quad constants be written as expressions. */ 1061.1Sfredette#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */ 1071.1Sfredette /* max value for a quad_t */ 1081.1Sfredette#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) 1091.1Sfredette#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */ 1101.1Sfredette#define ULLONG_MAX (UQUAD_MAX) /* max value for unsigned long long */ 1111.1Sfredette#define LLONG_MAX (QUAD_MAX) /* max value for a signed long long */ 1121.1Sfredette#define LLONG_MIN (QUAD_MIN) /* min value for a signed long long */ 1131.1Sfredette 1141.3Sbjh21#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ 1151.1Sfredette 1161.3Sbjh21#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ 1171.1Sfredette 1181.3Sbjh21#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 1191.1Sfredette#define LONG_BIT 32 1201.1Sfredette#define WORD_BIT 32 1211.1Sfredette 1221.1Sfredette#define DBL_DIG 15 1231.1Sfredette#define DBL_MAX 1.7976931348623157E+308 1241.1Sfredette#define DBL_MIN 2.2250738585072014E-308 1251.1Sfredette 1261.1Sfredette#define FLT_DIG 6 1271.1Sfredette#define FLT_MAX 3.40282347E+38F 1281.1Sfredette#define FLT_MIN 1.17549435E-38F 1291.1Sfredette#endif 130