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 /* 35 * <machine/internal_types.h> is meant to describe a specific architecture, 36 * but to be a safe include, that doesn't ever define anything that is 37 * user-visible (only typedefs and #define names that stays in the __xxx 38 * namespace). 39 * 40 * __machine_has_unsigned_chars (default is signed chars) 41 * __FLT_xxx/__DBL_xxx non standard values for floating 42 * points limits. 43 */ 44 #include <machine/internal_types.h> 45 46 /* Legacy */ 47 #include <machine/limits.h> 48 49 #define CHAR_BIT 8 /* number of bits in a char */ 50 51 #define SCHAR_MAX 0x7f /* max value for a signed char */ 52 #define SCHAR_MIN (-0x7f-1) /* min value for a signed char */ 53 54 #define UCHAR_MAX 0xffU /* max value for an unsigned char */ 55 #ifdef __machine_has_unsigned_chars 56 # define CHAR_MIN 0 /* min value for a char */ 57 # define CHAR_MAX 0xff /* max value for a char */ 58 #else 59 # define CHAR_MAX 0x7f 60 # define CHAR_MIN (-0x7f-1) 61 #endif 62 63 #define USHRT_MAX 0xffffU /* max value for an unsigned short */ 64 #define SHRT_MAX 0x7fff /* max value for a short */ 65 #define SHRT_MIN (-0x7fff-1) /* min value for a short */ 66 67 #define UINT_MAX 0xffffffffU /* max value for an unsigned int */ 68 #define INT_MAX 0x7fffffff /* max value for an int */ 69 #define INT_MIN (-0x7fffffff-1) /* min value for an int */ 70 71 #ifdef __LP64__ 72 # define ULONG_MAX 0xffffffffffffffffUL 73 /* max value for unsigned long */ 74 # define LONG_MAX 0x7fffffffffffffffL 75 /* max value for a signed long */ 76 # define LONG_MIN (-0x7fffffffffffffffL-1) 77 /* min value for a signed long */ 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 #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 85 # define ULLONG_MAX 0xffffffffffffffffULL 86 /* max value for unsigned long long */ 87 # define LLONG_MAX 0x7fffffffffffffffLL 88 /* max value for a signed long long */ 89 # define LLONG_MIN (-0x7fffffffffffffffLL-1) 90 /* min value for a signed long long */ 91 #endif 92 93 #if __BSD_VISIBLE 94 # define UID_MAX UINT_MAX /* max value for a uid_t */ 95 # define GID_MAX UINT_MAX /* max value for a gid_t */ 96 #endif 97 98 99 #ifdef __LP64__ 100 # define LONG_BIT 64 101 #else 102 # define LONG_BIT 32 103 #endif 104 105 /* float.h defines these as well */ 106 # if !defined(DBL_DIG) 107 # if defined(__DBL_DIG) 108 # define DBL_DIG __DBL_DIG 109 # define DBL_MAX __DBL_MAX 110 # define DBL_MIN __DBL_MIN 111 112 # define FLT_DIG __FLT_DIG 113 # define FLT_MAX __FLT_MAX 114 # define FLT_MIN __FLT_MIN 115 # else 116 # define DBL_DIG 15 117 # define DBL_MAX 1.7976931348623157E+308 118 # define DBL_MIN 2.2250738585072014E-308 119 120 # define FLT_DIG 6 121 # define FLT_MAX 3.40282347E+38F 122 # define FLT_MIN 1.17549435E-38F 123 # endif 124 # endif 125 126 /* Bionic: the following has been optimized out from our processed kernel headers */ 127 128 #define CHILD_MAX 999 129 #define OPEN_MAX 256 130 131 /* Bionic-specific definitions */ 132 133 #define _POSIX_VERSION 200112L /* Posix C language bindings version */ 134 #define _POSIX2_VERSION -1 /* we don't support Posix command-line tools */ 135 #define _POSIX2_C_VERSION _POSIX_VERSION 136 #define _XOPEN_VERSION 500 /* by Posix definition */ 137 #define _XOPEN_XCU_VERSION -1 /* we don't support command-line utilities */ 138 139 /* tell what we implement legacy stuff when appropriate */ 140 #if _POSIX_VERSION > 0 141 #define _XOPEN_XPG2 1 142 #define _XOPEN_XPG3 1 143 #define _XOPEN_XPG4 1 144 #define _XOPEN_UNIX 1 145 #endif 146 147 #define _XOPEN_ENH_I18N -1 /* we don't support internationalization in the C library */ 148 #define _XOPEN_CRYPT -1 /* don't support X/Open Encryption */ 149 #define _XOPEN_LEGACY -1 /* don't claim we support these, we have some of them but not all */ 150 #define _XOPEN_REALTIME -1 /* we don't support all these functions */ 151 #define _XOPEN_REALTIME_THREADS -1 /* same here */ 152 153 #define _POSIX_REALTIME_SIGNALS -1 /* for now, this is not supported */ 154 #define _POSIX_PRIORITY_SCHEDULING 1 /* priority scheduling is a Linux feature */ 155 #define _POSIX_TIMERS 1 /* Posix timers are supported */ 156 #undef _POSIX_ASYNCHRONOUS_IO /* aio_ functions are not supported */ 157 #define _POSIX_SYNCHRONIZED_IO 1 /* synchronized i/o supported */ 158 #define _POSIX_FSYNC 1 /* fdatasync() supported */ 159 #define _POSIX_MAPPED_FILES 1 /* mmap-ed files supported */ 160 161 /* XXX: TODO: complete and check list here */ 162 163 164 #define _POSIX_THREADS 1 /* we support threads */ 165 #define _POSIX_THREAD_STACKADDR 1 /* we support thread stack address */ 166 #define _POSIX_THREAD_STACKSIZE 1 /* we support thread stack size */ 167 #define _POSIX_THREAD_PRIO_INHERIT 200112L /* linux feature */ 168 #define _POSIX_THREAD_PRIO_PROTECT 200112L /* linux feature */ 169 170 #undef _POSIX_PROCESS_SHARED /* we don't support process-shared synchronization */ 171 #undef _POSIX_THREAD_SAFE_FUNCTIONS /* most functions are, but not everything yet */ 172 #define _POSIX_CHOWN_RESTRICTED 1 /* yes, chown requires appropriate privileges */ 173 #define _POSIX_MONOTONIC_CLOCK 0 /* the monotonic clock may be available; ask sysconf */ 174 #define _POSIX_NO_TRUNC 1 /* very long pathnames generate an error */ 175 #define _POSIX_SAVED_IDS 1 /* saved user ids is a Linux feature */ 176 #define _POSIX_JOB_CONTROL 1 /* job control is a Linux feature */ 177 178 179 180 #endif 181