DragonFlyBSD/src 721505dlib/libc/gen _thread_init.c, lib/libc/include libc_private.h

libc - Implement sigblockall() and sigunblockall()

* Signal safety is becoming a defacto requirement for most of libc and
  pthreads.  In particular, the memory allocator.  Given the chances of
  teaching tens of thousands of programmers about signal safety, and
  just making it work in libc and pthreads, only one of these two
  possibilities is actually realizable.

  In particular, high-level languages have become so complex, and some
  applications (chrome, firefox, etc) have become so complex, that the
  code is regularly tripping over signal safety issues.

  However, implementing signal safety with current mechanisms is extremely
  expensive due to the need for multiple system calls.  To whit,
  DragonFlyBSD now has a mechanism that does not require system calls
  in the critical path.

* Implement sigblockall() and sigunblockall().  These functions
  leverage the new /dev/lpmap per-thread shared page mechanism
  to provide a way to temporary block the dispatch of all maskable
  signals without having to make any system calls.

  These are extremely fast routines.

  - Reentrant / Recursable

  - Temporarily blocks any dispatch of a maskable asynchronous signal
    to the calling thread.  Other threads are not affected... this is
    a per-thread mechanism.

  - The last sigunblockall() will immediately dispatch any blocked
    signals.

  - The normal signal mask is not affected by these routines.

  - Does not block signals caused by synchronous traps.

  - The current recursion count is retained on [v]fork() to ease
    coding and to also allow signals to be temporarily blocked across a
    fork until the child process is ready to deal with them, if desired.

* Implement signal safety for most of pthreads.  All temporary internal
  mutexes are now wrapped with sigblockall() and sigunblockall().

* Implement signal safety for the malloc subsystem.  All functions
  are wrawpped with sigblockall() and sigunblockall().

  These implementations make lang/mono and lang/rust far more reliable
  than they were before.  Where 9 out of 10 builds used to fail, now
  they succeed.
DeltaFile
+129-53lib/libc/stdlib/nmalloc.c
+139-15lib/libc/upmap/upmap.c
+100-0lib/libc/upmap/ukp_blocksigs.c
+29-6lib/libthread_xu/thread/thr_private.h
+31-2lib/libc/gen/_thread_init.c
+26-6lib/libthread_xu/thread/thr_umtx.h
+10-9lib/libthread_xu/thread/thr_mutex.c
+15-0lib/libc/include/libc_private.h
+8-0lib/libc/upmap/Symbol.map
+6-1lib/libc/upmap/upmap.h
+3-3lib/libthread_xu/thread/thr_pspinlock.c
+3-3lib/libthread_xu/thread/thr_spinlock.c
+3-1lib/libc/upmap/Makefile.inc
+2-0libexec/rtld-elf/rtld.c
+1-1lib/libc/stdlib/Symbol.map
+2-0lib/libstand/Makefile
+1-1lib/libthread_xu/thread/thr_create.c
+1-0lib/libthread_xu/thread/thr_init.c
+509-10118 files

UnifiedSplitRaw