11.17Sskrll/* $NetBSD: limits.h,v 1.17 2019/04/16 12:25:17 skrll Exp $ */ 21.1Sfredette 31.1Sfredette/* $OpenBSD: limits.h,v 1.2 2000/07/31 20:06:02 millert Exp $ */ 41.1Sfredette 51.17Sskrll/* 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.14Schristos#define UCHAR_MAX 0xff /* max value for an unsigned char */ 771.10Sskrll#define SCHAR_MAX 0x7f /* max value for a signed char */ 781.10Sskrll#define SCHAR_MIN (-0x7f-1) /* min value for a signed char */ 791.1Sfredette 801.7Sdrochner#define USHRT_MAX 0xffff /* max value for an unsigned short */ 811.6She#define SHRT_MAX 0x7fff /* max value for a short */ 821.6She#define SHRT_MIN (-0x7fff-1) /* min value for a short */ 831.6She 841.6She#define UINT_MAX 0xffffffffU /* max value for an unsigned int */ 851.6She#define INT_MAX 0x7fffffff /* max value for an int */ 861.6She#define INT_MIN (-0x7fffffff-1) /* min value for an int */ 871.1Sfredette 881.1Sfredette#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ 891.6She#define LONG_MAX 0x7fffffffL /* max value for a long */ 901.6She#define LONG_MIN (-0x7fffffffL-1) /* min value for a long */ 911.1Sfredette 921.11Sskrll#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ 931.11Sskrll defined(_NETBSD_SOURCE) 941.11Sskrll#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ 951.11Sskrll#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ 961.11Sskrll#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ 971.11Sskrll#endif 981.1Sfredette 991.16Sdholland#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 1001.16Sdholland defined(_NETBSD_SOURCE) 1011.16Sdholland#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ 1021.16Sdholland 1031.11Sskrll#if defined(_NETBSD_SOURCE) 1041.15Schristos#define SSIZE_MIN INT_MIN /* min value for a ssize_t */ 1051.11Sskrll#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ 1061.1Sfredette 1071.11Sskrll#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ 1081.11Sskrll#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ 1091.11Sskrll#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ 1101.1Sfredette 1111.11Sskrll#endif /* _NETBSD_SOURCE */ 1121.3Sbjh21#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ 1131.1Sfredette 1141.3Sbjh21#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 1151.1Sfredette#define LONG_BIT 32 1161.1Sfredette#define WORD_BIT 32 1171.1Sfredette 1181.13Smatt#ifndef DBL_DIG 1191.13Smatt#ifdef __DBL_DIG__ 1201.13Smatt#define DBL_DIG __DBL_DIG__ 1211.13Smatt#else 1221.1Sfredette#define DBL_DIG 15 1231.13Smatt#endif 1241.13Smatt#endif 1251.13Smatt 1261.13Smatt#ifndef DBL_MAX 1271.13Smatt#ifdef __DBL_MAX__ 1281.13Smatt#define DBL_MAX __DBL_MAX__ 1291.13Smatt#else 1301.1Sfredette#define DBL_MAX 1.7976931348623157E+308 1311.13Smatt#endif 1321.13Smatt#endif 1331.13Smatt 1341.13Smatt#ifndef DBL_MIN 1351.13Smatt#ifdef __DBL_MIN__ 1361.13Smatt#define DBL_MIN __DBL_MIN__ 1371.13Smatt#else 1381.1Sfredette#define DBL_MIN 2.2250738585072014E-308 1391.13Smatt#endif 1401.13Smatt#endif 1411.1Sfredette 1421.13Smatt#ifndef FLT_DIG 1431.13Smatt#ifdef __FLT_DIG__ 1441.13Smatt#define FLT_DIG __FLT_DIG__ 1451.13Smatt#else 1461.1Sfredette#define FLT_DIG 6 1471.13Smatt#endif 1481.13Smatt#endif 1491.13Smatt 1501.13Smatt#ifndef FLT_MAX 1511.13Smatt#ifdef __FLT_MAX__ 1521.13Smatt#define FLT_MAX __FLT_MAX__ 1531.13Smatt#else 1541.17Sskrll#define FLT_MAX 3.40282347E+38F 1551.13Smatt#endif 1561.13Smatt#endif 1571.13Smatt 1581.13Smatt#ifndef FLT_MIN 1591.13Smatt#ifdef __FLT_MIN__ 1601.13Smatt#define FLT_MIN __FLT_MIN__ 1611.13Smatt#else 1621.17Sskrll#define FLT_MIN 1.17549435E-38F 1631.1Sfredette#endif 1641.13Smatt#endif 1651.13Smatt 1661.13Smatt#endif 1671.9Sskrll 1681.9Sskrll#endif /* _MACHINE_LIMITS_H_ */ 169