blob: c50eb109bff35f72ea641b427a28a45f07a4c9e4 [file] [log] [blame]
Dan Albert287553d2017-02-16 10:47:51 -08001/* $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 200112L /* Posix C language bindings version */
119#define _POSIX2_VERSION -1 /* we don't support Posix command-line tools */
120#define _POSIX2_C_VERSION _POSIX_VERSION
121#define _XOPEN_VERSION 500 /* by Posix definition */
122#define _XOPEN_XCU_VERSION -1 /* we don't support command-line utilities */
123
124/* tell what we implement legacy stuff when appropriate */
125#if _POSIX_VERSION > 0
126#define _XOPEN_XPG2 1
127#define _XOPEN_XPG3 1
128#define _XOPEN_XPG4 1
129#define _XOPEN_UNIX 1
130#endif
131
132#define _XOPEN_ENH_I18N -1 /* we don't support internationalization in the C library */
133#define _XOPEN_CRYPT -1 /* don't support X/Open Encryption */
134#define _XOPEN_LEGACY -1 /* don't claim we support these, we have some of them but not all */
135#define _XOPEN_REALTIME -1 /* we don't support all these functions */
136#define _XOPEN_REALTIME_THREADS -1 /* same here */
137
138#define _POSIX_REALTIME_SIGNALS -1 /* for now, this is not supported */
139#define _POSIX_PRIORITY_SCHEDULING 1 /* priority scheduling is a Linux feature */
140#define _POSIX_TIMERS 1 /* Posix timers are supported */
141#undef _POSIX_ASYNCHRONOUS_IO /* aio_ functions are not supported */
142#define _POSIX_SYNCHRONIZED_IO 1 /* synchronized i/o supported */
143#define _POSIX_FSYNC 1 /* fdatasync() supported */
144#define _POSIX_MAPPED_FILES 1 /* mmap-ed files supported */
145
146/* XXX: TODO: complete and check list here */
147
148
149#define _POSIX_THREADS 1 /* we support threads */
150#define _POSIX_THREAD_STACKADDR 1 /* we support thread stack address */
151#define _POSIX_THREAD_STACKSIZE 1 /* we support thread stack size */
152#define _POSIX_THREAD_PRIO_INHERIT 200112L /* linux feature */
153#define _POSIX_THREAD_PRIO_PROTECT 200112L /* linux feature */
154
155#undef _POSIX_PROCESS_SHARED /* we don't support process-shared synchronization */
156#undef _POSIX_THREAD_SAFE_FUNCTIONS /* most functions are, but not everything yet */
157#define _POSIX_CHOWN_RESTRICTED 1 /* yes, chown requires appropriate privileges */
158#define _POSIX_MONOTONIC_CLOCK 0 /* the monotonic clock may be available; ask sysconf */
159#define _POSIX_NO_TRUNC 1 /* very long pathnames generate an error */
160#define _POSIX_SAVED_IDS 1 /* saved user ids is a Linux feature */
161#define _POSIX_JOB_CONTROL 1 /* job control is a Linux feature */
162
163#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 /* the minimum mandated by POSIX */
164#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
165#define _POSIX_THREAD_KEYS_MAX 128 /* the minimum mandated by POSIX */
166#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX
167#define _POSIX_THREAD_THREADS_MAX 64 /* the minimum mandated by POSIX */
168#define PTHREAD_THREADS_MAX /* bionic has no specific limit */
169
170
171#endif