1*480020cdSdholland /* $NetBSD: limits.h,v 1.17 2019/01/21 20:28:17 dholland Exp $ */ 285854cb4Scgd 385854cb4Scgd /* 485854cb4Scgd * Copyright (c) 1988, 1993 585854cb4Scgd * The Regents of the University of California. All rights reserved. 685854cb4Scgd * 785854cb4Scgd * Redistribution and use in source and binary forms, with or without 885854cb4Scgd * modification, are permitted provided that the following conditions 985854cb4Scgd * are met: 1085854cb4Scgd * 1. Redistributions of source code must retain the above copyright 1185854cb4Scgd * notice, this list of conditions and the following disclaimer. 1285854cb4Scgd * 2. Redistributions in binary form must reproduce the above copyright 1385854cb4Scgd * notice, this list of conditions and the following disclaimer in the 1485854cb4Scgd * documentation and/or other materials provided with the distribution. 15aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 1685854cb4Scgd * may be used to endorse or promote products derived from this software 1785854cb4Scgd * without specific prior written permission. 1885854cb4Scgd * 1985854cb4Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2085854cb4Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2185854cb4Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2285854cb4Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2385854cb4Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2485854cb4Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2585854cb4Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2685854cb4Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2785854cb4Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2885854cb4Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2985854cb4Scgd * SUCH DAMAGE. 3085854cb4Scgd * 3185854cb4Scgd * @(#)limits.h 8.3 (Berkeley) 1/4/94 3285854cb4Scgd */ 3385854cb4Scgd 346f57e5c5Sperry #ifndef _MACHINE_LIMITS_H_ 356f57e5c5Sperry #define _MACHINE_LIMITS_H_ 366f57e5c5Sperry 374be7a2dcSbjh21 #include <sys/featuretest.h> 384be7a2dcSbjh21 3985854cb4Scgd #define CHAR_BIT 8 /* number of bits in a char */ 4085854cb4Scgd 4185854cb4Scgd /* 4285854cb4Scgd * According to ANSI (section 2.2.4.2), the values below must be usable by 4385854cb4Scgd * #if preprocessing directives. Additionally, the expression must have the 4485854cb4Scgd * same type as would an expression that is an object of the corresponding 4585854cb4Scgd * type converted according to the integral promotions. The subtraction for 4685854cb4Scgd * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an 4785854cb4Scgd * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). 4885854cb4Scgd * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values 4985854cb4Scgd * are written as hex so that GCC will be quiet about large integer constants. 5085854cb4Scgd */ 517484a2dbSchristos #define UCHAR_MAX 0xff /* max value for an unsigned char */ 520e1f0862Scgd #define SCHAR_MAX 0x7f /* max value for a signed char */ 530e1f0862Scgd #define SCHAR_MIN (-0x7f-1) /* min value for a signed char */ 5485854cb4Scgd 550e0fe2c3Sdrochner #define USHRT_MAX 0xffff /* max value for an unsigned short */ 560e1f0862Scgd #define SHRT_MAX 0x7fff /* max value for a short */ 570e1f0862Scgd #define SHRT_MIN (-0x7fff-1) /* min value for a short */ 5885854cb4Scgd 590e1f0862Scgd #define UINT_MAX 0xffffffffU /* max value for an unsigned int */ 600e1f0862Scgd #define INT_MAX 0x7fffffff /* max value for an int */ 610e1f0862Scgd #define INT_MIN (-0x7fffffff-1) /* min value for an int */ 6285854cb4Scgd 630e1f0862Scgd #define ULONG_MAX 0xffffffffffffffffUL /* max for an unsigned long */ 640e1f0862Scgd #define LONG_MAX 0x7fffffffffffffffL /* max for a long */ 650e1f0862Scgd #define LONG_MIN (-0x7fffffffffffffffL-1) /* min for a long */ 6685854cb4Scgd 674be7a2dcSbjh21 #if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ 684be7a2dcSbjh21 defined(_NETBSD_SOURCE) 69a9ebf7bbSkleink #define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ 70a9ebf7bbSkleink #define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ 71a9ebf7bbSkleink #define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ 72a9ebf7bbSkleink #endif 73a9ebf7bbSkleink 74*480020cdSdholland #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 75*480020cdSdholland defined(_NETBSD_SOURCE) 76*480020cdSdholland #define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ 77*480020cdSdholland 784be7a2dcSbjh21 #if defined(_NETBSD_SOURCE) 79caafbf4eSchristos #define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ 800e1f0862Scgd #define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ 8185854cb4Scgd 820e1f0862Scgd /* Quads and longs are the same on the alpha */ 830e1f0862Scgd #define UQUAD_MAX (ULONG_MAX) /* max value for a uquad_t */ 840e1f0862Scgd #define QUAD_MAX (LONG_MAX) /* max value for a quad_t */ 850e1f0862Scgd #define QUAD_MIN (LONG_MIN) /* min value for a quad_t */ 8685854cb4Scgd 874be7a2dcSbjh21 #endif /* _NETBSD_SOURCE */ 884be7a2dcSbjh21 #endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ 890e1f0862Scgd 904be7a2dcSbjh21 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 910e1f0862Scgd #define LONG_BIT 64 920e1f0862Scgd #define WORD_BIT 32 930e1f0862Scgd 948ed9a6d8Smatt #define DBL_DIG __DBL_DIG__ 958ed9a6d8Smatt #define DBL_MAX __DBL_MAX__ 968ed9a6d8Smatt #define DBL_MIN __DBL_MIN__ 970e1f0862Scgd 988ed9a6d8Smatt #define FLT_DIG __FLT_DIG__ 998ed9a6d8Smatt #define FLT_MAX __FLT_MAX__ 1008ed9a6d8Smatt #define FLT_MIN __FLT_MIN__ 1010e1f0862Scgd #endif 1026f57e5c5Sperry 1036f57e5c5Sperry #endif /* _MACHINE_LIMITS_H_ */ 104