HomeFreeBSD

libc: Rewrite quick_exit() and at_quick_exit() using C11 atomics.

Description

libc: Rewrite quick_exit() and at_quick_exit() using C11 atomics.

Compiler memory barriers do not prevent the CPU from executing the code
out of order. Switch to C11 atomics. This also lets us get rid of the
mutex; instead, loop until the compare_exchange succeeds.

While here, change the return value of at_quick_exit() on failure to
the more traditional -1, matching atexit().

Sponsored by: Klara, Inc.
Reviewed by: Olivier Certner, kevans, kib
Differential Revision: https://reviews.freebsd.org/D41936

(cherry picked from commit 1dc3abb052430279e47c8922d22b30922adcf0f6)

libc: Add a rudimentary test for quick_exit(3).

Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D41937

(cherry picked from commit c7dd4601aeebbc1bbe131cbe6747476c124b47fe)

Details

Provenance
desAuthored on Sep 26 2023, 8:06 PM
Reviewer
olivier
Differential Revision
D41936: libc: Rewrite quick_exit() and at_quick_exit() using C11 atomics.
Parents
rGa3e10c2b1418: LinuxKPI: 802.11: fill regulatory_hint() with some life
Branches
Unknown
Tags
Unknown