diff options
author | 2005-12-06 06:19:31 +0000 | |
---|---|---|
committer | 2005-12-06 06:19:31 +0000 | |
commit | 3636e78590bdd31b1b4bc89c52e56a5598464356 (patch) | |
tree | 8fcf442838ba85f861bef65c7dabaf3fcfb98ddf | |
parent | can't build shared lib without shlib_version (diff) | |
download | wireguard-openbsd-3636e78590bdd31b1b4bc89c52e56a5598464356.tar.xz wireguard-openbsd-3636e78590bdd31b1b4bc89c52e56a5598464356.zip |
add pthread_once. unfortunately, the public pthread.h header
defines the pthread_once_t internals, so we're stuck with them.
-rw-r--r-- | lib/librthread/rthread_sync.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/librthread/rthread_sync.c b/lib/librthread/rthread_sync.c index a2d7faf01cd..262983a926d 100644 --- a/lib/librthread/rthread_sync.c +++ b/lib/librthread/rthread_sync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread_sync.c,v 1.1 2005/12/03 18:16:19 tedu Exp $ */ +/* $OpenBSD: rthread_sync.c,v 1.2 2005/12/06 06:19:31 tedu Exp $ */ /* * Copyright (c) 2004 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -475,3 +475,16 @@ pthread_rwlockattr_destory(pthread_rwlockattr_t *attrp) return (0); } + +int +pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) +{ + pthread_mutex_lock(&once_control->mutex); + if (once_control->state == PTHREAD_NEEDS_INIT) { + init_routine(); + once_control->state = PTHREAD_DONE_INIT; + } + pthread_mutex_unlock(&once_control->mutex); + + return (0); +} |