limits.h revision 1.10
11.10Schristos/* $NetBSD: limits.h,v 1.10 2024/03/16 21:50:47 christos Exp $ */ 21.1Scherry 31.1Scherry/* 41.1Scherry * Copyright (c) 1988 The Regents of the University of California. 51.1Scherry * All rights reserved. 61.1Scherry * 71.1Scherry * Redistribution and use in source and binary forms, with or without 81.1Scherry * modification, are permitted provided that the following conditions 91.1Scherry * are met: 101.1Scherry * 1. Redistributions of source code must retain the above copyright 111.1Scherry * notice, this list of conditions and the following disclaimer. 121.1Scherry * 2. Redistributions in binary form must reproduce the above copyright 131.1Scherry * notice, this list of conditions and the following disclaimer in the 141.1Scherry * documentation and/or other materials provided with the distribution. 151.1Scherry * 3. Neither the name of the University nor the names of its contributors 161.1Scherry * may be used to endorse or promote products derived from this software 171.1Scherry * without specific prior written permission. 181.1Scherry * 191.1Scherry * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 201.1Scherry * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 211.1Scherry * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 221.1Scherry * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 231.1Scherry * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 241.1Scherry * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 251.1Scherry * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 261.1Scherry * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 271.1Scherry * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 281.1Scherry * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 291.1Scherry * SUCH DAMAGE. 301.1Scherry * 311.1Scherry * @(#)limits.h 7.2 (Berkeley) 6/28/90 321.1Scherry */ 331.1Scherry 341.1Scherry#ifndef _MACHINE_LIMITS_H_ 351.1Scherry#define _MACHINE_LIMITS_H_ 361.1Scherry 371.1Scherry#define CHAR_BIT 8 /* number of bits in a char */ 381.1Scherry 391.3Sdrochner#define UCHAR_MAX 0xff /* max value for an unsigned char */ 401.6Schristos#define SCHAR_MAX 0x7f /* max value for a signed char */ 411.6Schristos#define SCHAR_MIN (-0x7f-1) /* min value for a signed char */ 421.1Scherry 431.3Sdrochner#define USHRT_MAX 0xffff /* max value for an unsigned short */ 441.1Scherry#define SHRT_MAX 0x7fff /* max value for a short */ 451.1Scherry#define SHRT_MIN (-0x7fff-1) /* min value for a short */ 461.1Scherry 471.1Scherry#define UINT_MAX 0xffffffffU /* max value for an unsigned int */ 481.1Scherry#define INT_MAX 0x7fffffff /* max value for an int */ 491.1Scherry#define INT_MIN (-0x7fffffff-1) /* min value for an int */ 501.1Scherry 511.1Scherry#define ULONG_MAX 0xffffffffffffffffUL /* max value for an unsigned long */ 521.1Scherry#define LONG_MAX 0x7fffffffffffffffL /* max value for a long */ 531.1Scherry#define LONG_MIN (-0x7fffffffffffffffL-1) /* min value for a long */ 541.1Scherry 551.1Scherry 561.1Scherry#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ 571.1Scherry defined(_NETBSD_SOURCE) 581.1Scherry#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ 591.1Scherry#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ 601.1Scherry#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ 611.1Scherry#endif 621.1Scherry 631.9Sdholland#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 641.9Sdholland defined(_NETBSD_SOURCE) 651.9Sdholland#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ 661.9Sdholland 671.1Scherry#if defined(_NETBSD_SOURCE) 681.7Schristos#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ 691.1Scherry#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ 701.1Scherry 711.10Schristos#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ 721.10Schristos#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ 731.10Schristos#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ 741.1Scherry 751.1Scherry#endif /* _NETBSD_SOURCE */ 761.1Scherry#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ 771.1Scherry 781.1Scherry#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 791.1Scherry#define LONG_BIT 64 801.1Scherry#define WORD_BIT 32 811.1Scherry 821.8Smatt#define DBL_DIG __DBL_DIG__ 831.8Smatt#define DBL_MAX __DBL_MAX__ 841.8Smatt#define DBL_MIN __DBL_MIN__ 851.8Smatt 861.8Smatt#define FLT_DIG __FLT_DIG__ 871.8Smatt#define FLT_MAX __FLT_MAX__ 881.8Smatt#define FLT_MIN __FLT_MIN__ 891.1Scherry#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ 901.1Scherry 911.1Scherry#endif /* _MACHINE_LIMITS_H_ */ 92