cosmopolitan/third_party/nsync
Justine Tunney 957c61cbbf
Release Cosmopolitan v3.3
This change upgrades to GCC 12.3 and GNU binutils 2.42. The GNU linker
appears to have changed things so that only a single de-duplicated str
table is present in the binary, and it gets placed wherever the linker
wants, regardless of what the linker script says. To cope with that we
need to stop using .ident to embed licenses. As such, this change does
significant work to revamp how third party licenses are defined in the
codebase, using `.section .notice,"aR",@progbits`.

This new GCC 12.3 toolchain has support for GNU indirect functions. It
lets us support __target_clones__ for the first time. This is used for
optimizing the performance of libc string functions such as strlen and
friends so far on x86, by ensuring AVX systems favor a second codepath
that uses VEX encoding. It shaves some latency off certain operations.
It's a useful feature to have for scientific computing for the reasons
explained by the test/libcxx/openmp_test.cc example which compiles for
fifteen different microarchitectures. Thanks to the upgrades, it's now
also possible to use newer instruction sets, such as AVX512FP16, VNNI.

Cosmo now uses the %gs register on x86 by default for TLS. Doing it is
helpful for any program that links `cosmo_dlopen()`. Such programs had
to recompile their binaries at startup to change the TLS instructions.
That's not great, since it means every page in the executable needs to
be faulted. The work of rewriting TLS-related x86 opcodes, is moved to
fixupobj.com instead. This is great news for MacOS x86 users, since we
previously needed to morph the binary every time for that platform but
now that's no longer necessary. The only platforms where we need fixup
of TLS x86 opcodes at runtime are now Windows, OpenBSD, and NetBSD. On
Windows we morph TLS to point deeper into the TIB, based on a TlsAlloc
assignment, and on OpenBSD/NetBSD we morph %gs back into %fs since the
kernels do not allow us to specify a value for the %gs register.

OpenBSD users are now required to use APE Loader to run Cosmo binaries
and assimilation is no longer possible. OpenBSD kernel needs to change
to allow programs to specify a value for the %gs register, or it needs
to stop marking executable pages loaded by the kernel as mimmutable().

This release fixes __constructor__, .ctor, .init_array, and lastly the
.preinit_array so they behave the exact same way as glibc.

We no longer use hex constants to define math.h symbols like M_PI.
2024-02-20 13:27:59 -08:00
..
mem Release Cosmopolitan v3.3 2024-02-20 13:27:59 -08:00
testing more modeline errata (#1019) 2023-12-16 23:07:10 -05:00
array.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
atomic.h Reduce header complexity 2023-11-28 14:39:42 -08:00
atomic.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
BUILD.mk more modeline errata (#1019) 2023-12-16 23:07:10 -05:00
common.c Release Cosmopolitan v3.3 2024-02-20 13:27:59 -08:00
common.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
compat.S Fix more vi modelines (#1006) 2023-12-13 02:28:11 -05:00
counter.h Reduce header complexity 2023-11-28 14:39:42 -08:00
cv.h Reduce header complexity 2023-11-28 14:39:42 -08:00
debug.h Reduce header complexity 2023-11-28 14:39:42 -08:00
futex.c Make improvements 2024-02-12 10:23:00 -08:00
futex.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
heap.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
LICENSE.txt Use *NSYNC for POSIX threads locking APIs 2022-09-11 11:04:50 -07:00
mu.c Release Cosmopolitan v3.3 2024-02-20 13:27:59 -08:00
mu.h Reduce header complexity 2023-11-28 14:39:42 -08:00
mu_semaphore.c Release Cosmopolitan v3.3 2024-02-20 13:27:59 -08:00
mu_semaphore.h Reduce header complexity 2023-11-28 14:39:42 -08:00
mu_semaphore.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
mu_semaphore_futex.c Fix more vi modelines (#1006) 2023-12-13 02:28:11 -05:00
mu_semaphore_gcd.c Fix more vi modelines (#1006) 2023-12-13 02:28:11 -05:00
mu_semaphore_sem.c Fix more vi modelines (#1006) 2023-12-13 02:28:11 -05:00
mu_wait.h Reduce header complexity 2023-11-28 14:39:42 -08:00
note.h Reduce header complexity 2023-11-28 14:39:42 -08:00
notice.c Release Cosmopolitan v3.3 2024-02-20 13:27:59 -08:00
once.h Reduce header complexity 2023-11-28 14:39:42 -08:00
panic.c Fix more vi modelines (#1006) 2023-12-13 02:28:11 -05:00
races.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
README.cosmo Fix nsync_mu_unlock_slow_() on Apple Silicon 2023-11-13 11:07:13 -08:00
time.h Reduce header complexity 2023-11-28 14:39:42 -08:00
wait_s.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
waiter.h Reduce header complexity 2023-11-28 14:39:42 -08:00
yield.c Make improvements 2024-02-12 10:23:00 -08:00

DESCRIPTION

  *NSYNC is a synchronization primitives library.

LICENSE

  Apache 2.0

ORIGIN

  git@github.com:google/nsync
  commit ac5489682760393fe21bd2a8e038b528442412a7
  Author: Mike Burrows <m3b@google.com>
  Date:   Wed Jun 1 16:47:52 2022 -0700

LOCAL CHANGES

  - Fix nsync_mu_unlock() on Apple Silicon

  - Time APIs were so good that they're now in libc

  - Double linked list API was so good that it's now in libc

  - Support Apple's ulock futexes which are internal but nicer than GCD

  - Ensure resources such as POSIX semaphores are are released on fork.

  - Modified *NSYNC to allocate waiter objects on the stack. We need it
    because we use *NSYNC mutexes to implement POSIX mutexes, which are
    too low-level to safely depend on malloc, or even mmap in our case.

  - Rewrote most of the semaphore and futex system call support code so
    it works well with Cosmopolitan's fat runtime portability. *NSYNC's
    unit test suite passes on all supported platforms. However the BSDs
    currently appear to be overutilizing CPU time compared with others.
    This appears to be the fault of the OSes rather than *NSYNC / Cosmo

  - Support POSIX thread cancellation. APIs that wait on condition vars
    are now cancellation points. In PTHREAD_CANCEL_MASKED mode they may
    return ECANCELED. In PTHREAD_CANCEL_DEFERRED mode the POSIX threads
    library will unwind the stack to re-acquire locks and free waiters.
    On the other hand the *NSYNC APIs for mutexes will now safely block
    thread cancellation, but you can still use *NSYNC notes to do that.