diff options
author | 2008-01-01 00:43:39 +0000 | |
---|---|---|
committer | 2008-01-01 00:43:39 +0000 | |
commit | 229f4f6ee4c7ecffe38220a1baa321e3465d69d6 (patch) | |
tree | 8958250da2db5f655350d351427431e7df1af2e8 /lib/libpthread/thread/thread_malloc_lock.c | |
parent | fix name (diff) | |
download | wireguard-openbsd-229f4f6ee4c7ecffe38220a1baa321e3465d69d6.tar.xz wireguard-openbsd-229f4f6ee4c7ecffe38220a1baa321e3465d69d6.zip |
- 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/libpthread/thread/thread_malloc_lock.c')
-rw-r--r-- | lib/libpthread/thread/thread_malloc_lock.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/libpthread/thread/thread_malloc_lock.c b/lib/libpthread/thread/thread_malloc_lock.c index 6e8b96bb656..6deebb53f66 100644 --- a/lib/libpthread/thread/thread_malloc_lock.c +++ b/lib/libpthread/thread/thread_malloc_lock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: thread_malloc_lock.c,v 1.5 2006/02/22 07:16:32 otto Exp $ */ +/* $OpenBSD: thread_malloc_lock.c,v 1.6 2008/01/01 00:43:39 kurt Exp $ */ /* Public Domain <marc@snafu.org> */ #include <pthread.h> @@ -6,6 +6,7 @@ static spinlock_t malloc_lock = _SPINLOCK_INITIALIZER; static spinlock_t atexit_lock = _SPINLOCK_INITIALIZER; +static spinlock_t arc4_lock = _SPINLOCK_INITIALIZER; void _thread_malloc_lock() @@ -35,3 +36,15 @@ _thread_atexit_unlock() { _SPINUNLOCK(&atexit_lock); } + +void +_thread_arc4_lock() +{ + _SPINLOCK(&arc4_lock); +} + +void +_thread_arc4_unlock() +{ + _SPINUNLOCK(&arc4_lock); +} |