cosmopolitan/libc/isystem
Justine Tunney ec480f5aa0
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-18 21:04:47 -07:00
..
arpa Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
linux Make the Windows Console work better 2023-09-07 18:27:22 -07:00
net Get us closer to building busybox 2023-06-18 04:13:45 -07:00
netinet get rsync to build (#886) 2023-08-16 21:41:36 -07:00
sys Get GNU MPFR and MPC tests to pass 2023-08-21 15:05:10 -07:00
algorithm Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
alloca.h Remove some dead code 2023-07-03 02:48:29 -07:00
ammintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
any Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ar.h Remove some dead code 2023-07-03 02:48:29 -07:00
array Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
assert.h Further improve fatcosmocc 2023-08-13 01:51:39 -07:00
atomic Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
bit Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
bitset Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
byteswap.h Clean up more code 2023-06-18 01:00:05 -07:00
cassert Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ccomplex Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cctype Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cerrno Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cfenv Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cfloat Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
charconv Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
chrono Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cinttypes Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ciso646 Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
climits Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
clocale Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
clzerointrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
cmath Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
codecvt Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
compare Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
complex Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
complex.h Clean up more code 2023-06-18 01:00:05 -07:00
condition_variable Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cosmo.h Get GNU MPFR and MPC tests to pass 2023-08-21 15:05:10 -07:00
cpio.h Clean up more code 2023-06-18 01:00:05 -07:00
cpuid.h Clean up more code 2023-06-18 01:00:05 -07:00
crypt.h Clean up more code 2023-06-18 01:00:05 -07:00
csetjmp Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
csignal Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstdarg Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstdbool Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstddef Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstdint Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstdio Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstdlib Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cstring Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ctgmath Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ctime Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ctype.h Clean up more code 2023-06-18 01:00:05 -07:00
cwchar Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
cwctype Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
deque Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
dirent.h Clean up more code 2023-06-18 01:00:05 -07:00
dlfcn.h Clean up more code 2023-06-18 01:00:05 -07:00
elf.h Clean up more code 2023-06-18 01:00:05 -07:00
emmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
endian.h Clean up more code 2023-06-18 01:00:05 -07:00
err.h Clean up more code 2023-06-18 01:00:05 -07:00
errno.h Clean up more code 2023-06-18 01:00:05 -07:00
exception Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
execution Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
fcntl.h Clean up more code 2023-06-18 01:00:05 -07:00
features.h Clean up more code 2023-06-18 01:00:05 -07:00
fenv.h Clean up more code 2023-06-18 01:00:05 -07:00
filesystem Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
float.h Clean up more code 2023-06-18 01:00:05 -07:00
fnmatch.h Clean up more code 2023-06-18 01:00:05 -07:00
forward_list Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
fstream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ftw.h Make fixes and improvements 2023-07-09 05:21:11 -07:00
functional Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
getopt.h Fix getopt again 2023-08-15 20:06:19 -07:00
glob.h Clean up more code 2023-06-18 01:00:05 -07:00
grp.h Clean up more code 2023-06-18 01:00:05 -07:00
iconv.h Clean up more code 2023-06-18 01:00:05 -07:00
immintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
initializer_list Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
inttypes.h Clean up more code 2023-06-18 01:00:05 -07:00
iomanip Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ios Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
iosfwd Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
iostream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
iso646.h Clean up more code 2023-06-18 01:00:05 -07:00
istream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
iterator Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
langinfo.h Clean up more code 2023-06-18 01:00:05 -07:00
libgen.h Implement more toolchain fixes 2023-06-18 05:39:31 -07:00
limits Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
limits.h Clean up more code 2023-06-18 01:00:05 -07:00
list Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
locale Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
locale.h Clean up more code 2023-06-18 01:00:05 -07:00
malloc.h Clean up more code 2023-06-18 01:00:05 -07:00
map Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
math.h Clean up more code 2023-06-18 01:00:05 -07:00
memory Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
memory.h Clean up more code 2023-06-18 01:00:05 -07:00
mm3dnow.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
mm_malloc.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
mmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
mntent.h Make some foss compatibility improvements 2022-10-14 13:59:34 -07:00
monetary.h Greatly expand system() shell code features 2022-10-11 21:30:31 -07:00
mutex Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
mwaitxintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
netdb.h Get us closer to building busybox 2023-06-18 04:13:45 -07:00
new Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
nl_types.h Fold LIBC_UNICODE into LIBC_STR 2022-08-13 08:42:32 -07:00
nmmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
nsync.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_atomic.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_counter.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_cv.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_debug.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_mu.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_mu_wait.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_note.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_once.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_time.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
nsync_waiter.h Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
numeric Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
optional Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ostream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
paths.h Initial import 2020-06-15 07:18:57 -07:00
pmmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
poll.h Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
popcntintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
pthread.h Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
pwd.h Fix isystem headers including wrong files (#108) 2021-03-06 21:06:29 -08:00
queue Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
random Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
ratio Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
regex Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
regex.h Initial import 2020-06-15 07:18:57 -07:00
sched.h Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
scoped_allocator Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
semaphore.h Add posix semaphores support 2022-10-14 09:21:02 -07:00
set Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
setjmp.h Clean up more code 2023-06-18 01:00:05 -07:00
sgxintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
signal.h Simplify cosmocc builds (#863) 2023-07-23 11:11:08 -07:00
smmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
span Make some fixes for libcxx 2023-07-07 19:35:58 -07:00
spawn.h Make improvements 2023-09-18 21:04:47 -07:00
sstream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
stack Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
stdalign.h Clean up more code 2023-06-18 01:00:05 -07:00
stdarg.h Make the Windows Console work better 2023-09-07 18:27:22 -07:00
stdatomic.h Clean up more code 2023-06-18 01:00:05 -07:00
stdbool.h Make fatcosmocc good enough to build ncurses 6.4 2023-08-12 22:30:05 -07:00
stdc-predef.h Initial import 2020-06-15 07:18:57 -07:00
stdckdint.h Clean up more code 2023-06-18 01:00:05 -07:00
stddef.h Clean up more code 2023-06-18 01:00:05 -07:00
stdexcept Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
stdint.h Clean up more code 2023-06-18 01:00:05 -07:00
stdio.h Make improvements 2023-09-06 12:34:59 -07:00
stdio_ext.h Clean up more code 2023-06-18 01:00:05 -07:00
stdlib.h Make improvements 2023-09-06 12:34:59 -07:00
stdnoreturn.h Clean up more code 2023-06-18 01:00:05 -07:00
streambuf Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
string Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
string.h Clean up more code 2023-06-18 01:00:05 -07:00
string_view Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
strings.h Clean up more code 2023-06-18 01:00:05 -07:00
strstream Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
sysexits.h Clean up more code 2023-06-18 01:00:05 -07:00
syslog.h Clean up more code 2023-06-18 01:00:05 -07:00
system_error Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
termios.h Clean up more code 2023-06-18 01:00:05 -07:00
tgmath.h Clean up more code 2023-06-18 01:00:05 -07:00
thread Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
time.h Clean up more code 2023-06-18 01:00:05 -07:00
tmmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
tuple Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
type_traits Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
typeindex Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
typeinfo Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
uchar.h Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
uio.h Improve isystem includes and magic numbers 2021-08-14 23:36:36 -07:00
unistd.h Refactor fatcosmocc into a single file 2023-08-14 22:26:17 -07:00
unordered_map Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
unordered_set Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
utility Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
utime.h Clean up more code 2023-06-18 01:00:05 -07:00
utmp.h Clean up more code 2023-06-18 01:00:05 -07:00
utmpx.h Clean up more code 2023-06-18 01:00:05 -07:00
valarray Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
variant Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
vector Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
version Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
wait.h Clean up more code 2023-06-18 01:00:05 -07:00
wchar.h Clean up more code 2023-06-18 01:00:05 -07:00
wctype.h Clean up more code 2023-06-18 01:00:05 -07:00
windows.h Fix some win32 definitions 2022-03-22 19:54:36 -07:00
winternl.h Restore strict header checking 2022-08-13 16:02:01 -07:00
wmmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
x86intrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00
xmmintrin.h Add Intel intrinsics headers 2023-04-27 05:44:38 -07:00