04c9903055
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> |
||
---|---|---|
.. | ||
arcmwdt | ||
armstdc | ||
common | ||
minimal | ||
newlib | ||
picolibc | ||
CMakeLists.txt | ||
Kconfig |