• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 1988 The Regents of the University of California.
3  * All rights reserved.
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  * 3. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *	@(#)limits.h	5.9 (Berkeley) 4/3/91
30  */
31 
32 #pragma once
33 
34 /**
35  * @file limits.h
36  * @brief Constants relating to implementation limits.
37  *
38  * This file is included via `#include_next` from the clang header of the same
39  * name that provides all the limits that the compiler is responsible for,
40  * primarily those relating to integer types defined by the C standard.
41  * This file defines the additional limits defined by POSIX.
42  */
43 
44 /*
45  * The Android build system has bionic _before_ the clang headers,
46  * so although the claim above that clang does an `#include_next`
47  * of this file is true for the NDK, it's not true for the OS,
48  * and we need to paper over that difference here until/unless
49  * the OS build changes.
50  */
51 #if __has_include_next(<limits.h>)
52 #include_next <limits.h>
53 #endif
54 
55 #include <sys/cdefs.h>
56 
57 /* Historically bionic exposed the content of <float.h> from <limits.h> and <sys/limits.h> too. */
58 #include <float.h>
59 
60 /* Many of the POSIX limits come from the kernel. */
61 #include <linux/limits.h>
62 
63 /** Maximum number of positional arguments in a printf()/scanf() format string. */
64 #define NL_ARGMAX 9
65 /** Maximum number of bytes in a $LANG name. */
66 #define NL_LANGMAX 14
67 /** Irrelevant with Android's <nl_types.h>. */
68 #define NL_MSGMAX 32767
69 /** Obsolete; removed from POSIX. */
70 #define NL_NMAX 1
71 /** Irrelevant with Android's <nl_types.h>. */
72 #define NL_SETMAX 255
73 /** Irrelevant with Android's <nl_types.h>. */
74 #define NL_TEXTMAX 255
75 
76 /** Obsolete; removed from POSIX. */
77 #define PASS_MAX 128
78 /** Obsolete; removed from POSIX. */
79 #define TMP_MAX 308915776
80 
81 /** Number of bits in a `long` (POSIX). */
82 #if __LP64__
83 #define LONG_BIT 64
84 #else
85 #define LONG_BIT 32
86 #endif
87 /** Number of bits in a "word" of `int` (POSIX). */
88 #define WORD_BIT 32
89 
90 /** Maximum value of a uid_t. */
91 #define UID_MAX UINT_MAX
92 /** Maximum value of a gid_t. */
93 #define GID_MAX UINT_MAX
94 /** Maximum value of a size_t. */
95 #define SIZE_T_MAX ULONG_MAX
96 /** Maximum value of a ssize_t. */
97 #define SSIZE_MAX LONG_MAX
98 
99 /**
100  * POSIX 2024's name for NSIG.
101  * See the NSIG documentation for an explanation and warnings.
102  */
103 #define NSIG_MAX 65
104 
105 /** Maximum number of bytes in a multibyte character. */
106 #define MB_LEN_MAX 4
107 
108 /** Default process priority. */
109 #define NZERO 20
110 
111 /** Maximum number of struct iovec that can be passed in a single readv()/writev(). */
112 #define IOV_MAX 1024
113 
114 /** Maximum value for a semaphore. */
115 #define SEM_VALUE_MAX 0x3fffffff
116 
117 /** Do not use: prefer getline() or asprintf() rather than hard-coding an arbitrary size. */
118 #define LINE_MAX _POSIX2_LINE_MAX
119 
120 /* POSIX says these belong in <unistd.h> but BSD has some in <limits.h>. */
121 #include <bits/posix_limits.h>
122 
123 /** Maximum length of a hostname returned by gethostname(). */
124 #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
125 
126 /** Maximum length of a login name. */
127 #define LOGIN_NAME_MAX 256
128 
129 /** Maximum length of terminal device name. */
130 #define TTY_NAME_MAX 32
131 
132 /** Maximum number of attempts to destroy thread-specific data when a thread exits. */
133 #define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
134 
135 /**
136  * The number of calls to pthread_key_create() without intervening calls to
137  * pthread_key_delete() that are guaranteed to succeed. See pthread_key_create()
138  * for more details and ways to avoid hitting this limit.
139  */
140 #define PTHREAD_KEYS_MAX 128
141 
142 /** bionic has no fixed limit on the number of threads. */
143 #undef PTHREAD_THREADS_MAX
144