1 /* $OpenBSD: limits.h,v 1.6 2005/12/13 00:35:23 millert 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 #include <linux/limits.h> 31 32 /* Common definitions for limits.h. */ 33 34 #define CHAR_BIT 8 /* number of bits in a char */ 35 36 #define SCHAR_MAX 0x7f /* max value for a signed char */ 37 #define SCHAR_MIN (-0x7f-1) /* min value for a signed char */ 38 39 #define UCHAR_MAX 0xffU /* max value for an unsigned char */ 40 #ifdef __CHAR_UNSIGNED__ 41 # define CHAR_MIN 0 /* min value for a char */ 42 # define CHAR_MAX 0xff /* max value for a char */ 43 #else 44 # define CHAR_MAX 0x7f 45 # define CHAR_MIN (-0x7f-1) 46 #endif 47 48 #define USHRT_MAX 0xffffU /* max value for an unsigned short */ 49 #define SHRT_MAX 0x7fff /* max value for a short */ 50 #define SHRT_MIN (-0x7fff-1) /* min value for a short */ 51 52 #define UINT_MAX 0xffffffffU /* max value for an unsigned int */ 53 #define INT_MAX 0x7fffffff /* max value for an int */ 54 #define INT_MIN (-0x7fffffff-1) /* min value for an int */ 55 56 #ifdef __LP64__ 57 # define ULONG_MAX 0xffffffffffffffffUL 58 /* max value for unsigned long */ 59 # define LONG_MAX 0x7fffffffffffffffL 60 /* max value for a signed long */ 61 # define LONG_MIN (-0x7fffffffffffffffL-1) 62 /* min value for a signed long */ 63 #else 64 # define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ 65 # define LONG_MAX 0x7fffffffL /* max value for a long */ 66 # define LONG_MIN (-0x7fffffffL-1)/* min value for a long */ 67 #endif 68 69 #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 70 # define ULLONG_MAX 0xffffffffffffffffULL 71 /* max value for unsigned long long */ 72 # define LLONG_MAX 0x7fffffffffffffffLL 73 /* max value for a signed long long */ 74 # define LLONG_MIN (-0x7fffffffffffffffLL-1) 75 /* min value for a signed long long */ 76 #endif 77 78 #if __BSD_VISIBLE 79 # define UID_MAX UINT_MAX /* max value for a uid_t */ 80 # define GID_MAX UINT_MAX /* max value for a gid_t */ 81 #endif 82 83 84 #ifdef __LP64__ 85 # define LONG_BIT 64 86 #else 87 # define LONG_BIT 32 88 #endif 89 90 /* float.h defines these as well */ 91 # if !defined(DBL_DIG) 92 # if defined(__DBL_DIG) 93 # define DBL_DIG __DBL_DIG 94 # define DBL_MAX __DBL_MAX 95 # define DBL_MIN __DBL_MIN 96 97 # define FLT_DIG __FLT_DIG 98 # define FLT_MAX __FLT_MAX 99 # define FLT_MIN __FLT_MIN 100 # else 101 # define DBL_DIG 15 102 # define DBL_MAX 1.7976931348623157E+308 103 # define DBL_MIN 2.2250738585072014E-308 104 105 # define FLT_DIG 6 106 # define FLT_MAX 3.40282347E+38F 107 # define FLT_MIN 1.17549435E-38F 108 # endif 109 # endif 110 111 /* Bionic: the following has been optimized out from our processed kernel headers */ 112 113 #define CHILD_MAX 999 114 #define OPEN_MAX 256 115 116 /* Bionic-specific definitions */ 117 118 #define _POSIX_VERSION 200809L /* Posix C language bindings version */ 119 #define _POSIX2_VERSION -1 /* we don't support Posix command-line tools */ 120 #define _XOPEN_VERSION 700 /* by Posix definition */ 121 122 123 #define PTHREAD_DESTRUCTOR_ITERATIONS 4 // >= _POSIX_THREAD_DESTRUCTOR_ITERATIONS 124 #define PTHREAD_KEYS_MAX 128 // >= _POSIX_THREAD_KEYS_MAX 125 #define PTHREAD_THREADS_MAX 2048 // bionic has no specific limit 126 127 #endif 128