zephyr/lib/libc
Christopher Friedt 04c9903055 posix: pthread_once: simplify and reduce size of pthread_once_t
Since pthread_once() is both the initializer and executor of
pthread_once_t, it can have maximally two states. Since the
implementation in Zephyr previously aimed to maximize libc
compatibility, we opted to use the definition of pthread_once_t
from newlib, which is a structure with two ints.

It does not make sense to use 64 bits to manage 2 possible
states. The control for that should effectively be a bool.

We maintain compatibility with newlib by asserting (at build
time), that newlib's pthread_once_t is larger than Zephyr's
new struct pthread_once (which just contains a bool).

This allows us to delete the non-standard pthread_key.h
header file (finally).

Reuse the pthread_pool_lock in order to synchronize the related
init function (so that it is only called maximally once from any
thread). The spinlock is only used to test the state and the
init function is not called with the spinlock held.

The alternative was to use an atomic inside of
struct pthread_once. But again, that could be up to 64-bits with
Zephyr's atomics implementation.

Ideally we would use C11 generics or something to support atomics
on 8, 16, 32, and 64-bit primitives.

Lastly, also update declarations for C11 threads as they mostly
mirror our pthread implementation.

This needed to be done as a single commit in order to ensure
continuity of build.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-12-14 09:32:58 +01:00
..
arcmwdt syscall: rename Z_OOPS -> K_OOPS 2023-11-03 11:46:52 +01:00
armstdc
common posix: pthread_once: simplify and reduce size of pthread_once_t 2023-12-14 09:32:58 +01:00
minimal lib: libc: minimal: proper cast to "(char *)" from "(const char *)" 2023-12-13 20:12:45 +01:00
newlib kernel: mm: move kernel mm functions under kernel includes 2023-11-20 09:19:14 +01:00
picolibc libc/picolibc: Support 'long long' and 'minimal' printf variants 2023-11-20 06:07:58 -05:00
CMakeLists.txt
Kconfig libc/picolibc: Support 'long long' and 'minimal' printf variants 2023-11-20 06:07:58 -05:00