From f7f26f65ab61fe39fe57a9ae38029c4d0cd10653 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 18 Mar 2016 18:01:07 +0100 Subject: Allow machine-dependent arc4 locking newlib: * libc/stdlib/arc4random.h: Remove Cygwin-specific locking code. Conditionalize arc4 locking. Check for _ARC4_LOCK_INIT being undefined to fall back to default implementation. cygwin: * include/machine/_arc4random.h: New file. Signed-off-by: Corinna Vinschen --- newlib/libc/stdlib/arc4random.h | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'newlib/libc/stdlib/arc4random.h') diff --git a/newlib/libc/stdlib/arc4random.h b/newlib/libc/stdlib/arc4random.h index 8bb72f4..54bcbe8 100644 --- a/newlib/libc/stdlib/arc4random.h +++ b/newlib/libc/stdlib/arc4random.h @@ -37,30 +37,17 @@ #include #include -__LOCK_INIT(static, _arc4random_mutex); +#ifndef _ARC4_LOCK_INIT -#ifdef __CYGWIN__ - -extern int __isthreaded; - -#define _ARC4_LOCK() \ - do { \ - if (__isthreaded) \ - __lock_acquire (_arc4random_mutex); \ - } while (0) - -#define _ARC4_UNLOCK() \ - do { \ - if (__isthreaded) \ - __lock_release (_arc4random_mutex); \ - } while (0) -#else +#define _ARC4_LOCK_INIT __LOCK_INIT(static, _arc4random_mutex); #define _ARC4_LOCK() __lock_acquire(_arc4random_mutex) #define _ARC4_UNLOCK() __lock_release(_arc4random_mutex) -#endif +#endif /* _ARC4_LOCK_INIT */ + +_ARC4_LOCK_INIT #ifdef _ARC4RANDOM_DATA _ARC4RANDOM_DATA -- cgit v1.1