diff options
author | Kurt Miller <kurt@cvs.openbsd.org> | 2008-01-01 00:43:40 +0000 |
---|---|---|
committer | Kurt Miller <kurt@cvs.openbsd.org> | 2008-01-01 00:43:40 +0000 |
commit | 0c67ab8bf7edbef019be3f16d6fecf3415f936b8 (patch) | |
tree | 0962e1797400e9c942f430c5e9f445d72fb5452b /lib/libpthread | |
parent | a2bf00b0dbd8e50cb2c798d07003e3a20aa2d32c (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/libpthread')
-rw-r--r-- | lib/libpthread/shlib_version | 2 | ||||
-rw-r--r-- | lib/libpthread/thread/thread_malloc_lock.c | 15 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_init.c | 4 |
3 files changed, 18 insertions, 3 deletions
diff --git a/lib/libpthread/shlib_version b/lib/libpthread/shlib_version index d0f0988b418..00604e64e7d 100644 --- a/lib/libpthread/shlib_version +++ b/lib/libpthread/shlib_version @@ -1,2 +1,2 @@ major=8 -minor=0 +minor=1 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); +} diff --git a/lib/libpthread/uthread/uthread_init.c b/lib/libpthread/uthread/uthread_init.c index d48e1173566..36559a5ae34 100644 --- a/lib/libpthread/uthread/uthread_init.c +++ b/lib/libpthread/uthread/uthread_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_init.c,v 1.40 2007/07/20 22:34:40 kettenis Exp $ */ +/* $OpenBSD: uthread_init.c,v 1.41 2008/01/01 00:43:39 kurt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -135,6 +135,8 @@ static void *references[] = { &_thread_malloc_unlock, &_thread_atexit_lock, &_thread_atexit_unlock, + &_thread_arc4_lock, + &_thread_arc4_unlock, &_thread_tag_lock, &_thread_tag_unlock, &_thread_tag_storage, |