_limits.h revision 21673
1250226Sjkim/* 2250226Sjkim * Copyright (c) 1988, 1993 3228063Sbapt * The Regents of the University of California. All rights reserved. 4228063Sbapt * 5228063Sbapt * Redistribution and use in source and binary forms, with or without 6228063Sbapt * modification, are permitted provided that the following conditions 7228063Sbapt * are met: 8228063Sbapt * 1. Redistributions of source code must retain the above copyright 9228063Sbapt * notice, this list of conditions and the following disclaimer. 10228063Sbapt * 2. Redistributions in binary form must reproduce the above copyright 11228063Sbapt * notice, this list of conditions and the following disclaimer in the 12228063Sbapt * documentation and/or other materials provided with the distribution. 13228063Sbapt * 3. All advertising materials mentioning features or use of this software 14228063Sbapt * must display the following acknowledgement: 15228063Sbapt * This product includes software developed by the University of 16228063Sbapt * California, Berkeley and its contributors. 17228063Sbapt * 4. Neither the name of the University nor the names of its contributors 18228063Sbapt * may be used to endorse or promote products derived from this software 19228063Sbapt * without specific prior written permission. 20228063Sbapt * 21228063Sbapt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22228063Sbapt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23228063Sbapt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24228063Sbapt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25228063Sbapt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26228063Sbapt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27228063Sbapt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28228063Sbapt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29228063Sbapt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30228063Sbapt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31228063Sbapt * SUCH DAMAGE. 32228063Sbapt * 33228063Sbapt * @(#)limits.h 8.3 (Berkeley) 1/4/94 3497575Sru * $FreeBSD: head/sys/i386/include/_limits.h 21673 1997-01-14 07:20:47Z jkh $ 352021Sjkh */ 36250226Sjkim 3749823Smpp#ifndef _MACHINE_LIMITS_H_ 382021Sjkh#define _MACHINE_LIMITS_H_ 392021Sjkh 402021Sjkh#define CHAR_BIT 8 /* number of bits in a char */ 412021Sjkh#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */ 422021Sjkh 43250226Sjkim/* 44228063Sbapt * According to ANSI (section 2.2.4.2), the values below must be usable by 45228063Sbapt * #if preprocessing directives. Additionally, the expression must have the 46228063Sbapt * same type as would an expression that is an object of the corresponding 47228063Sbapt * type converted according to the integral promotions. The subtraction for 48228063Sbapt * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an 49228063Sbapt * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). 5095059Sjmallett * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values 5195059Sjmallett * are written as hex so that GCC will be quiet about large integer constants. 52228063Sbapt */ 53228063Sbapt#define SCHAR_MAX 127 /* min value for a signed char */ 54228063Sbapt#define SCHAR_MIN (-128) /* max value for a signed char */ 5597575Sru 562021Sjkh#define UCHAR_MAX 255 /* max value for an unsigned char */ 572021Sjkh#define CHAR_MAX 127 /* max value for a char */ 58250226Sjkim#define CHAR_MIN (-128) /* min value for a char */ 592021Sjkh 602021Sjkh#define USHRT_MAX 65535 /* max value for an unsigned short */ 61228063Sbapt#define SHRT_MAX 32767 /* max value for a short */ 62250226Sjkim#define SHRT_MIN (-32768) /* min value for a short */ 63228063Sbapt 64228063Sbapt#define UINT_MAX 0xffffffff /* max value for an unsigned int */ 65228063Sbapt#define INT_MAX 2147483647 /* max value for an int */ 66228063Sbapt#define INT_MIN (-2147483647-1) /* min value for an int */ 67228063Sbapt 68228063Sbapt#define ULONG_MAX 0xffffffff /* max value for an unsigned long */ 69228063Sbapt#define LONG_MAX 2147483647 /* max value for a long */ 70250226Sjkim#define LONG_MIN (-2147483647-1) /* min value for a long */ 71228063Sbapt 72228063Sbapt#if !defined(_ANSI_SOURCE) 732021Sjkh#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ 74228063Sbapt 752021Sjkh#if !defined(_POSIX_SOURCE) 762021Sjkh#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ 7795059Sjmallett 78250226Sjkim/* GCC requires that quad constants be written as expressions. */ 7995059Sjmallett#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */ 8095059Sjmallett /* max value for a quad_t */ 812021Sjkh#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) 822021Sjkh#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */ 8395059Sjmallett 8495059Sjmallett#endif /* !_POSIX_SOURCE */ 85228063Sbapt#endif /* !_ANSI_SOURCE */ 862021Sjkh 8795059Sjmallett#endif /* !_MACHINE_LIMITS_H_ */ 88228063Sbapt