cosmopolitan/libc/nexgen32e
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
..
argc.S Improve memory safety 2021-10-13 17:27:13 -07:00
argc2.c Get LIBC_RUNTIME and LIBC_CALLS building on aarch64 2023-05-10 04:20:47 -07:00
argv.S Perform some minor code cleanup 2021-03-04 13:22:32 -08:00
argv2.c Get LIBC_RUNTIME and LIBC_CALLS building on aarch64 2023-05-10 04:20:47 -07:00
auxv.S Perform some minor code cleanup 2021-03-04 13:22:32 -08:00
auxv2.c Make progress towards aarch64 build 2023-05-10 04:20:46 -07:00
bench.h Make AARCH64 harder, better, faster, stronger 2023-05-15 02:15:34 -07:00
blink_linux_aarch64.S Mint APE Loader v1.5 2023-07-26 13:54:49 -07:00
blink_xnu_aarch64.S Mint APE Loader v1.5 2023-07-26 13:54:49 -07:00
cachesize.h Pay off more technical debt 2022-09-12 23:36:56 -07:00
checkstackalign.S Improve aarch64 native support some more 2023-06-04 08:58:47 -07:00
cpuid4.internal.h Get Cosmopolitan into releasable state 2020-11-25 08:19:00 -08:00
crc32.h Make improvements 2023-09-18 21:04:47 -07:00
crc32init.c Make more progress on aarch64 2023-05-10 04:20:47 -07:00
djbsort-avx2.S Clean old .source directive out of asm code 2022-03-18 12:43:21 -07:00
environ.S Make progress towards aarch64 build 2023-05-10 04:20:46 -07:00
environ2.c Get LIBC_RUNTIME and LIBC_CALLS building on aarch64 2023-05-10 04:20:47 -07:00
envp.c Make improvements for Actually Portable Emacs 2023-08-19 06:44:58 -07:00
ffs.h Port a lot more code to AARCH64 2023-05-14 09:37:26 -07:00
gc.internal.h Pay off more technical debt 2022-09-12 23:36:56 -07:00
gc.S Make improvements 2023-09-18 21:04:47 -07:00
gclongjmp.S Get garbage collector working on aarch64 2023-06-07 03:34:45 -07:00
hascharacter.internal.h Get Cosmopolitan into releasable state 2020-11-25 08:19:00 -08:00
identity.S Clean old .source directive out of asm code 2022-03-18 12:43:21 -07:00
kbase36.c Get LIBC_FMT to build for aarch64 2023-05-10 04:20:47 -07:00
kcp437.S Replace COSMO define with _COSMO_SOURCE 2023-08-13 20:55:04 -07:00
kcpuids.h Auto-generate some documentation 2020-12-26 02:09:07 -08:00
kcpuids.S Perform some code cleanup 2022-06-23 10:21:07 -07:00
khalfcache3.S Introduce native support for MacOS ARM64 2023-05-20 04:17:03 -07:00
kompressor.h Replace COSMO define with _COSMO_SOURCE 2023-08-13 20:55:04 -07:00
ksha256.S Make progress towards aarch64 build 2023-05-10 04:20:46 -07:00
ksha512.S Make progress towards aarch64 build 2023-05-10 04:20:46 -07:00
ktens.c Make more code aarch64 friendly 2023-05-10 04:20:46 -07:00
ktensindex.S Make some minor fixups to bug reporting, etc. 2022-07-11 05:58:24 -07:00
ktolower.c Get LIBC_FMT to build for aarch64 2023-05-10 04:20:47 -07:00
ktoupper.c Get LIBC_FMT to build for aarch64 2023-05-10 04:20:47 -07:00
longerjmp.S Introduce #include <cosmo.h> to toolchain users 2023-06-09 18:03:05 -07:00
longjmp.S Introduce #include <cosmo.h> to toolchain users 2023-06-09 18:03:05 -07:00
lz4.h Fold LIBC_BITS into LIBC_INTRIN 2022-08-11 12:13:18 -07:00
macros.h Make improvements 2020-12-01 03:43:40 -08:00
macros.internal.inc Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
mcount.S Make considerably more progress on AARCH64 2023-05-12 22:42:57 -07:00
msr.internal.h Run clang-format on most sources 2023-04-27 05:44:32 -07:00
mul4x4adx.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
mul6x6adx.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
mul8x8adx.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
nexgen32e.h Do some more aarch64 fixups 2023-05-10 04:20:47 -07:00
nexgen32e.mk Make improvements for Actually Portable Emacs 2023-08-19 06:44:58 -07:00
nt2sysv.h Get Cosmopolitan into releasable state 2020-11-25 08:19:00 -08:00
nt2sysv.S Fix some behavioral issues on Windows 2023-07-09 09:59:22 -07:00
pcmpstr.inc Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
pid.c Make more code aarch64 friendly 2023-05-10 04:20:46 -07:00
program_invocation_name.S Add syscalls to Blinkenlights and fix bugs 2022-05-13 13:31:21 -07:00
program_invocation_name2.c Make considerably more progress on AARCH64 2023-05-12 22:42:57 -07:00
rdtsc.h Make improvements 2023-06-03 08:12:22 -07:00
rdtscp.h Run clang-format on most sources 2023-04-27 05:44:32 -07:00
rldecode.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
runlevel.c Fix some behavioral issues on Windows 2023-07-09 09:59:22 -07:00
setjmp.S Introduce #include <cosmo.h> to toolchain users 2023-06-09 18:03:05 -07:00
setlongerjmp.S Introduce #include <cosmo.h> to toolchain users 2023-06-09 18:03:05 -07:00
sha.h Make numerous improvements 2021-09-28 01:52:34 -07:00
sha1.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
sha1ni.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
sha256.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
sha256ni.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
sha512.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
siglongjmp.S Make fixes and improvements 2022-10-19 07:19:19 -07:00
stackframe.h Make improvements 2023-09-18 21:04:47 -07:00
threaded.c Hunt down more bugs 2023-07-03 18:43:29 -07:00
tinydivsi.greg.S Clean old .source directive out of asm code 2022-03-18 12:43:21 -07:00
tinywcslen.greg.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
tinywcsnlen.greg.S Get --ftrace working on aarch64 2023-06-05 23:35:31 -07:00
trampoline.h Replace .pushsection directives (#30) 2021-01-10 13:36:31 -08:00
uart.internal.h Add epoll and do more release readiness changes 2020-11-28 12:01:51 -08:00
vendor.internal.h Update tests and CPU detection for Blink 2023-01-18 00:56:09 -08:00
vidya.internal.h Get Cosmopolitan into releasable state 2020-11-25 08:19:00 -08:00
x86compiler.h Initial import 2020-06-15 07:18:57 -07:00
x86feature.h Make progress towards aarch64 build 2023-05-10 04:20:46 -07:00
x86info.h Add SSL to redbean 2021-06-24 13:20:50 -07:00
x87conf.inc Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
xmm.S Make fixes and improvements 2023-07-09 05:21:11 -07:00
zip.S Rewrite .zip.o file linker 2023-06-10 09:29:44 -07:00