zephyr/lib/posix
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
..
getopt
_common.c arch: remove wait_q.h include 2023-09-12 12:55:36 -04:00
barrier.c posix: Implement pthread_barrieratter functions 2023-07-09 10:40:57 -04:00
clock.c syscall: rename Z_OOPS -> K_OOPS 2023-11-03 11:46:52 +01:00
CMakeLists.txt posix: ensure that pooled ipc type is user-configurable 2023-10-13 11:13:07 -04:00
cond.c posix: logging: use log module register instead of declare 2023-09-19 16:11:58 +01:00
eventfd.c posix: eventfd: remove redundant conditional 2023-07-21 06:33:19 -04:00
fnmatch.c
fs.c posix: fs: Fixes stat command to return file information 2023-06-23 17:04:34 -04:00
Kconfig hostap: Move the relevant config options away from hostap 2023-10-26 09:48:47 +02:00
Kconfig.barrier posix: split supported features into separate Kconfig files 2023-07-06 11:47:07 -04:00
Kconfig.clock lib/posix clock: Add missing kconfig dependency 2023-10-25 09:58:07 +02:00
Kconfig.cond posix: split supported features into separate Kconfig files 2023-07-06 11:47:07 -04:00
Kconfig.eventfd lib: os: build fdtable conditionally 2023-09-28 06:25:16 -04:00
Kconfig.fnmatch posix: split supported features into separate Kconfig files 2023-07-06 11:47:07 -04:00
Kconfig.fs lib: os: build fdtable conditionally 2023-09-28 06:25:16 -04:00
Kconfig.getopt posix: split supported features into separate Kconfig files 2023-07-06 11:47:07 -04:00
Kconfig.key posix: split supported features into separate Kconfig files 2023-07-06 11:47:07 -04:00
Kconfig.limits posix: signal: check RTSIG limit 2023-07-18 15:35:42 -04:00
Kconfig.mqueue posix: split supported features into separate Kconfig files 2023-07-06 11:47:07 -04:00
Kconfig.mutex posix: split supported features into separate Kconfig files 2023-07-06 11:47:07 -04:00
Kconfig.pthread pthread: facilitate dynamically allocated thread stacks 2023-07-24 12:59:43 -04:00
Kconfig.semaphore posix: split supported features into separate Kconfig files 2023-07-06 11:47:07 -04:00
Kconfig.signal posix: pthread: implement pthread_sigmask() 2023-12-04 20:49:35 -05:00
Kconfig.spinlock posix: split supported features into separate Kconfig files 2023-07-06 11:47:07 -04:00
Kconfig.template.pooled_ipc_type posix: ensure that pooled ipc type is user-configurable 2023-10-13 11:13:07 -04:00
Kconfig.template.pooled_type posix: add logging to pooled resource templates 2023-09-19 06:16:10 -04:00
Kconfig.template.with_logging posix: add logging to pooled resource templates 2023-09-19 06:16:10 -04:00
Kconfig.template.with_url posix: split supported features into separate Kconfig files 2023-07-06 11:47:07 -04:00
Kconfig.timer posix: implement timer_getoverrun() 2023-07-10 09:30:33 +02:00
Kconfig.uname posix: implement uname 2023-07-09 16:57:16 -04:00
key.c posix: pthread_once: simplify and reduce size of pthread_once_t 2023-12-14 09:32:58 +01:00
mqueue.c
mutex.c lib: posix: mutex: to_posix_mutex should be spinlocked 2023-10-03 22:30:38 -04:00
nanosleep.c posix: implement clock_nanosleep 2023-08-30 13:02:58 -07:00
perror.c
posix_internal.h posix: pthread: implement pthread_sigmask() 2023-12-04 20:49:35 -05:00
pthread_sched.h
pthread.c posix: pthread_once: simplify and reduce size of pthread_once_t 2023-12-14 09:32:58 +01:00
rwlock.c lib: posix: pthread_rwlock: Fix a racy issue 2023-07-12 09:25:26 +02:00
sched.c posix: rename some files for brevity 2023-07-06 11:47:07 -04:00
semaphore.c
signal.c posix: signal: extend strsignal buf to cover entire INT range 2023-08-04 15:54:18 -04:00
sleep.c
spinlock.c posix: spinlock: additional kconfig for k_spinlock being size 0 2023-07-06 16:45:26 +00:00
timer.c timer: add support for sigev_thread flag in zephyr timer posix api 2023-10-20 14:52:07 +02:00
uname.c posix: implement uname 2023-07-09 16:57:16 -04:00