1 /*
2 * Copyright (C) 2017 The Android Open Source Project
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 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #include <limits.h>
30
31 #include "header_checks.h"
32
limits_h()33 static void limits_h() {
34 // These are only defined if they're constants.
35 #if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
36 MACRO(AIO_LISTIO_MAX);
37 MACRO(AIO_MAX);
38 #endif
39 #if !defined(__BIONIC__) && !defined(ANDROID_HOST_MUSL)
40 MACRO(AIO_PRIO_DELTA_MAX);
41 #endif
42 #if !defined(__BIONIC__) && !defined(__GLIBC__)
43 MACRO(ARG_MAX);
44 #endif
45 #if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
46 MACRO(ATEXIT_MAX);
47 MACRO(CHILD_MAX);
48 #endif
49 #if !defined(__BIONIC__)
50 MACRO(DELAYTIMER_MAX);
51 #endif
52 MACRO(HOST_NAME_MAX);
53 MACRO(IOV_MAX);
54 MACRO(LOGIN_NAME_MAX);
55 #if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
56 MACRO(MQ_OPEN_MAX);
57 #endif
58 #if !defined(__BIONIC__)
59 MACRO(MQ_PRIO_MAX);
60 #endif
61 #if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
62 MACRO(OPEN_MAX);
63 #endif
64 #if !defined(__BIONIC__) && !defined(__GLIBC__)
65 MACRO(PAGESIZE);
66 MACRO(PAGE_SIZE);
67 #endif
68 MACRO(PTHREAD_DESTRUCTOR_ITERATIONS);
69 MACRO(PTHREAD_KEYS_MAX);
70 #if !defined(__BIONIC__)
71 MACRO(PTHREAD_STACK_MIN);
72 #endif
73 #if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
74 MACRO(PTHREAD_THREADS_MAX);
75 #endif
76 #if !defined(ANDROID_HOST_MUSL)
77 MACRO(RTSIG_MAX);
78 #endif
79 #if !defined(__BIONIC__) && !defined(__GLIBC__)
80 MACRO(SEM_NSEMS_MAX);
81 #endif
82 MACRO(SEM_VALUE_MAX);
83 #if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
84 MACRO(SIGQUEUE_MAX);
85 MACRO(SS_REPL_MAX);
86 MACRO(STREAM_MAX);
87 #endif
88 #if !defined(__BIONIC__) && !defined(__GLIBC__)
89 MACRO(SYMLOOP_MAX);
90 #endif
91 #if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
92 MACRO(TIMER_MAX);
93 #endif
94 #if !defined(__BIONIC__)
95 MACRO(TTY_NAME_MAX);
96 #endif
97 #if !defined(__BIONIC__) && !defined(__GLIBC__)
98 MACRO(TZNAME_MAX);
99 #endif
100
101 #if !defined(__BIONIC__) && !defined(__GLIBC__)
102 MACRO(FILESIZEBITS);
103 #endif
104 #if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
105 MACRO(LINK_MAX);
106 #endif
107 #if !defined(ANDROID_HOST_MUSL)
108 MACRO(MAX_CANON);
109 MACRO(MAX_INPUT);
110 #endif
111 MACRO(NAME_MAX);
112 MACRO(PATH_MAX);
113 MACRO(PIPE_BUF);
114 #if 0 // No libc has these.
115 MACRO(POSIX_ALLOC_SIZE_MIN);
116 MACRO(POSIX_REC_INCR_XFER_SIZE);
117 MACRO(POSIX_REC_MAX_XFER_SIZE);
118 MACRO(POSIX_REC_MIN_XFER_SIZE);
119 MACRO(POSIX_REC_XFER_ALIGN);
120 #endif
121 #if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
122 MACRO(SYMLINK_MAX);
123 #endif
124
125 #if !defined(__BIONIC__)
126 MACRO(BC_BASE_MAX);
127 MACRO(BC_DIM_MAX);
128 MACRO(BC_SCALE_MAX);
129 MACRO(BC_STRING_MAX);
130 MACRO(CHARCLASS_NAME_MAX);
131 MACRO(COLL_WEIGHTS_MAX);
132 MACRO(EXPR_NEST_MAX);
133 MACRO(LINE_MAX);
134 MACRO(NGROUPS_MAX);
135 MACRO(RE_DUP_MAX);
136 #endif
137
138 MACRO_VALUE(_POSIX_CLOCKRES_MIN, 20000000);
139
140 MACRO_VALUE(_POSIX_AIO_LISTIO_MAX, 2);
141 MACRO_VALUE(_POSIX_AIO_MAX, 1);
142 MACRO_VALUE(_POSIX_ARG_MAX, 4096);
143 MACRO_VALUE(_POSIX_CHILD_MAX, 25);
144 MACRO_VALUE(_POSIX_DELAYTIMER_MAX, 32);
145 MACRO_VALUE(_POSIX_HOST_NAME_MAX, 255);
146 MACRO_VALUE(_POSIX_LINK_MAX, 8);
147 MACRO_VALUE(_POSIX_LOGIN_NAME_MAX, 9);
148 MACRO_VALUE(_POSIX_MAX_CANON, 255);
149 MACRO_VALUE(_POSIX_MAX_INPUT, 255);
150 MACRO_VALUE(_POSIX_MQ_OPEN_MAX, 8);
151 MACRO_VALUE(_POSIX_MQ_PRIO_MAX, 32);
152 MACRO_VALUE(_POSIX_NAME_MAX, 14);
153 MACRO_VALUE(_POSIX_NGROUPS_MAX, 8);
154 MACRO_VALUE(_POSIX_OPEN_MAX, 20);
155 MACRO_VALUE(_POSIX_PATH_MAX, 256);
156 MACRO_VALUE(_POSIX_PIPE_BUF, 512);
157 MACRO_VALUE(_POSIX_RE_DUP_MAX, 255);
158 MACRO_VALUE(_POSIX_RTSIG_MAX, 8);
159 MACRO_VALUE(_POSIX_SEM_NSEMS_MAX, 256);
160 MACRO_VALUE(_POSIX_SEM_VALUE_MAX, 32767);
161 MACRO_VALUE(_POSIX_SIGQUEUE_MAX, 32);
162 MACRO_VALUE(_POSIX_SSIZE_MAX, 32767);
163 #if !defined(__GLIBC__)
164 MACRO_VALUE(_POSIX_SS_REPL_MAX, 4);
165 #endif
166 MACRO_VALUE(_POSIX_STREAM_MAX, 8);
167 MACRO_VALUE(_POSIX_SYMLINK_MAX, 255);
168 MACRO_VALUE(_POSIX_SYMLOOP_MAX, 8);
169 MACRO_VALUE(_POSIX_THREAD_DESTRUCTOR_ITERATIONS, 4);
170 MACRO_VALUE(_POSIX_THREAD_KEYS_MAX, 128);
171 MACRO_VALUE(_POSIX_THREAD_THREADS_MAX, 64);
172 MACRO_VALUE(_POSIX_TIMER_MAX, 32);
173 #if !defined(__GLIBC__)
174 MACRO_VALUE(_POSIX_TRACE_EVENT_NAME_MAX, 30);
175 MACRO_VALUE(_POSIX_TRACE_NAME_MAX, 8);
176 MACRO_VALUE(_POSIX_TRACE_SYS_MAX, 8);
177 MACRO_VALUE(_POSIX_TRACE_USER_EVENT_MAX, 32);
178 #endif
179 MACRO_VALUE(_POSIX_TTY_NAME_MAX, 9);
180 MACRO_VALUE(_POSIX_TZNAME_MAX, 6);
181 MACRO_VALUE(_POSIX2_BC_BASE_MAX, 99);
182 MACRO_VALUE(_POSIX2_BC_DIM_MAX, 2048);
183 MACRO_VALUE(_POSIX2_BC_SCALE_MAX, 99);
184 MACRO_VALUE(_POSIX2_BC_STRING_MAX, 1000);
185 MACRO_VALUE(_POSIX2_CHARCLASS_NAME_MAX, 14);
186 MACRO_VALUE(_POSIX2_COLL_WEIGHTS_MAX, 2);
187 MACRO_VALUE(_POSIX2_EXPR_NEST_MAX, 32);
188 MACRO_VALUE(_POSIX2_LINE_MAX, 2048);
189 MACRO_VALUE(_POSIX2_RE_DUP_MAX, 255);
190 #if !defined(__GLIBC__)
191 MACRO_VALUE(_XOPEN_IOV_MAX, 16);
192 MACRO_VALUE(_XOPEN_NAME_MAX, 255);
193 MACRO_VALUE(_XOPEN_PATH_MAX, 1024);
194 #endif
195
196 MACRO_VALUE(CHAR_BIT, 8);
197 MACRO(CHAR_MAX);
198 MACRO(CHAR_MIN);
199 MACRO(INT_MAX);
200 MACRO(INT_MIN);
201 MACRO(LLONG_MAX);
202 MACRO(LLONG_MIN);
203 MACRO(LONG_BIT);
204 MACRO(LONG_MAX);
205 MACRO(LONG_MIN);
206 MACRO(MB_LEN_MAX);
207 MACRO_VALUE(SCHAR_MAX, 127);
208 MACRO_VALUE(SCHAR_MIN, -128);
209 MACRO(SHRT_MAX);
210 MACRO(SHRT_MIN);
211 MACRO(SSIZE_MAX);
212 MACRO_VALUE(UCHAR_MAX, 255);
213 MACRO(UINT_MAX);
214 MACRO(ULLONG_MAX);
215 MACRO(ULONG_MAX);
216 MACRO(USHRT_MAX);
217 MACRO(WORD_BIT);
218
219 MACRO(NL_ARGMAX);
220 MACRO(NL_LANGMAX);
221 MACRO(NL_MSGMAX);
222 MACRO(NL_SETMAX);
223 MACRO(NL_TEXTMAX);
224 MACRO(NZERO);
225 }
226