From d08c4e4910d78ef0ddd9e7917c1f2d61b0021d4a Mon Sep 17 00:00:00 2001 From: kurt <> Date: Tue, 1 Jan 2008 00:43:39 +0000 Subject: - 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@ --- src/lib/libc/include/thread_private.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/lib/libc/include') diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h index 146f0b0a01..f55880f7ba 100644 --- a/src/lib/libc/include/thread_private.h +++ b/src/lib/libc/include/thread_private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: thread_private.h,v 1.21 2007/11/19 02:54:19 kurt Exp $ */ +/* $OpenBSD: thread_private.h,v 1.22 2008/01/01 00:43:39 kurt Exp $ */ /* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman */ @@ -150,4 +150,16 @@ void _thread_atexit_unlock(void); _thread_atexit_unlock();\ } while (0) +void _thread_arc4_lock(void); +void _thread_arc4_unlock(void); + +#define _ARC4_LOCK() do { \ + if (__isthreaded) \ + _thread_arc4_lock(); \ + } while (0) +#define _ARC4_UNLOCK() do { \ + if (__isthreaded) \ + _thread_arc4_unlock();\ + } while (0) + #endif /* _THREAD_PRIVATE_H_ */ -- cgit v1.2.3-55-g6feb