_limits.h revision 47347
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 3447347Sache * $Id: limits.h,v 1.11 1997/02/22 09:34:47 peter Exp $ 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 481549Srgrimes * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an 491549Srgrimes * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). 501549Srgrimes * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values 511549Srgrimes * are written as hex so that GCC will be quiet about large integer constants. 521549Srgrimes */ 531549Srgrimes#define SCHAR_MAX 127 /* min value for a signed char */ 541549Srgrimes#define SCHAR_MIN (-128) /* max value for a signed char */ 554Srgrimes 561549Srgrimes#define UCHAR_MAX 255 /* max value for an unsigned char */ 571549Srgrimes 5847347Sache#ifdef __CHAR_UNSIGNED__ 5947347Sache# define CHAR_MIN 0 /* min value for a char */ 6047347Sache# define CHAR_MAX UCHAR_MAX /* max value for a char */ 6147347Sache#else 6247347Sache# define CHAR_MIN SCHAR_MIN /* min value for a char */ 6347347Sache# define CHAR_MAX SCHAR_MAX /* max value for a char */ 6447347Sache#endif 6547347Sache 661549Srgrimes#define USHRT_MAX 65535 /* max value for an unsigned short */ 671549Srgrimes#define SHRT_MAX 32767 /* max value for a short */ 681549Srgrimes#define SHRT_MIN (-32768) /* min value for a short */ 691549Srgrimes 704Srgrimes#define UINT_MAX 0xffffffff /* max value for an unsigned int */ 711549Srgrimes#define INT_MAX 2147483647 /* max value for an int */ 721549Srgrimes#define INT_MIN (-2147483647-1) /* min value for an int */ 734Srgrimes 744Srgrimes#define ULONG_MAX 0xffffffff /* max value for an unsigned long */ 751549Srgrimes#define LONG_MAX 2147483647 /* max value for a long */ 761549Srgrimes#define LONG_MIN (-2147483647-1) /* min value for a long */ 77880Salm 781549Srgrimes#if !defined(_ANSI_SOURCE) 791549Srgrimes#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ 80880Salm 811549Srgrimes#if !defined(_POSIX_SOURCE) 821549Srgrimes#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ 831549Srgrimes 841549Srgrimes/* GCC requires that quad constants be written as expressions. */ 851549Srgrimes#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */ 861549Srgrimes /* max value for a quad_t */ 871549Srgrimes#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) 881549Srgrimes#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */ 891549Srgrimes 901549Srgrimes#endif /* !_POSIX_SOURCE */ 911549Srgrimes#endif /* !_ANSI_SOURCE */ 921549Srgrimes 936165Sbde#endif /* !_MACHINE_LIMITS_H_ */ 94