1 /*
2  * Copyright (c) 2024, Meta
3  * Copyright (c) 2024, Tenstorrent AI ULC
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 #ifndef ZEPHYR_INCLUDE_POSIX_SYS_SYSCONF_H_
8 #define ZEPHYR_INCLUDE_POSIX_SYS_SYSCONF_H_
9 
10 #include <zephyr/sys/util_macro.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 enum {
17 	_SC_ADVISORY_INFO,
18 	_SC_ASYNCHRONOUS_IO,
19 	_SC_BARRIERS,
20 	_SC_CLOCK_SELECTION,
21 	_SC_CPUTIME,
22 	_SC_FSYNC,
23 	_SC_IPV6,
24 	_SC_JOB_CONTROL,
25 	_SC_MAPPED_FILES,
26 	_SC_MEMLOCK,
27 	_SC_MEMLOCK_RANGE,
28 	_SC_MEMORY_PROTECTION,
29 	_SC_MESSAGE_PASSING,
30 	_SC_MONOTONIC_CLOCK,
31 	_SC_PRIORITIZED_IO,
32 	_SC_PRIORITY_SCHEDULING,
33 	_SC_RAW_SOCKETS,
34 	_SC_RE_DUP_MAX,
35 	_SC_READER_WRITER_LOCKS,
36 	_SC_REALTIME_SIGNALS,
37 	_SC_REGEXP,
38 	_SC_SAVED_IDS,
39 	_SC_SEMAPHORES,
40 	_SC_SHARED_MEMORY_OBJECTS,
41 	_SC_SHELL,
42 	_SC_SPAWN,
43 	_SC_SPIN_LOCKS,
44 	_SC_SPORADIC_SERVER,
45 	_SC_SS_REPL_MAX,
46 	_SC_SYNCHRONIZED_IO,
47 	_SC_THREAD_ATTR_STACKADDR,
48 	_SC_THREAD_ATTR_STACKSIZE,
49 	_SC_THREAD_CPUTIME,
50 	_SC_THREAD_PRIO_INHERIT,
51 	_SC_THREAD_PRIO_PROTECT,
52 	_SC_THREAD_PRIORITY_SCHEDULING,
53 	_SC_THREAD_PROCESS_SHARED,
54 	_SC_THREAD_ROBUST_PRIO_INHERIT,
55 	_SC_THREAD_ROBUST_PRIO_PROTECT,
56 	_SC_THREAD_SAFE_FUNCTIONS,
57 	_SC_THREAD_SPORADIC_SERVER,
58 	_SC_THREADS,
59 	_SC_TIMEOUTS,
60 	_SC_TIMERS,
61 	_SC_TRACE,
62 	_SC_TRACE_EVENT_FILTER,
63 	_SC_TRACE_EVENT_NAME_MAX,
64 	_SC_TRACE_INHERIT,
65 	_SC_TRACE_LOG,
66 	_SC_TRACE_NAME_MAX,
67 	_SC_TRACE_SYS_MAX,
68 	_SC_TRACE_USER_EVENT_MAX,
69 	_SC_TYPED_MEMORY_OBJECTS,
70 	_SC_VERSION,
71 	_SC_V7_ILP32_OFF32,
72 	_SC_V7_ILP32_OFFBIG,
73 	_SC_V7_LP64_OFF64,
74 	_SC_V7_LPBIG_OFFBIG,
75 	_SC_V6_ILP32_OFF32,
76 	_SC_V6_ILP32_OFFBIG,
77 	_SC_V6_LP64_OFF64,
78 	_SC_V6_LPBIG_OFFBIG,
79 	_SC_BC_BASE_MAX,
80 	_SC_BC_DIM_MAX,
81 	_SC_BC_SCALE_MAX,
82 	_SC_BC_STRING_MAX,
83 	_SC_2_C_BIND,
84 	_SC_2_C_DEV,
85 	_SC_2_CHAR_TERM,
86 	_SC_COLL_WEIGHTS_MAX,
87 	_SC_DELAYTIMER_MAX,
88 	_SC_EXPR_NEST_MAX,
89 	_SC_2_FORT_DEV,
90 	_SC_2_FORT_RUN,
91 	_SC_LINE_MAX,
92 	_SC_2_LOCALEDEF,
93 	_SC_2_PBS,
94 	_SC_2_PBS_ACCOUNTING,
95 	_SC_2_PBS_CHECKPOINT,
96 	_SC_2_PBS_LOCATE,
97 	_SC_2_PBS_MESSAGE,
98 	_SC_2_PBS_TRACK,
99 	_SC_2_SW_DEV,
100 	_SC_2_UPE,
101 	_SC_2_VERSION,
102 	_SC_XOPEN_CRYPT,
103 	_SC_XOPEN_ENH_I18N,
104 	_SC_XOPEN_REALTIME,
105 	_SC_XOPEN_REALTIME_THREADS,
106 	_SC_XOPEN_SHM,
107 	_SC_XOPEN_STREAMS,
108 	_SC_XOPEN_UNIX,
109 	_SC_XOPEN_UUCP,
110 	_SC_XOPEN_VERSION,
111 	_SC_CLK_TCK,
112 	_SC_GETGR_R_SIZE_MAX,
113 	_SC_GETPW_R_SIZE_MAX,
114 	_SC_AIO_LISTIO_MAX,
115 	_SC_AIO_MAX,
116 	_SC_AIO_PRIO_DELTA_MAX,
117 	_SC_ARG_MAX,
118 	_SC_ATEXIT_MAX,
119 	_SC_CHILD_MAX,
120 	_SC_HOST_NAME_MAX,
121 	_SC_IOV_MAX,
122 	_SC_LOGIN_NAME_MAX,
123 	_SC_NGROUPS_MAX,
124 	_SC_MQ_OPEN_MAX,
125 	_SC_MQ_PRIO_MAX,
126 	_SC_OPEN_MAX,
127 	_SC_PAGE_SIZE,
128 	_SC_PAGESIZE,
129 	_SC_THREAD_DESTRUCTOR_ITERATIONS,
130 	_SC_THREAD_KEYS_MAX,
131 	_SC_THREAD_STACK_MIN,
132 	_SC_THREAD_THREADS_MAX,
133 	_SC_RTSIG_MAX,
134 	_SC_SEM_NSEMS_MAX,
135 	_SC_SEM_VALUE_MAX,
136 	_SC_SIGQUEUE_MAX,
137 	_SC_STREAM_MAX,
138 	_SC_SYMLOOP_MAX,
139 	_SC_TIMER_MAX,
140 	_SC_TTY_NAME_MAX,
141 	_SC_TZNAME_MAX,
142 };
143 
144 #define __z_posix_sysconf_SC_ADVISORY_INFO (-1L)
145 #define __z_posix_sysconf_SC_ASYNCHRONOUS_IO                                                       \
146 	COND_CODE_1(CONFIG_POSIX_ASYNCHRONOUS_IO, (_POSIX_ASYNCHRONOUS_IO), (-1L))
147 #define __z_posix_sysconf_SC_BARRIERS COND_CODE_1(CONFIG_POSIX_BARRIERS, (_POSIX_BARRIERS), (-1L))
148 #define __z_posix_sysconf_SC_CLOCK_SELECTION                                                       \
149 	COND_CODE_1(CONFIG_POSIX_CLOCK_SELECTION, (_POSIX_CLOCK_SELECTION), (-1L))
150 #define __z_posix_sysconf_SC_CPUTIME \
151 	COND_CODE_1(CONFIG_POSIX_CPUTIME, (_POSIX_CPUTIME), (-1L))
152 #define __z_posix_sysconf_SC_FSYNC                                                                 \
153 	COND_CODE_1(CONFIG_POSIX_FSYNC, (_POSIX_FSYNC), (-1L))
154 #define __z_posix_sysconf_SC_IPV6              COND_CODE_1(CONFIG_NET_IPV6, (_POSIX_IPV6), (-1L))
155 #define __z_posix_sysconf_SC_JOB_CONTROL       (-1L)
156 #define __z_posix_sysconf_SC_MAPPED_FILES                                                          \
157 	COND_CODE_1(CONFIG_POSIX_MAPPED_FILES, (_POSIX_MAPPED_FILES), (-1L))
158 #define __z_posix_sysconf_SC_MEMLOCK                                                               \
159 	COND_CODE_1(CONFIG_POSIX_MEMLOCK, (_POSIX_MEMLOCK), (-1L))
160 #define __z_posix_sysconf_SC_MEMLOCK_RANGE                                                         \
161 	COND_CODE_1(CONFIG_POSIX_MEMLOCK_RANGE, (_POSIX_MEMLOCK_RANGE), (-1L))
162 #define __z_posix_sysconf_SC_MEMORY_PROTECTION                                                     \
163 	COND_CODE_1(CONFIG_POSIX_MEMORY_PROTECTION, (_POSIX_MEMORY_PROTECTION), (-1L))
164 #define __z_posix_sysconf_SC_MESSAGE_PASSING                                                       \
165 	COND_CODE_1(CONFIG_POSIX_MESSAGE_PASSING, (_POSIX_MESSAGE_PASSING), (-1L))
166 #define __z_posix_sysconf_SC_MONOTONIC_CLOCK                                                       \
167 	COND_CODE_1(CONFIG_POSIX_MONOTONIC_CLOCK, (_POSIX_MONOTONIC_CLOCK), (-1L))
168 #define __z_posix_sysconf_SC_PRIORITIZED_IO (-1L)
169 #define __z_posix_sysconf_SC_PRIORITY_SCHEDULING                                                   \
170 	COND_CODE_1(CONFIG_POSIX_PRIORITY_SCHEDULING, (_POSIX_PRIORITY_SCHEDULING), (-1L))
171 #define __z_posix_sysconf_SC_RAW_SOCKETS                                                           \
172 	COND_CODE_1(CONFIG_NET_SOCKETS_PACKET, (_POSIX_RAW_SOCKETS), (-1L))
173 #define __z_posix_sysconf_SC_RE_DUP_MAX _POSIX_RE_DUP_MAX
174 #define __z_posix_sysconf_SC_READER_WRITER_LOCKS                                                   \
175 	COND_CODE_1(CONFIG_POSIX_READER_WRITER_LOCKS, (_POSIX_READER_WRITER_LOCKS), (-1L))
176 #define __z_posix_sysconf_SC_REALTIME_SIGNALS      (-1L)
177 #define __z_posix_sysconf_SC_REGEXP                (-1L)
178 #define __z_posix_sysconf_SC_SAVED_IDS             (-1L)
179 #define __z_posix_sysconf_SC_SEMAPHORES                                                            \
180 	COND_CODE_1(CONFIG_POSIX_SEMAPHORES, (_POSIX_SEMAPHORES), (-1L))
181 #define __z_posix_sysconf_SC_SHARED_MEMORY_OBJECTS                                                 \
182 	COND_CODE_1(CONFIG_POSIX_SHARED_MEMORY_OBJECTS, (_POSIX_SHARED_MEMORY_OBJECTS), (-1L))
183 #define __z_posix_sysconf_SC_SHELL                 (-1L)
184 #define __z_posix_sysconf_SC_SPAWN                 (-1L)
185 #define __z_posix_sysconf_SC_SPIN_LOCKS                                                            \
186 	COND_CODE_1(CONFIG_POSIX_SPIN_LOCKS, (_POSIX_SPIN_LOCKS), (-1L))
187 #define __z_posix_sysconf_SC_SPORADIC_SERVER (-1L)
188 #define __z_posix_sysconf_SC_SS_REPL_MAX     _POSIX_SS_REPL_MAX
189 #define __z_posix_sysconf_SC_SYNCHRONIZED_IO (-1L)
190 #define __z_posix_sysconf_SC_THREAD_ATTR_STACKADDR                                                 \
191 	COND_CODE_1(CONFIG_POSIX_THREAD_ATTR_STACKADDR, (_POSIX_THREAD_ATTR_STACKADDR), (-1))
192 #define __z_posix_sysconf_SC_THREAD_ATTR_STACKSIZE                                                 \
193 	COND_CODE_1(CONFIG_POSIX_THREAD_ATTR_STACKSIZE, (_POSIX_THREAD_ATTR_STACKSIZE), (-1L))
194 #define __z_posix_sysconf_SC_THREAD_CPUTIME (-1L)
195 #define __z_posix_sysconf_SC_THREAD_PRIO_INHERIT                                                   \
196 	COND_CODE_1(CONFIG_POSIX_THREAD_PRIO_INHERIT, (_POSIX_THREAD_PRIO_INHERIT), (-1L))
197 #define __z_posix_sysconf_SC_THREAD_PRIO_PROTECT        (-1L)
198 #define __z_posix_sysconf_SC_THREAD_PRIORITY_SCHEDULING                                            \
199 	COND_CODE_1(CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING, (_POSIX_THREAD_PRIORITY_SCHEDULING),  \
200 		    (-1L))
201 #define __z_posix_sysconf_SC_THREAD_PROCESS_SHARED      (-1L)
202 #define __z_posix_sysconf_SC_THREAD_ROBUST_PRIO_INHERIT (-1L)
203 #define __z_posix_sysconf_SC_THREAD_ROBUST_PRIO_PROTECT (-1L)
204 #define __z_posix_sysconf_SC_THREAD_SAFE_FUNCTIONS                                                 \
205 	COND_CODE_1(CONFIG_POSIX_THREAD_SAFE_FUNCTIONS, (_POSIX_THREAD_SAFE_FUNCTIONS), (-1L))
206 #define __z_posix_sysconf_SC_THREAD_SPORADIC_SERVER       (-1L)
207 #define __z_posix_sysconf_SC_THREADS                                                               \
208 	COND_CODE_1(CONFIG_POSIX_THREADS, (_POSIX_THREADS), (-1L))
209 #define __z_posix_sysconf_SC_TIMEOUTS                                                              \
210 	COND_CODE_1(CONFIG_POSIX_TIMEOUTS, (_POSIX_TIMEOUTS), (-1L))
211 #define __z_posix_sysconf_SC_TIMERS                                                                \
212 	COND_CODE_1(CONFIG_POSIX_TIMEOUTS, (_POSIX_TIMERS), (-1))
213 #define __z_posix_sysconf_SC_TRACE                        (-1L)
214 #define __z_posix_sysconf_SC_TRACE_EVENT_FILTER           (-1L)
215 #define __z_posix_sysconf_SC_TRACE_EVENT_NAME_MAX         _POSIX_TRACE_NAME_MAX
216 #define __z_posix_sysconf_SC_TRACE_INHERIT                (-1L)
217 #define __z_posix_sysconf_SC_TRACE_LOG                    (-1L)
218 #define __z_posix_sysconf_SC_TRACE_NAME_MAX               _POSIX_TRACE_NAME_MAX
219 #define __z_posix_sysconf_SC_TRACE_SYS_MAX                _POSIX_TRACE_SYS_MAX
220 #define __z_posix_sysconf_SC_TRACE_USER_EVENT_MAX         _POSIX_TRACE_USER_EVENT_MAX
221 #define __z_posix_sysconf_SC_TYPED_MEMORY_OBJECTS         (-1L)
222 #define __z_posix_sysconf_SC_VERSION                      _POSIX_VERSION
223 #define __z_posix_sysconf_SC_V6_ILP32_OFF32               (-1L)
224 #define __z_posix_sysconf_SC_V6_ILP32_OFFBIG              (-1L)
225 #define __z_posix_sysconf_SC_V6_LP64_OFF64                (-1L)
226 #define __z_posix_sysconf_SC_V6_LPBIG_OFFBIG              (-1L)
227 #define __z_posix_sysconf_SC_V7_ILP32_OFF32               (-1L)
228 #define __z_posix_sysconf_SC_V7_ILP32_OFFBIG              (-1L)
229 #define __z_posix_sysconf_SC_V7_LP64_OFF64                (-1L)
230 #define __z_posix_sysconf_SC_V7_LPBIG_OFFBIG              (-1L)
231 #define __z_posix_sysconf_SC_BC_BASE_MAX                  _POSIX2_BC_BASE_MAX
232 #define __z_posix_sysconf_SC_BC_DIM_MAX                   _POSIX2_BC_DIM_MAX
233 #define __z_posix_sysconf_SC_BC_SCALE_MAX                 _POSIX2_BC_SCALE_MAX
234 #define __z_posix_sysconf_SC_BC_STRING_MAX                _POSIX2_BC_STRING_MAX
235 #define __z_posix_sysconf_SC_2_C_BIND                     _POSIX2_C_BIND
236 #define __z_posix_sysconf_SC_2_C_DEV                      _POSIX2_C_DEV
237 #define __z_posix_sysconf_SC_2_CHAR_TERM                  (-1L)
238 #define __z_posix_sysconf_SC_COLL_WEIGHTS_MAX             _POSIX2_COLL_WEIGHTS_MAX
239 #define __z_posix_sysconf_SC_DELAYTIMER_MAX               _POSIX_DELAYTIMER_MAX
240 #define __z_posix_sysconf_SC_EXPR_NEST_MAX                _POSIX2_EXPR_NEST_MAX
241 #define __z_posix_sysconf_SC_2_FORT_DEV                   (-1L)
242 #define __z_posix_sysconf_SC_2_FORT_RUN                   (-1L)
243 #define __z_posix_sysconf_SC_LINE_MAX                     (-1L)
244 #define __z_posix_sysconf_SC_2_LOCALEDEF                  (-1L)
245 #define __z_posix_sysconf_SC_2_PBS                        (-1L)
246 #define __z_posix_sysconf_SC_2_PBS_ACCOUNTING             (-1L)
247 #define __z_posix_sysconf_SC_2_PBS_CHECKPOINT             (-1L)
248 #define __z_posix_sysconf_SC_2_PBS_LOCATE                 (-1L)
249 #define __z_posix_sysconf_SC_2_PBS_MESSAGE                (-1L)
250 #define __z_posix_sysconf_SC_2_PBS_TRACK                  (-1L)
251 #define __z_posix_sysconf_SC_2_SW_DEV                     (-1L)
252 #define __z_posix_sysconf_SC_2_UPE                        (-1L)
253 #define __z_posix_sysconf_SC_2_VERSION                    _POSIX2_VERSION
254 #define __z_posix_sysconf_SC_XOPEN_CRYPT                  (-1L)
255 #define __z_posix_sysconf_SC_XOPEN_ENH_I18N               (-1L)
256 #define __z_posix_sysconf_SC_XOPEN_REALTIME               (-1L)
257 #define __z_posix_sysconf_SC_XOPEN_REALTIME_THREADS       (-1L)
258 #define __z_posix_sysconf_SC_XOPEN_SHM                    (-1L)
259 #define __z_posix_sysconf_SC_XOPEN_STREAMS                                                         \
260 	COND_CODE_1(CONFIG_XOPEN_STREAMS, (_XOPEN_STREAMS), (-1))
261 #define __z_posix_sysconf_SC_XOPEN_UNIX                   (-1L)
262 #define __z_posix_sysconf_SC_XOPEN_UUCP                   (-1L)
263 #define __z_posix_sysconf_SC_XOPEN_VERSION                _XOPEN_VERSION
264 #define __z_posix_sysconf_SC_CLK_TCK                      (100L)
265 #define __z_posix_sysconf_SC_GETGR_R_SIZE_MAX             (0L)
266 #define __z_posix_sysconf_SC_GETPW_R_SIZE_MAX             (0L)
267 #define __z_posix_sysconf_SC_AIO_LISTIO_MAX               AIO_LISTIO_MAX
268 #define __z_posix_sysconf_SC_AIO_MAX                      AIO_MAX
269 #define __z_posix_sysconf_SC_AIO_PRIO_DELTA_MAX           AIO_PRIO_DELTA_MAX
270 #define __z_posix_sysconf_SC_ARG_MAX                      ARG_MAX
271 #define __z_posix_sysconf_SC_ATEXIT_MAX                   ATEXIT_MAX
272 #define __z_posix_sysconf_SC_CHILD_MAX                    CHILD_MAX
273 #define __z_posix_sysconf_SC_HOST_NAME_MAX                HOST_NAME_MAX
274 #define __z_posix_sysconf_SC_IOV_MAX                      IOV_MAX
275 #define __z_posix_sysconf_SC_LOGIN_NAME_MAX               LOGIN_NAME_MAX
276 #define __z_posix_sysconf_SC_NGROUPS_MAX                  _POSIX_NGROUPS_MAX
277 #define __z_posix_sysconf_SC_MQ_OPEN_MAX                  MQ_OPEN_MAX
278 #define __z_posix_sysconf_SC_MQ_PRIO_MAX                  MQ_PRIO_MAX
279 #define __z_posix_sysconf_SC_OPEN_MAX                     CONFIG_ZVFS_OPEN_MAX
280 #define __z_posix_sysconf_SC_PAGE_SIZE                    PAGE_SIZE
281 #define __z_posix_sysconf_SC_PAGESIZE                     PAGESIZE
282 #define __z_posix_sysconf_SC_THREAD_DESTRUCTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS
283 #define __z_posix_sysconf_SC_THREAD_KEYS_MAX              PTHREAD_KEYS_MAX
284 #define __z_posix_sysconf_SC_THREAD_STACK_MIN             PTHREAD_STACK_MIN
285 #define __z_posix_sysconf_SC_THREAD_THREADS_MAX           PTHREAD_THREADS_MAX
286 #define __z_posix_sysconf_SC_RTSIG_MAX                    RTSIG_MAX
287 #define __z_posix_sysconf_SC_SEM_NSEMS_MAX                SEM_NSEMS_MAX
288 #define __z_posix_sysconf_SC_SEM_VALUE_MAX                SEM_VALUE_MAX
289 #define __z_posix_sysconf_SC_SIGQUEUE_MAX                 SIGQUEUE_MAX
290 #define __z_posix_sysconf_SC_STREAM_MAX                   STREAM_MAX
291 #define __z_posix_sysconf_SC_SYMLOOP_MAX                  SYMLOOP_MAX
292 #define __z_posix_sysconf_SC_TIMER_MAX                    TIMER_MAX
293 #define __z_posix_sysconf_SC_TTY_NAME_MAX                 TTY_NAME_MAX
294 #define __z_posix_sysconf_SC_TZNAME_MAX                   TZNAME_MAX
295 
296 #ifdef CONFIG_POSIX_SYSCONF_IMPL_MACRO
297 #define sysconf(x) (long)CONCAT(__z_posix_sysconf, x)
298 #endif
299 
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #endif /* ZEPHYR_INCLUDE_POSIX_SYS_SYSCONF_H_ */
305