blob: 36f73b2b3c67bac4e74d03083d5f8d592bce657e [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -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
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080034/* Legacy */
35#include <machine/limits.h>
36
37#define CHAR_BIT 8 /* number of bits in a char */
38
39#define SCHAR_MAX 0x7f /* max value for a signed char */
40#define SCHAR_MIN (-0x7f-1) /* min value for a signed char */
41
42#define UCHAR_MAX 0xffU /* max value for an unsigned char */
Elliott Hughes72645162013-10-04 15:59:19 -070043#ifdef __CHAR_UNSIGNED__
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080044# define CHAR_MIN 0 /* min value for a char */
45# define CHAR_MAX 0xff /* max value for a char */
46#else
47# define CHAR_MAX 0x7f
48# define CHAR_MIN (-0x7f-1)
49#endif
50
51#define USHRT_MAX 0xffffU /* max value for an unsigned short */
52#define SHRT_MAX 0x7fff /* max value for a short */
53#define SHRT_MIN (-0x7fff-1) /* min value for a short */
54
55#define UINT_MAX 0xffffffffU /* max value for an unsigned int */
56#define INT_MAX 0x7fffffff /* max value for an int */
57#define INT_MIN (-0x7fffffff-1) /* min value for an int */
58
59#ifdef __LP64__
60# define ULONG_MAX 0xffffffffffffffffUL
61 /* max value for unsigned long */
62# define LONG_MAX 0x7fffffffffffffffL
63 /* max value for a signed long */
64# define LONG_MIN (-0x7fffffffffffffffL-1)
65 /* min value for a signed long */
66#else
67# define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
68# define LONG_MAX 0x7fffffffL /* max value for a long */
69# define LONG_MIN (-0x7fffffffL-1)/* min value for a long */
70#endif
71
72#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999
73# define ULLONG_MAX 0xffffffffffffffffULL
74 /* max value for unsigned long long */
75# define LLONG_MAX 0x7fffffffffffffffLL
76 /* max value for a signed long long */
77# define LLONG_MIN (-0x7fffffffffffffffLL-1)
78 /* min value for a signed long long */
79#endif
80
81#if __BSD_VISIBLE
82# define UID_MAX UINT_MAX /* max value for a uid_t */
83# define GID_MAX UINT_MAX /* max value for a gid_t */
84#endif
85
86
87#ifdef __LP64__
88# define LONG_BIT 64
89#else
90# define LONG_BIT 32
91#endif
92
93/* float.h defines these as well */
94# if !defined(DBL_DIG)
95# if defined(__DBL_DIG)
96# define DBL_DIG __DBL_DIG
97# define DBL_MAX __DBL_MAX
98# define DBL_MIN __DBL_MIN
99
100# define FLT_DIG __FLT_DIG
101# define FLT_MAX __FLT_MAX
102# define FLT_MIN __FLT_MIN
103# else
104# define DBL_DIG 15
105# define DBL_MAX 1.7976931348623157E+308
106# define DBL_MIN 2.2250738585072014E-308
107
108# define FLT_DIG 6
109# define FLT_MAX 3.40282347E+38F
110# define FLT_MIN 1.17549435E-38F
111# endif
112# endif
113
114/* Bionic: the following has been optimized out from our processed kernel headers */
115
116#define CHILD_MAX 999
117#define OPEN_MAX 256
118
119/* Bionic-specific definitions */
120
121#define _POSIX_VERSION 200112L /* Posix C language bindings version */
122#define _POSIX2_VERSION -1 /* we don't support Posix command-line tools */
123#define _POSIX2_C_VERSION _POSIX_VERSION
124#define _XOPEN_VERSION 500 /* by Posix definition */
125#define _XOPEN_XCU_VERSION -1 /* we don't support command-line utilities */
126
127/* tell what we implement legacy stuff when appropriate */
128#if _POSIX_VERSION > 0
129#define _XOPEN_XPG2 1
130#define _XOPEN_XPG3 1
131#define _XOPEN_XPG4 1
132#define _XOPEN_UNIX 1
133#endif
134
135#define _XOPEN_ENH_I18N -1 /* we don't support internationalization in the C library */
136#define _XOPEN_CRYPT -1 /* don't support X/Open Encryption */
137#define _XOPEN_LEGACY -1 /* don't claim we support these, we have some of them but not all */
138#define _XOPEN_REALTIME -1 /* we don't support all these functions */
139#define _XOPEN_REALTIME_THREADS -1 /* same here */
140
141#define _POSIX_REALTIME_SIGNALS -1 /* for now, this is not supported */
142#define _POSIX_PRIORITY_SCHEDULING 1 /* priority scheduling is a Linux feature */
143#define _POSIX_TIMERS 1 /* Posix timers are supported */
144#undef _POSIX_ASYNCHRONOUS_IO /* aio_ functions are not supported */
145#define _POSIX_SYNCHRONIZED_IO 1 /* synchronized i/o supported */
146#define _POSIX_FSYNC 1 /* fdatasync() supported */
147#define _POSIX_MAPPED_FILES 1 /* mmap-ed files supported */
148
149/* XXX: TODO: complete and check list here */
150
151
152#define _POSIX_THREADS 1 /* we support threads */
153#define _POSIX_THREAD_STACKADDR 1 /* we support thread stack address */
154#define _POSIX_THREAD_STACKSIZE 1 /* we support thread stack size */
155#define _POSIX_THREAD_PRIO_INHERIT 200112L /* linux feature */
156#define _POSIX_THREAD_PRIO_PROTECT 200112L /* linux feature */
157
158#undef _POSIX_PROCESS_SHARED /* we don't support process-shared synchronization */
159#undef _POSIX_THREAD_SAFE_FUNCTIONS /* most functions are, but not everything yet */
Elliott Hughesa55f6302013-01-02 14:23:43 -0800160#define _POSIX_CHOWN_RESTRICTED 1 /* yes, chown requires appropriate privileges */
161#define _POSIX_MONOTONIC_CLOCK 0 /* the monotonic clock may be available; ask sysconf */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800162#define _POSIX_NO_TRUNC 1 /* very long pathnames generate an error */
163#define _POSIX_SAVED_IDS 1 /* saved user ids is a Linux feature */
164#define _POSIX_JOB_CONTROL 1 /* job control is a Linux feature */
165
Elliott Hughes44b53ad2013-02-11 20:18:47 +0000166#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 /* the minimum mandated by POSIX */
Elliott Hughesc03e1e72013-07-29 16:51:45 -0700167#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
Elliott Hughes44b53ad2013-02-11 20:18:47 +0000168#define _POSIX_THREAD_KEYS_MAX 128 /* the minimum mandated by POSIX */
Elliott Hughesc03e1e72013-07-29 16:51:45 -0700169#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX
Elliott Hughes44b53ad2013-02-11 20:18:47 +0000170#define _POSIX_THREAD_THREADS_MAX 64 /* the minimum mandated by POSIX */
171#define PTHREAD_THREADS_MAX /* bionic has no specific limit */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800172
173
174#endif