summaryrefslogtreecommitdiff
path: root/lib/librthread/rthread_libc.c
diff options
context:
space:
mode:
authorKurt Miller <kurt@cvs.openbsd.org>2008-01-01 00:43:40 +0000
committerKurt Miller <kurt@cvs.openbsd.org>2008-01-01 00:43:40 +0000
commit0c67ab8bf7edbef019be3f16d6fecf3415f936b8 (patch)
tree0962e1797400e9c942f430c5e9f445d72fb5452b /lib/librthread/rthread_libc.c
parenta2bf00b0dbd8e50cb2c798d07003e3a20aa2d32c (diff)
- make arc4random*() functions thread safe. Use a custom spinlock function
instead of the generic pthread macros since free(3) uses __arc4_getbyte() when freeing small sized allocations and the generic pthread macros call malloc(3). - eliminate passing pointers to a static variable with global scope (rs) for additional code clarity and reduction. - shlib minor bumps for libc and libpthread due to new functions. From andreas@ with some bits from me. okay tedu@ marc@ w/some spot checking from millert@
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 bf3c057d874..da0d92f8da5 100644
--- a/lib/librthread/rthread_libc.c
+++ b/lib/librthread/rthread_libc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_libc.c,v 1.4 2007/06/05 18:11:49 kurt Exp $ */
+/* $OpenBSD: rthread_libc.c,v 1.5 2008/01/01 00:43:39 kurt 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> */
@@ -175,6 +175,23 @@ _thread_malloc_init(void)
{
}
+/*
+ * arc4random lock
+ */
+static _spinlock_lock_t arc4_lock = _SPINLOCK_UNLOCKED;
+
+void
+_thread_arc4_lock(void)
+{
+ _spinlock(&arc4_lock);
+}
+
+void
+_thread_arc4_unlock(void)
+{
+ _spinunlock(&arc4_lock);
+}
+
#if 0
/*
* miscellaneous libc exported symbols we want to override