_limits.h revision 108533
1169691Skan/* 2169691Skan * Copyright (c) 1988, 1993 3169691Skan * The Regents of the University of California. All rights reserved. 4169691Skan * 5169691Skan * Redistribution and use in source and binary forms, with or without 6169691Skan * modification, are permitted provided that the following conditions 7169691Skan * are met: 8169691Skan * 1. Redistributions of source code must retain the above copyright 9169691Skan * notice, this list of conditions and the following disclaimer. 10169691Skan * 2. Redistributions in binary form must reproduce the above copyright 11169691Skan * notice, this list of conditions and the following disclaimer in the 12169691Skan * documentation and/or other materials provided with the distribution. 13169691Skan * 3. All advertising materials mentioning features or use of this software 14169691Skan * must display the following acknowledgement: 15169691Skan * This product includes software developed by the University of 16169691Skan * California, Berkeley and its contributors. 17169691Skan * 4. Neither the name of the University nor the names of its contributors 18169691Skan * may be used to endorse or promote products derived from this software 19169691Skan * without specific prior written permission. 20169691Skan * 21169691Skan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22169691Skan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23169691Skan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24169691Skan * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25169691Skan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26169691Skan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27169691Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28169691Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29169691Skan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30169691Skan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31169691Skan * SUCH DAMAGE. 32169691Skan * 33169691Skan * @(#)limits.h 8.3 (Berkeley) 1/4/94 34169691Skan * $FreeBSD: head/sys/i386/include/_limits.h 108533 2003-01-01 18:49:04Z schweikh $ 35169691Skan */ 36169691Skan 37169691Skan#ifndef _MACHINE_LIMITS_H_ 38169691Skan#define _MACHINE_LIMITS_H_ 39169691Skan 40169691Skan#define CHAR_BIT 8 /* number of bits in a char */ 41169691Skan 42169691Skan/* 43169691Skan * According to ANSI (section 2.2.4.2), the values below must be usable by 44169691Skan * #if preprocessing directives. Additionally, the expression must have the 45169691Skan * same type as would an expression that is an object of the corresponding 46169691Skan * type converted according to the integral promotions. The subtraction for 47169691Skan * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an 48169691Skan * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). 49169691Skan * These numbers are for the default configuration of gcc. They work for 50169691Skan * some other compilers as well, but this should not be depended on. 51169691Skan */ 52169691Skan#define SCHAR_MAX 0x7f /* max value for a signed char */ 53169691Skan#define SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ 54169691Skan 55169691Skan#define UCHAR_MAX 0xff /* max value for an unsigned char */ 56169691Skan 57169691Skan#ifdef __CHAR_UNSIGNED__ 58169691Skan#define CHAR_MAX UCHAR_MAX /* max value for a char */ 59169691Skan#define CHAR_MIN 0 /* min value for a char */ 60169691Skan#else 61169691Skan#define CHAR_MAX SCHAR_MAX /* max value for a char */ 62169691Skan#define CHAR_MIN SCHAR_MIN /* min value for a char */ 63169691Skan#endif 64169691Skan 65169691Skan#define USHRT_MAX 0xffff /* max value for an unsigned short */ 66169691Skan#define SHRT_MAX 0x7fff /* max value for a short */ 67169691Skan#define SHRT_MIN (-0x7fff - 1) /* min value for a short */ 68169691Skan 69169691Skan#define UINT_MAX 0xffffffffU /* max value for an unsigned int */ 70169691Skan#define INT_MAX 0x7fffffff /* max value for an int */ 71169691Skan#define INT_MIN (-0x7fffffff - 1) /* min value for an int */ 72169691Skan 73169691Skan/* Bad hack for gcc configured to give 64-bit longs. */ 74169691Skan#ifdef _LARGE_LONG 75#define ULONG_MAX 0xffffffffffffffffUL 76#define LONG_MAX 0x7fffffffffffffffL 77#define LONG_MIN (-0x7fffffffffffffffL - 1) 78#else 79#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ 80#define LONG_MAX 0x7fffffffL /* max value for a long */ 81#define LONG_MIN (-0x7fffffffL - 1) /* min value for a long */ 82#endif 83 84 /* max value for an unsigned long long */ 85#define ULLONG_MAX 0xffffffffffffffffULL 86#define LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */ 87#define LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */ 88 89#if !defined(_ANSI_SOURCE) 90#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ 91 92#if !defined(_POSIX_SOURCE) 93#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ 94 95#define OFF_MAX LLONG_MAX /* max value for an off_t */ 96#define OFF_MIN LLONG_MIN /* min value for an off_t */ 97 98/* Quads and long longs are the same size. Ensure they stay in sync. */ 99#define UQUAD_MAX ULLONG_MAX /* max value for a uquad_t */ 100#define QUAD_MAX LLONG_MAX /* max value for a quad_t */ 101#define QUAD_MIN LLONG_MIN /* min value for a quad_t */ 102#endif /* !_POSIX_SOURCE */ 103#endif /* !_ANSI_SOURCE */ 104 105#endif /* !_MACHINE_LIMITS_H_ */ 106