blob: b7d899b52286dc5cd762b447bd10c969b352337c [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#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 */
Elliott Hughes72645162013-10-04 15:59:19 -070040#ifdef __CHAR_UNSIGNED__
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080041# 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
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080069# define ULLONG_MAX 0xffffffffffffffffULL
70 /* max value for unsigned long long */
71# define LLONG_MAX 0x7fffffffffffffffLL
72 /* max value for a signed long long */
73# define LLONG_MIN (-0x7fffffffffffffffLL-1)
74 /* min value for a signed long long */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080075
Elliott Hughes3ba55f82016-06-08 18:11:23 -070076#if defined(__USE_BSD)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080077# define UID_MAX UINT_MAX /* max value for a uid_t */
78# define GID_MAX UINT_MAX /* max value for a gid_t */
79#endif
80
81
82#ifdef __LP64__
83# define LONG_BIT 64
84#else
85# define LONG_BIT 32
86#endif
87
88/* float.h defines these as well */
89# if !defined(DBL_DIG)
90# if defined(__DBL_DIG)
91# define DBL_DIG __DBL_DIG
92# define DBL_MAX __DBL_MAX
93# define DBL_MIN __DBL_MIN
94
95# define FLT_DIG __FLT_DIG
96# define FLT_MAX __FLT_MAX
97# define FLT_MIN __FLT_MIN
98# else
99# define DBL_DIG 15
100# define DBL_MAX 1.7976931348623157E+308
101# define DBL_MIN 2.2250738585072014E-308
102
103# define FLT_DIG 6
104# define FLT_MAX 3.40282347E+38F
105# define FLT_MIN 1.17549435E-38F
106# endif
107# endif
108
109/* Bionic: the following has been optimized out from our processed kernel headers */
110
111#define CHILD_MAX 999
112#define OPEN_MAX 256
113
114/* Bionic-specific definitions */
115
Yabin Cui1c191942014-11-19 19:49:14 -0800116#define _POSIX_VERSION 200809L /* Posix C language bindings version */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800117#define _POSIX2_VERSION -1 /* we don't support Posix command-line tools */
Yabin Cui1c191942014-11-19 19:49:14 -0800118#define _XOPEN_VERSION 700 /* by Posix definition */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800119
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800120
Elliott Hughes545afa12016-03-15 17:11:56 -0700121/* >= _POSIX_THREAD_DESTRUCTOR_ITERATIONS */
122#define PTHREAD_DESTRUCTOR_ITERATIONS 4
123/* >= _POSIX_THREAD_KEYS_MAX */
124#define PTHREAD_KEYS_MAX 128
125/* bionic has no specific limit */
126#undef PTHREAD_THREADS_MAX
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800127
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800128#endif