summaryrefslogtreecommitdiffstats
path: root/lib/librthread/rthread_libc.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2015-04-07 01:27:06 +0000
committerguenther <guenther@openbsd.org>2015-04-07 01:27:06 +0000
commit514a545f8a3983d53b7de4e8dfcefe16c9496776 (patch)
treee17cf0966466dfd49a1decf34dd536d3fdbe4765 /lib/librthread/rthread_libc.c
parentDo not mistreat empty arguments to font alternating macros (diff)
downloadwireguard-openbsd-514a545f8a3983d53b7de4e8dfcefe16c9496776.tar.xz
wireguard-openbsd-514a545f8a3983d53b7de4e8dfcefe16c9496776.zip
Make pthread_atfork() track the DSO that called it like atexit() does,
unregistering callbacks if the DSO is unloaded. Move the callback handling from libpthread to libc, though libpthread still overrides the inner call to handle locking and thread-library reinitialization. Major version bump for both libc and libpthread. verification that this fixes various ports ajacoutot@ asm assistance miod@; ok millert@ deraadt@
Diffstat (limited to 'lib/librthread/rthread_libc.c')
-rw-r--r--lib/librthread/rthread_libc.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/librthread/rthread_libc.c b/lib/librthread/rthread_libc.c
index 13df27c498e..018368a84dd 100644
--- a/lib/librthread/rthread_libc.c
+++ b/lib/librthread/rthread_libc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_libc.c,v 1.11 2013/06/01 20:47:40 tedu Exp $ */
+/* $OpenBSD: rthread_libc.c,v 1.12 2015/04/07 01:27:07 guenther Exp $ */
/* $snafu: libc_tag.c,v 1.4 2004/11/30 07:00:06 marc Exp $ */
/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
@@ -184,6 +184,23 @@ _thread_atexit_unlock(void)
}
/*
+ * atfork lock
+ */
+static struct _spinlock atfork_lock = _SPINLOCK_UNLOCKED;
+
+void
+_thread_atfork_lock(void)
+{
+ _spinlock(&atfork_lock);
+}
+
+void
+_thread_atfork_unlock(void)
+{
+ _spinunlock(&atfork_lock);
+}
+
+/*
* arc4random lock
*/
static struct _spinlock arc4_lock = _SPINLOCK_UNLOCKED;