t2ex/bsd_source/lib/libc/src_bsd/include/sys/limits.h | bare source | permlink (0.01 seconds) |
1: /* $OpenBSD: limits.h,v 1.8 2009/11/27 19:54:35 guenther Exp $ */ 2: /* 3: * Copyright (c) 2002 Marc Espie. 4: * 5: * Redistribution and use in source and binary forms, with or without 6: * modification, are permitted provided that the following conditions 7: * are met: 8: * 1. Redistributions of source code must retain the above copyright 9: * notice, this list of conditions and the following disclaimer. 10: * 2. Redistributions in binary form must reproduce the above copyright 11: * notice, this list of conditions and the following disclaimer in the 12: * documentation and/or other materials provided with the distribution. 13: * 14: * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 15: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 18: * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25: */ 26: #ifndef _SYS_LIMITS_H_ 27: #define _SYS_LIMITS_H_ 28: 29: #include <sys/cdefs.h> 30: 31: /* Common definitions for limits.h. */ 32: 33: /* 34: * <machine/internal_types.h> is meant to describe a specific architecture, 35: * but to be a safe include, that doesn't ever define anything that is 36: * user-visible (only typedefs and #define names that stays in the __xxx 37: * namespace). 38: * 39: * __machine_has_unsigned_chars (default is signed chars) 40: * __FLT_xxx/__DBL_xxx non standard values for floating 41: * points limits. 42: */ 43: #include <machine/internal_types.h> 44: 45: /* Legacy */ 46: #include <machine/limits.h> 47: 48: #define CHAR_BIT 8 /* number of bits in a char */ 49: 50: #define SCHAR_MAX 0x7f /* max value for a signed char */ 51: #define SCHAR_MIN (-0x7f-1) /* min value for a signed char */ 52: 53: #define UCHAR_MAX 0xff /* max value for an unsigned char */ 54: #ifdef __machine_has_unsigned_chars 55: # define CHAR_MIN 0 /* min value for a char */ 56: # define CHAR_MAX 0xff /* max value for a char */ 57: #else 58: # define CHAR_MAX 0x7f 59: # define CHAR_MIN (-0x7f-1) 60: #endif 61: 62: #define MB_LEN_MAX 4 /* Allow UTF-8 (RFC 3629) */ 63: 64: #define USHRT_MAX 0xffff /* max value for an unsigned short */ 65: #define SHRT_MAX 0x7fff /* max value for a short */ 66: #define SHRT_MIN (-0x7fff-1) /* min value for a short */ 67: 68: #define UINT_MAX 0xffffffffU /* max value for an unsigned int */ 69: #define INT_MAX 0x7fffffff /* max value for an int */ 70: #define INT_MIN (-0x7fffffff-1) /* min value for an int */ 71: 72: #ifdef __LP64__ 73: # define ULONG_MAX 0xffffffffffffffffUL 74: /* max value for unsigned long */ 75: # define LONG_MAX 0x7fffffffffffffffL 76: /* max value for a signed long */ 77: # define LONG_MIN (-0x7fffffffffffffffL-1) 78: /* min value for a signed long */ 79: #else 80: # define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ 81: # define LONG_MAX 0x7fffffffL /* max value for a long */ 82: # define LONG_MIN (-0x7fffffffL-1)/* min value for a long */ 83: #endif 84: 85: #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 86: # define ULLONG_MAX 0xffffffffffffffffULL 87: /* max value for unsigned long long */ 88: # define LLONG_MAX 0x7fffffffffffffffLL 89: /* max value for a signed long long */ 90: # define LLONG_MIN (-0x7fffffffffffffffLL-1) 91: /* min value for a signed long long */ 92: #endif 93: 94: #if __BSD_VISIBLE 95: # define UID_MAX UINT_MAX /* max value for a uid_t */ 96: # define GID_MAX UINT_MAX /* max value for a gid_t */ 97: #endif 98: 99: 100: #if __XPG_VISIBLE 101: # ifdef __LP64__ 102: # define LONG_BIT 64 103: # else 104: # define LONG_BIT 32 105: # endif 106: # define WORD_BIT 32 107: 108: /* float.h defines these as well */ 109: # if !defined(DBL_DIG) 110: # if defined(__DBL_DIG) 111: # define DBL_DIG __DBL_DIG 112: # define DBL_MAX __DBL_MAX 113: # define DBL_MIN __DBL_MIN 114: 115: # define FLT_DIG __FLT_DIG 116: # define FLT_MAX __FLT_MAX 117: # define FLT_MIN __FLT_MIN 118: # else 119: # define DBL_DIG 15 120: # define DBL_MAX 1.7976931348623157E+308 121: # define DBL_MIN 2.2250738585072014E-308 122: 123: # define FLT_DIG 6 124: # define FLT_MAX 3.40282347E+38F 125: # define FLT_MIN 1.17549435E-38F 126: # endif 127: # endif 128: #endif 129: 130: #endif