limits.h revision 1.13
11.13Smatt/* $NetBSD: limits.h,v 1.13 2011/07/11 02:54:04 matt 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 661.1Sfredette/* 671.1Sfredette * According to ANSI (section 2.2.4.2), the values below must be usable by 681.1Sfredette * #if preprocessing directives. Additionally, the expression must have the 691.1Sfredette * same type as would an expression that is an object of the corresponding 701.1Sfredette * type converted according to the integral promotions. The subtraction for 711.1Sfredette * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an 721.1Sfredette * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). 731.1Sfredette * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values 741.1Sfredette * are written as hex so that GCC will be quiet about large integer constants. 751.1Sfredette */ 761.10Sskrll#define SCHAR_MAX 0x7f /* max value for a signed char */ 771.10Sskrll#define SCHAR_MIN (-0x7f-1) /* min value for a signed char */ 781.1Sfredette 791.7Sdrochner#define UCHAR_MAX 0xff /* max value for an unsigned char */ 801.6She#define CHAR_MAX 0x7f /* max value for a char */ 811.6She#define CHAR_MIN (-0x7f-1) /* min value for a char */ 821.6She 831.7Sdrochner#define USHRT_MAX 0xffff /* max value for an unsigned short */ 841.6She#define SHRT_MAX 0x7fff /* max value for a short */ 851.6She#define SHRT_MIN (-0x7fff-1) /* min value for a short */ 861.6She 871.6She#define UINT_MAX 0xffffffffU /* max value for an unsigned int */ 881.6She#define INT_MAX 0x7fffffff /* max value for an int */ 891.6She#define INT_MIN (-0x7fffffff-1) /* min value for an int */ 901.1Sfredette 911.1Sfredette#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ 921.6She#define LONG_MAX 0x7fffffffL /* max value for a long */ 931.6She#define LONG_MIN (-0x7fffffffL-1) /* min value for a long */ 941.1Sfredette 951.3Sbjh21#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 961.3Sbjh21 defined(_NETBSD_SOURCE) 971.1Sfredette#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ 981.1Sfredette 991.11Sskrll#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ 1001.11Sskrll defined(_NETBSD_SOURCE) 1011.11Sskrll#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ 1021.11Sskrll#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ 1031.11Sskrll#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ 1041.11Sskrll#endif 1051.1Sfredette 1061.11Sskrll#if defined(_NETBSD_SOURCE) 1071.11Sskrll#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ 1081.1Sfredette 1091.11Sskrll#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ 1101.11Sskrll#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ 1111.11Sskrll#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ 1121.1Sfredette 1131.11Sskrll#endif /* _NETBSD_SOURCE */ 1141.3Sbjh21#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ 1151.1Sfredette 1161.3Sbjh21#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 1171.1Sfredette#define LONG_BIT 32 1181.1Sfredette#define WORD_BIT 32 1191.1Sfredette 1201.13Smatt#ifndef DBL_DIG 1211.13Smatt#ifdef __DBL_DIG__ 1221.13Smatt#define DBL_DIG __DBL_DIG__ 1231.13Smatt#else 1241.1Sfredette#define DBL_DIG 15 1251.13Smatt#endif 1261.13Smatt#endif 1271.13Smatt 1281.13Smatt#ifndef DBL_MAX 1291.13Smatt#ifdef __DBL_MAX__ 1301.13Smatt#define DBL_MAX __DBL_MAX__ 1311.13Smatt#else 1321.1Sfredette#define DBL_MAX 1.7976931348623157E+308 1331.13Smatt#endif 1341.13Smatt#endif 1351.13Smatt 1361.13Smatt#ifndef DBL_MIN 1371.13Smatt#ifdef __DBL_MIN__ 1381.13Smatt#define DBL_MIN __DBL_MIN__ 1391.13Smatt#else 1401.1Sfredette#define DBL_MIN 2.2250738585072014E-308 1411.13Smatt#endif 1421.13Smatt#endif 1431.1Sfredette 1441.13Smatt#ifndef FLT_DIG 1451.13Smatt#ifdef __FLT_DIG__ 1461.13Smatt#define FLT_DIG __FLT_DIG__ 1471.13Smatt#else 1481.1Sfredette#define FLT_DIG 6 1491.13Smatt#endif 1501.13Smatt#endif 1511.13Smatt 1521.13Smatt#ifndef FLT_MAX 1531.13Smatt#ifdef __FLT_MAX__ 1541.13Smatt#define FLT_MAX __FLT_MAX__ 1551.13Smatt#else 1561.1Sfredette#define FLT_MAX 3.40282347E+38F 1571.13Smatt#endif 1581.13Smatt#endif 1591.13Smatt 1601.13Smatt#ifndef FLT_MIN 1611.13Smatt#ifdef __FLT_MIN__ 1621.13Smatt#define FLT_MIN __FLT_MIN__ 1631.13Smatt#else 1641.1Sfredette#define FLT_MIN 1.17549435E-38F 1651.1Sfredette#endif 1661.13Smatt#endif 1671.13Smatt 1681.13Smatt#endif 1691.9Sskrll 1701.9Sskrll#endif /* _MACHINE_LIMITS_H_ */ 171