_limits.h revision 67487
14Srgrimes/* 21549Srgrimes * Copyright (c) 1988, 1993 31549Srgrimes * The Regents of the University of California. All rights reserved. 44Srgrimes * 54Srgrimes * Redistribution and use in source and binary forms, with or without 64Srgrimes * modification, are permitted provided that the following conditions 74Srgrimes * are met: 84Srgrimes * 1. Redistributions of source code must retain the above copyright 94Srgrimes * notice, this list of conditions and the following disclaimer. 104Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 114Srgrimes * notice, this list of conditions and the following disclaimer in the 124Srgrimes * documentation and/or other materials provided with the distribution. 134Srgrimes * 3. All advertising materials mentioning features or use of this software 144Srgrimes * must display the following acknowledgement: 154Srgrimes * This product includes software developed by the University of 164Srgrimes * California, Berkeley and its contributors. 174Srgrimes * 4. Neither the name of the University nor the names of its contributors 184Srgrimes * may be used to endorse or promote products derived from this software 194Srgrimes * without specific prior written permission. 204Srgrimes * 214Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 224Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 234Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 244Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 254Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 264Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 274Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 284Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 294Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 304Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 314Srgrimes * SUCH DAMAGE. 324Srgrimes * 331549Srgrimes * @(#)limits.h 8.3 (Berkeley) 1/4/94 3450477Speter * $FreeBSD: head/sys/i386/include/_limits.h 67487 2000-10-24 10:48:50Z obrien $ 354Srgrimes */ 364Srgrimes 37719Swollman#ifndef _MACHINE_LIMITS_H_ 386165Sbde#define _MACHINE_LIMITS_H_ 39719Swollman 404Srgrimes#define CHAR_BIT 8 /* number of bits in a char */ 411549Srgrimes#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */ 424Srgrimes 431549Srgrimes/* 441549Srgrimes * According to ANSI (section 2.2.4.2), the values below must be usable by 451549Srgrimes * #if preprocessing directives. Additionally, the expression must have the 461549Srgrimes * same type as would an expression that is an object of the corresponding 471549Srgrimes * type converted according to the integral promotions. The subtraction for 4867487Sobrien * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an 491549Srgrimes * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). 5067487Sobrien * These numbers are for the default configuration of gcc. They work for 5167487Sobrien * some other compilers as well, but this should not be depended on. 521549Srgrimes */ 5367487Sobrien#define SCHAR_MAX 0x7f /* max value for a signed char */ 5467487Sobrien#define SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ 554Srgrimes 5667487Sobrien#define UCHAR_MAX 0xff /* max value for an unsigned char */ 571549Srgrimes 5847347Sache#ifdef __CHAR_UNSIGNED__ 5947389Sbde#define CHAR_MAX UCHAR_MAX /* max value for a char */ 6047389Sbde#define CHAR_MIN 0 /* min value for a char */ 6147347Sache#else 6247389Sbde#define CHAR_MAX SCHAR_MAX /* max value for a char */ 6347389Sbde#define CHAR_MIN SCHAR_MIN /* min value for a char */ 6447347Sache#endif 6547347Sache 6667487Sobrien#define USHRT_MAX 0xffff /* max value for an unsigned short */ 6767487Sobrien#define SHRT_MAX 0x7fff /* max value for a short */ 6867487Sobrien#define SHRT_MIN (-0x7ffff - 1) /* min value for a short */ 691549Srgrimes 7067487Sobrien#define UINT_MAX 0xffffffffU /* max value for an unsigned int */ 7167487Sobrien#define INT_MAX 0x7fffffff /* max value for an int */ 7267487Sobrien#define INT_MIN (-0x7fffffff - 1) /* min value for an int */ 734Srgrimes 7467487Sobrien/* Bad hack for gcc configured to give 64-bit longs. */ 7567487Sobrien#ifdef _LARGE_LONG 7667487Sobrien#define ULONG_MAX 0xffffffffffffffffUL 7767487Sobrien#define LONG_MAX 0x7fffffffffffffffL 7867487Sobrien#define LONG_MIN (-0x7fffffffffffffffL - 1) 7967487Sobrien#else 8067487Sobrien#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ 8167487Sobrien#define LONG_MAX 0x7fffffffL /* max value for a long */ 8267487Sobrien#define LONG_MIN (-0x7fffffffL - 1) /* min value for a long */ 8367487Sobrien#endif 84880Salm 8567487Sobrien /* max value for an unsigned long long */ 8667487Sobrien#define ULLONG_MAX 0xffffffffffffffffULL 8767487Sobrien#define LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */ 8867487Sobrien#define LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */ 8967487Sobrien 901549Srgrimes#if !defined(_ANSI_SOURCE) 911549Srgrimes#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ 92880Salm 931549Srgrimes#if !defined(_POSIX_SOURCE) 941549Srgrimes#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ 951549Srgrimes 9667487Sobrien/* Quads and long longs are the same size. Ensure they stay in sync. */ 9767487Sobrien#define UQUAD_MAX ULLONG_MAX /* max value for a uquad_t */ 9867487Sobrien#define QUAD_MAX LLONG_MAX /* max value for a quad_t */ 9967487Sobrien#define QUAD_MIN LLONG_MIN /* min value for a quad_t */ 1001549Srgrimes 1011549Srgrimes#endif /* !_POSIX_SOURCE */ 1021549Srgrimes#endif /* !_ANSI_SOURCE */ 1031549Srgrimes 1046165Sbde#endif /* !_MACHINE_LIMITS_H_ */ 105