1 /* 2 * Copyright (c) 2024, Meta 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #undef _POSIX_C_SOURCE 8 #define _POSIX_C_SOURCE 200809L 9 #include <zephyr/posix/pthread.h> 10 #include <zephyr/posix/sys/sysconf.h> 11 #include <zephyr/posix/unistd.h> 12 13 #ifdef CONFIG_POSIX_SYSCONF_IMPL_FULL 14 15 #define z_sysconf(x) (long)CONCAT(__z_posix_sysconf, x) 16 sysconf(int x)17long sysconf(int x) 18 { 19 switch (x) { 20 case _SC_ADVISORY_INFO: 21 return z_sysconf(_SC_ADVISORY_INFO); 22 case _SC_ASYNCHRONOUS_IO: 23 return z_sysconf(_SC_ASYNCHRONOUS_IO); 24 case _SC_BARRIERS: 25 return z_sysconf(_SC_BARRIERS); 26 case _SC_CLOCK_SELECTION: 27 return z_sysconf(_SC_CLOCK_SELECTION); 28 case _SC_CPUTIME: 29 return z_sysconf(_SC_CPUTIME); 30 case _SC_FSYNC: 31 return z_sysconf(_SC_FSYNC); 32 case _SC_IPV6: 33 return z_sysconf(_SC_IPV6); 34 case _SC_JOB_CONTROL: 35 return z_sysconf(_SC_JOB_CONTROL); 36 case _SC_MAPPED_FILES: 37 return z_sysconf(_SC_MAPPED_FILES); 38 case _SC_MEMLOCK: 39 return z_sysconf(_SC_MEMLOCK); 40 case _SC_MEMLOCK_RANGE: 41 return z_sysconf(_SC_MEMLOCK_RANGE); 42 case _SC_MEMORY_PROTECTION: 43 return z_sysconf(_SC_MEMORY_PROTECTION); 44 case _SC_MESSAGE_PASSING: 45 return z_sysconf(_SC_MESSAGE_PASSING); 46 case _SC_MONOTONIC_CLOCK: 47 return z_sysconf(_SC_MONOTONIC_CLOCK); 48 case _SC_PRIORITIZED_IO: 49 return z_sysconf(_SC_PRIORITIZED_IO); 50 case _SC_PRIORITY_SCHEDULING: 51 return z_sysconf(_SC_PRIORITY_SCHEDULING); 52 case _SC_RAW_SOCKETS: 53 return z_sysconf(_SC_RAW_SOCKETS); 54 case _SC_RE_DUP_MAX: 55 return z_sysconf(_SC_RE_DUP_MAX); 56 case _SC_READER_WRITER_LOCKS: 57 return z_sysconf(_SC_READER_WRITER_LOCKS); 58 case _SC_REALTIME_SIGNALS: 59 return z_sysconf(_SC_REALTIME_SIGNALS); 60 case _SC_REGEXP: 61 return z_sysconf(_SC_REGEXP); 62 case _SC_SAVED_IDS: 63 return z_sysconf(_SC_SAVED_IDS); 64 case _SC_SEMAPHORES: 65 return z_sysconf(_SC_SEMAPHORES); 66 case _SC_SHARED_MEMORY_OBJECTS: 67 return z_sysconf(_SC_SHARED_MEMORY_OBJECTS); 68 case _SC_SHELL: 69 return z_sysconf(_SC_SHELL); 70 case _SC_SPAWN: 71 return z_sysconf(_SC_SPAWN); 72 case _SC_SPIN_LOCKS: 73 return z_sysconf(_SC_SPIN_LOCKS); 74 case _SC_SPORADIC_SERVER: 75 return z_sysconf(_SC_SPORADIC_SERVER); 76 case _SC_SS_REPL_MAX: 77 return z_sysconf(_SC_SS_REPL_MAX); 78 case _SC_SYNCHRONIZED_IO: 79 return z_sysconf(_SC_SYNCHRONIZED_IO); 80 case _SC_THREAD_ATTR_STACKADDR: 81 return z_sysconf(_SC_THREAD_ATTR_STACKADDR); 82 case _SC_THREAD_ATTR_STACKSIZE: 83 return z_sysconf(_SC_THREAD_ATTR_STACKSIZE); 84 case _SC_THREAD_CPUTIME: 85 return z_sysconf(_SC_THREAD_CPUTIME); 86 case _SC_THREAD_PRIO_INHERIT: 87 return z_sysconf(_SC_THREAD_PRIO_INHERIT); 88 case _SC_THREAD_PRIO_PROTECT: 89 return z_sysconf(_SC_THREAD_PRIO_PROTECT); 90 case _SC_THREAD_PRIORITY_SCHEDULING: 91 return z_sysconf(_SC_THREAD_PRIORITY_SCHEDULING); 92 case _SC_THREAD_PROCESS_SHARED: 93 return z_sysconf(_SC_THREAD_PROCESS_SHARED); 94 case _SC_THREAD_ROBUST_PRIO_INHERIT: 95 return z_sysconf(_SC_THREAD_ROBUST_PRIO_INHERIT); 96 case _SC_THREAD_ROBUST_PRIO_PROTECT: 97 return z_sysconf(_SC_THREAD_ROBUST_PRIO_PROTECT); 98 case _SC_THREAD_SAFE_FUNCTIONS: 99 return z_sysconf(_SC_THREAD_SAFE_FUNCTIONS); 100 case _SC_THREAD_SPORADIC_SERVER: 101 return z_sysconf(_SC_THREAD_SPORADIC_SERVER); 102 case _SC_THREADS: 103 return z_sysconf(_SC_THREADS); 104 case _SC_TIMEOUTS: 105 return z_sysconf(_SC_TIMEOUTS); 106 case _SC_TIMERS: 107 return z_sysconf(_SC_TIMERS); 108 case _SC_TRACE: 109 return z_sysconf(_SC_TRACE); 110 case _SC_TRACE_EVENT_FILTER: 111 return z_sysconf(_SC_TRACE_EVENT_FILTER); 112 case _SC_TRACE_EVENT_NAME_MAX: 113 return z_sysconf(_SC_TRACE_EVENT_NAME_MAX); 114 case _SC_TRACE_INHERIT: 115 return z_sysconf(_SC_TRACE_INHERIT); 116 case _SC_TRACE_LOG: 117 return z_sysconf(_SC_TRACE_LOG); 118 case _SC_TRACE_NAME_MAX: 119 return z_sysconf(_SC_TRACE_NAME_MAX); 120 case _SC_TRACE_SYS_MAX: 121 return z_sysconf(_SC_TRACE_SYS_MAX); 122 case _SC_TRACE_USER_EVENT_MAX: 123 return z_sysconf(_SC_TRACE_USER_EVENT_MAX); 124 case _SC_TYPED_MEMORY_OBJECTS: 125 return z_sysconf(_SC_TYPED_MEMORY_OBJECTS); 126 case _SC_VERSION: 127 return z_sysconf(_SC_VERSION); 128 case _SC_V6_ILP32_OFF32: 129 return z_sysconf(_SC_V6_ILP32_OFF32); 130 case _SC_V6_ILP32_OFFBIG: 131 return z_sysconf(_SC_V6_ILP32_OFFBIG); 132 case _SC_V6_LP64_OFF64: 133 return z_sysconf(_SC_V6_LP64_OFF64); 134 case _SC_V6_LPBIG_OFFBIG: 135 return z_sysconf(_SC_V6_LPBIG_OFFBIG); 136 case _SC_V7_ILP32_OFF32: 137 return z_sysconf(_SC_V7_ILP32_OFF32); 138 case _SC_V7_ILP32_OFFBIG: 139 return z_sysconf(_SC_V7_ILP32_OFFBIG); 140 case _SC_V7_LP64_OFF64: 141 return z_sysconf(_SC_V7_LP64_OFF64); 142 case _SC_V7_LPBIG_OFFBIG: 143 return z_sysconf(_SC_V7_LPBIG_OFFBIG); 144 case _SC_BC_BASE_MAX: 145 return z_sysconf(_SC_BC_BASE_MAX); 146 case _SC_BC_DIM_MAX: 147 return z_sysconf(_SC_BC_DIM_MAX); 148 case _SC_BC_SCALE_MAX: 149 return z_sysconf(_SC_BC_SCALE_MAX); 150 case _SC_BC_STRING_MAX: 151 return z_sysconf(_SC_BC_STRING_MAX); 152 case _SC_2_C_BIND: 153 return z_sysconf(_SC_2_C_BIND); 154 case _SC_2_C_DEV: 155 return z_sysconf(_SC_2_C_DEV); 156 case _SC_2_CHAR_TERM: 157 return z_sysconf(_SC_2_CHAR_TERM); 158 case _SC_COLL_WEIGHTS_MAX: 159 return z_sysconf(_SC_COLL_WEIGHTS_MAX); 160 case _SC_DELAYTIMER_MAX: 161 return z_sysconf(_SC_DELAYTIMER_MAX); 162 case _SC_EXPR_NEST_MAX: 163 return z_sysconf(_SC_EXPR_NEST_MAX); 164 case _SC_2_FORT_DEV: 165 return z_sysconf(_SC_2_FORT_DEV); 166 case _SC_2_FORT_RUN: 167 return z_sysconf(_SC_2_FORT_RUN); 168 case _SC_LINE_MAX: 169 return z_sysconf(_SC_LINE_MAX); 170 case _SC_2_LOCALEDEF: 171 return z_sysconf(_SC_2_LOCALEDEF); 172 case _SC_2_PBS: 173 return z_sysconf(_SC_2_PBS); 174 case _SC_2_PBS_ACCOUNTING: 175 return z_sysconf(_SC_2_PBS_ACCOUNTING); 176 case _SC_2_PBS_CHECKPOINT: 177 return z_sysconf(_SC_2_PBS_CHECKPOINT); 178 case _SC_2_PBS_LOCATE: 179 return z_sysconf(_SC_2_PBS_LOCATE); 180 case _SC_2_PBS_MESSAGE: 181 return z_sysconf(_SC_2_PBS_MESSAGE); 182 case _SC_2_PBS_TRACK: 183 return z_sysconf(_SC_2_PBS_TRACK); 184 case _SC_2_SW_DEV: 185 return z_sysconf(_SC_2_SW_DEV); 186 case _SC_2_UPE: 187 return z_sysconf(_SC_2_UPE); 188 case _SC_2_VERSION: 189 return z_sysconf(_SC_2_VERSION); 190 case _SC_XOPEN_CRYPT: 191 return z_sysconf(_SC_XOPEN_CRYPT); 192 case _SC_XOPEN_ENH_I18N: 193 return z_sysconf(_SC_XOPEN_ENH_I18N); 194 case _SC_XOPEN_REALTIME: 195 return z_sysconf(_SC_XOPEN_REALTIME); 196 case _SC_XOPEN_REALTIME_THREADS: 197 return z_sysconf(_SC_XOPEN_REALTIME_THREADS); 198 case _SC_XOPEN_SHM: 199 return z_sysconf(_SC_XOPEN_SHM); 200 case _SC_XOPEN_STREAMS: 201 return z_sysconf(_SC_XOPEN_STREAMS); 202 case _SC_XOPEN_UNIX: 203 return z_sysconf(_SC_XOPEN_UNIX); 204 case _SC_XOPEN_UUCP: 205 return z_sysconf(_SC_XOPEN_UUCP); 206 case _SC_XOPEN_VERSION: 207 return z_sysconf(_SC_XOPEN_VERSION); 208 case _SC_CLK_TCK: 209 return z_sysconf(_SC_CLK_TCK); 210 case _SC_GETGR_R_SIZE_MAX: 211 return z_sysconf(_SC_GETGR_R_SIZE_MAX); 212 case _SC_GETPW_R_SIZE_MAX: 213 return z_sysconf(_SC_GETPW_R_SIZE_MAX); 214 case _SC_AIO_LISTIO_MAX: 215 return z_sysconf(_SC_AIO_LISTIO_MAX); 216 case _SC_AIO_MAX: 217 return z_sysconf(_SC_AIO_MAX); 218 case _SC_AIO_PRIO_DELTA_MAX: 219 return z_sysconf(_SC_AIO_PRIO_DELTA_MAX); 220 case _SC_ARG_MAX: 221 return z_sysconf(_SC_ARG_MAX); 222 case _SC_ATEXIT_MAX: 223 return z_sysconf(_SC_ATEXIT_MAX); 224 case _SC_CHILD_MAX: 225 return z_sysconf(_SC_CHILD_MAX); 226 case _SC_HOST_NAME_MAX: 227 return z_sysconf(_SC_HOST_NAME_MAX); 228 case _SC_IOV_MAX: 229 return z_sysconf(_SC_IOV_MAX); 230 case _SC_LOGIN_NAME_MAX: 231 return z_sysconf(_SC_LOGIN_NAME_MAX); 232 case _SC_NGROUPS_MAX: 233 return z_sysconf(_SC_NGROUPS_MAX); 234 case _SC_MQ_OPEN_MAX: 235 return z_sysconf(_SC_MQ_OPEN_MAX); 236 case _SC_MQ_PRIO_MAX: 237 return z_sysconf(_SC_MQ_PRIO_MAX); 238 case _SC_OPEN_MAX: 239 return z_sysconf(_SC_OPEN_MAX); 240 case _SC_PAGE_SIZE: 241 return z_sysconf(_SC_PAGE_SIZE); 242 case _SC_PAGESIZE: 243 return z_sysconf(_SC_PAGESIZE); 244 case _SC_THREAD_DESTRUCTOR_ITERATIONS: 245 return z_sysconf(_SC_THREAD_DESTRUCTOR_ITERATIONS); 246 case _SC_THREAD_KEYS_MAX: 247 return z_sysconf(_SC_THREAD_KEYS_MAX); 248 case _SC_THREAD_STACK_MIN: 249 return z_sysconf(_SC_THREAD_STACK_MIN); 250 case _SC_THREAD_THREADS_MAX: 251 return z_sysconf(_SC_THREAD_THREADS_MAX); 252 case _SC_RTSIG_MAX: 253 return z_sysconf(_SC_RTSIG_MAX); 254 case _SC_SEM_NSEMS_MAX: 255 return z_sysconf(_SC_SEM_NSEMS_MAX); 256 case _SC_SEM_VALUE_MAX: 257 return z_sysconf(_SC_SEM_VALUE_MAX); 258 case _SC_SIGQUEUE_MAX: 259 return z_sysconf(_SC_SIGQUEUE_MAX); 260 case _SC_STREAM_MAX: 261 return z_sysconf(_SC_STREAM_MAX); 262 case _SC_SYMLOOP_MAX: 263 return z_sysconf(_SC_SYMLOOP_MAX); 264 case _SC_TIMER_MAX: 265 return z_sysconf(_SC_TIMER_MAX); 266 case _SC_TTY_NAME_MAX: 267 return z_sysconf(_SC_TTY_NAME_MAX); 268 case _SC_TZNAME_MAX: 269 return z_sysconf(_SC_TZNAME_MAX); 270 default: 271 errno = EINVAL; 272 return -1; 273 } 274 } 275 276 #endif /* CONFIG_POSIX_SYSCONF_IMPL_FULL */ 277