2020-06-15 14:18:57 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_RUNTIME_SYSCONF_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_RUNTIME_SYSCONF_H_
|
|
|
|
|
2022-10-11 00:52:41 +00:00
|
|
|
#define _SC_ARG_MAX 0
|
|
|
|
#define _SC_CHILD_MAX 1
|
|
|
|
#define _SC_CLK_TCK 2
|
|
|
|
#define _SC_NGROUPS_MAX 3
|
|
|
|
#define _SC_OPEN_MAX 4
|
|
|
|
#define _SC_STREAM_MAX 5
|
|
|
|
#define _SC_TZNAME_MAX 6
|
|
|
|
#define _SC_JOB_CONTROL 7
|
|
|
|
#define _SC_SAVED_IDS 8
|
|
|
|
#define _SC_REALTIME_SIGNALS 9
|
|
|
|
#define _SC_PRIORITY_SCHEDULING 10
|
|
|
|
#define _SC_TIMERS 11
|
|
|
|
#define _SC_ASYNCHRONOUS_IO 12
|
|
|
|
#define _SC_PRIORITIZED_IO 13
|
|
|
|
#define _SC_SYNCHRONIZED_IO 14
|
|
|
|
#define _SC_FSYNC 15
|
|
|
|
#define _SC_MAPPED_FILES 16
|
|
|
|
#define _SC_MEMLOCK 17
|
|
|
|
#define _SC_MEMLOCK_RANGE 18
|
|
|
|
#define _SC_MEMORY_PROTECTION 19
|
|
|
|
#define _SC_MESSAGE_PASSING 20
|
|
|
|
#define _SC_SEMAPHORES 21
|
|
|
|
#define _SC_SHARED_MEMORY_OBJECTS 22
|
|
|
|
#define _SC_AIO_LISTIO_MAX 23
|
|
|
|
#define _SC_AIO_MAX 24
|
|
|
|
#define _SC_AIO_PRIO_DELTA_MAX 25
|
|
|
|
#define _SC_DELAYTIMER_MAX 26
|
|
|
|
#define _SC_MQ_OPEN_MAX 27
|
|
|
|
#define _SC_MQ_PRIO_MAX 28
|
|
|
|
#define _SC_VERSION 29
|
|
|
|
#define _SC_PAGE_SIZE 30
|
|
|
|
#define _SC_PAGESIZE 30 /* !! */
|
|
|
|
#define _SC_RTSIG_MAX 31
|
|
|
|
#define _SC_SEM_NSEMS_MAX 32
|
|
|
|
#define _SC_SEM_VALUE_MAX 33
|
|
|
|
#define _SC_SIGQUEUE_MAX 34
|
|
|
|
#define _SC_TIMER_MAX 35
|
|
|
|
#define _SC_BC_BASE_MAX 36
|
|
|
|
#define _SC_BC_DIM_MAX 37
|
|
|
|
#define _SC_BC_SCALE_MAX 38
|
|
|
|
#define _SC_BC_STRING_MAX 39
|
|
|
|
#define _SC_COLL_WEIGHTS_MAX 40
|
|
|
|
#define _SC_EXPR_NEST_MAX 42
|
|
|
|
#define _SC_LINE_MAX 43
|
|
|
|
#define _SC_RE_DUP_MAX 44
|
|
|
|
#define _SC_2_VERSION 46
|
|
|
|
#define _SC_2_C_BIND 47
|
|
|
|
#define _SC_2_C_DEV 48
|
|
|
|
#define _SC_2_FORT_DEV 49
|
|
|
|
#define _SC_2_FORT_RUN 50
|
|
|
|
#define _SC_2_SW_DEV 51
|
|
|
|
#define _SC_2_LOCALEDEF 52
|
|
|
|
#define _SC_UIO_MAXIOV 60 /* !! */
|
|
|
|
#define _SC_IOV_MAX 60
|
|
|
|
#define _SC_THREADS 67
|
|
|
|
#define _SC_THREAD_SAFE_FUNCTIONS 68
|
|
|
|
#define _SC_GETGR_R_SIZE_MAX 69
|
|
|
|
#define _SC_GETPW_R_SIZE_MAX 70
|
|
|
|
#define _SC_LOGIN_NAME_MAX 71
|
|
|
|
#define _SC_TTY_NAME_MAX 72
|
|
|
|
#define _SC_THREAD_DESTRUCTOR_ITERATIONS 73
|
|
|
|
#define _SC_THREAD_KEYS_MAX 74
|
|
|
|
#define _SC_THREAD_STACK_MIN 75
|
|
|
|
#define _SC_THREAD_THREADS_MAX 76
|
|
|
|
#define _SC_THREAD_ATTR_STACKADDR 77
|
|
|
|
#define _SC_THREAD_ATTR_STACKSIZE 78
|
|
|
|
#define _SC_THREAD_PRIORITY_SCHEDULING 79
|
|
|
|
#define _SC_THREAD_PRIO_INHERIT 80
|
|
|
|
#define _SC_THREAD_PRIO_PROTECT 81
|
|
|
|
#define _SC_THREAD_PROCESS_SHARED 82
|
|
|
|
#define _SC_NPROCESSORS_CONF 83
|
|
|
|
#define _SC_NPROCESSORS_ONLN 84
|
|
|
|
#define _SC_PHYS_PAGES 85
|
|
|
|
#define _SC_AVPHYS_PAGES 86
|
|
|
|
#define _SC_ATEXIT_MAX 87
|
|
|
|
#define _SC_PASS_MAX 88
|
|
|
|
#define _SC_XOPEN_VERSION 89
|
|
|
|
#define _SC_XOPEN_XCU_VERSION 90
|
|
|
|
#define _SC_XOPEN_UNIX 91
|
|
|
|
#define _SC_XOPEN_CRYPT 92
|
|
|
|
#define _SC_XOPEN_ENH_I18N 93
|
|
|
|
#define _SC_XOPEN_SHM 94
|
|
|
|
#define _SC_2_CHAR_TERM 95
|
|
|
|
#define _SC_2_UPE 97
|
|
|
|
#define _SC_XOPEN_XPG2 98
|
|
|
|
#define _SC_XOPEN_XPG3 99
|
|
|
|
#define _SC_XOPEN_XPG4 100
|
|
|
|
#define _SC_NZERO 109
|
|
|
|
#define _SC_XBS5_ILP32_OFF32 125
|
|
|
|
#define _SC_XBS5_ILP32_OFFBIG 126
|
|
|
|
#define _SC_XBS5_LP64_OFF64 127
|
|
|
|
#define _SC_XBS5_LPBIG_OFFBIG 128
|
|
|
|
#define _SC_XOPEN_LEGACY 129
|
|
|
|
#define _SC_XOPEN_REALTIME 130
|
|
|
|
#define _SC_XOPEN_REALTIME_THREADS 131
|
|
|
|
#define _SC_ADVISORY_INFO 132
|
|
|
|
#define _SC_BARRIERS 133
|
|
|
|
#define _SC_CLOCK_SELECTION 137
|
|
|
|
#define _SC_CPUTIME 138
|
|
|
|
#define _SC_THREAD_CPUTIME 139
|
|
|
|
#define _SC_MONOTONIC_CLOCK 149
|
|
|
|
#define _SC_READER_WRITER_LOCKS 153
|
|
|
|
#define _SC_SPIN_LOCKS 154
|
|
|
|
#define _SC_REGEXP 155
|
|
|
|
#define _SC_SHELL 157
|
|
|
|
#define _SC_SPAWN 159
|
|
|
|
#define _SC_SPORADIC_SERVER 160
|
|
|
|
#define _SC_THREAD_SPORADIC_SERVER 161
|
|
|
|
#define _SC_TIMEOUTS 164
|
|
|
|
#define _SC_TYPED_MEMORY_OBJECTS 165
|
|
|
|
#define _SC_2_PBS 168
|
|
|
|
#define _SC_2_PBS_ACCOUNTING 169
|
|
|
|
#define _SC_2_PBS_LOCATE 170
|
|
|
|
#define _SC_2_PBS_MESSAGE 171
|
|
|
|
#define _SC_2_PBS_TRACK 172
|
|
|
|
#define _SC_SYMLOOP_MAX 173
|
|
|
|
#define _SC_STREAMS 174
|
|
|
|
#define _SC_2_PBS_CHECKPOINT 175
|
|
|
|
#define _SC_V6_ILP32_OFF32 176
|
|
|
|
#define _SC_V6_ILP32_OFFBIG 177
|
|
|
|
#define _SC_V6_LP64_OFF64 178
|
|
|
|
#define _SC_V6_LPBIG_OFFBIG 179
|
|
|
|
#define _SC_HOST_NAME_MAX 180
|
|
|
|
#define _SC_TRACE 181
|
|
|
|
#define _SC_TRACE_EVENT_FILTER 182
|
|
|
|
#define _SC_TRACE_INHERIT 183
|
|
|
|
#define _SC_TRACE_LOG 184
|
|
|
|
#define _SC_IPV6 235
|
|
|
|
#define _SC_RAW_SOCKETS 236
|
|
|
|
#define _SC_V7_ILP32_OFF32 237
|
|
|
|
#define _SC_V7_ILP32_OFFBIG 238
|
|
|
|
#define _SC_V7_LP64_OFF64 239
|
|
|
|
#define _SC_V7_LPBIG_OFFBIG 240
|
|
|
|
#define _SC_SS_REPL_MAX 241
|
|
|
|
#define _SC_TRACE_EVENT_NAME_MAX 242
|
|
|
|
#define _SC_TRACE_NAME_MAX 243
|
|
|
|
#define _SC_TRACE_SYS_MAX 244
|
|
|
|
#define _SC_TRACE_USER_EVENT_MAX 245
|
|
|
|
#define _SC_XOPEN_STREAMS 246
|
|
|
|
#define _SC_THREAD_ROBUST_PRIO_INHERIT 247
|
|
|
|
#define _SC_THREAD_ROBUST_PRIO_PROTECT 248
|
Make improvements
- Every unit test now passes on Apple Silicon. The final piece of this
puzzle was porting our POSIX threads cancelation support, since that
works differently on ARM64 XNU vs. AMD64. Our semaphore support on
Apple Silicon is also superior now compared to AMD64, thanks to the
grand central dispatch library which lets *NSYNC locks go faster.
- The Cosmopolitan runtime is now more stable, particularly on Windows.
To do this, thread local storage is mandatory at all runtime levels,
and the innermost packages of the C library is no longer being built
using ASAN. TLS is being bootstrapped with a 128-byte TIB during the
process startup phase, and then later on the runtime re-allocates it
either statically or dynamically to support code using _Thread_local.
fork() and execve() now do a better job cooperating with threads. We
can now check how much stack memory is left in the process or thread
when functions like kprintf() / execve() etc. call alloca(), so that
ENOMEM can be raised, reduce a buffer size, or just print a warning.
- POSIX signal emulation is now implemented the same way kernels do it
with pthread_kill() and raise(). Any thread can interrupt any other
thread, regardless of what it's doing. If it's blocked on read/write
then the killer thread will cancel its i/o operation so that EINTR can
be returned in the mark thread immediately. If it's doing a tight CPU
bound operation, then that's also interrupted by the signal delivery.
Signal delivery works now by suspending a thread and pushing context
data structures onto its stack, and redirecting its execution to a
trampoline function, which calls SetThreadContext(GetCurrentThread())
when it's done.
- We're now doing a better job managing locks and handles. On NetBSD we
now close semaphore file descriptors in forked children. Semaphores on
Windows can now be canceled immediately, which means mutexes/condition
variables will now go faster. Apple Silicon semaphores can be canceled
too. We're now using Apple's pthread_yield() funciton. Apple _nocancel
syscalls are now used on XNU when appropriate to ensure pthread_cancel
requests aren't lost. The MbedTLS library has been updated to support
POSIX thread cancelations. See tool/build/runitd.c for an example of
how it can be used for production multi-threaded tls servers. Handles
on Windows now leak less often across processes. All i/o operations on
Windows are now overlapped, which means file pointers can no longer be
inherited across dup() and fork() for the time being.
- We now spawn a thread on Windows to deliver SIGCHLD and wakeup wait4()
which means, for example, that posix_spawn() now goes 3x faster. POSIX
spawn is also now more correct. Like Musl, it's now able to report the
failure code of execve() via a pipe although our approach favors using
shared memory to do that on systems that have a true vfork() function.
- We now spawn a thread to deliver SIGALRM to threads when setitimer()
is used. This enables the most precise wakeups the OS makes possible.
- The Cosmopolitan runtime now uses less memory. On NetBSD for example,
it turned out the kernel would actually commit the PT_GNU_STACK size
which caused RSS to be 6mb for every process. Now it's down to ~4kb.
On Apple Silicon, we reduce the mandatory upstream thread size to the
smallest possible size to reduce the memory overhead of Cosmo threads.
The examples directory has a program called greenbean which can spawn
a web server on Linux with 10,000 worker threads and have the memory
usage of the process be ~77mb. The 1024 byte overhead of POSIX-style
thread-local storage is now optional; it won't be allocated until the
pthread_setspecific/getspecific functions are called. On Windows, the
threads that get spawned which are internal to the libc implementation
use reserve rather than commit memory, which shaves a few hundred kb.
- sigaltstack() is now supported on Windows, however it's currently not
able to be used to handle stack overflows, since crash signals are
still generated by WIN32. However the crash handler will still switch
to the alt stack, which is helpful in environments with tiny threads.
- Test binaries are now smaller. Many of the mandatory dependencies of
the test runner have been removed. This ensures many programs can do a
better job only linking the the thing they're testing. This caused the
test binaries for LIBC_FMT for example, to decrease from 200kb to 50kb
- long double is no longer used in the implementation details of libc,
except in the APIs that define it. The old code that used long double
for time (instead of struct timespec) has now been thoroughly removed.
- ShowCrashReports() is now much tinier in MODE=tiny. Instead of doing
backtraces itself, it'll just print a command you can run on the shell
using our new `cosmoaddr2line` program to view the backtrace.
- Crash report signal handling now works in a much better way. Instead
of terminating the process, it now relies on SA_RESETHAND so that the
default SIG_IGN behavior can terminate the process if necessary.
- Our pledge() functionality has now been fully ported to AARCH64 Linux.
2023-09-19 03:44:45 +00:00
|
|
|
#define _SC_SIGSTKSZ 249
|
|
|
|
#define _SC_MINSIGSTKSZ 250
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
|
|
|
long sysconf(int);
|
|
|
|
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_RUNTIME_SYSCONF_H_ */
|