Arc4random locking: Check for threaded application on Cygwin

libc/stdlib/arc4random.h (_ARC4_LOCK): Special case Cygwin.
        (_ARC4_UNLOCK): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2016-03-18 14:40:26 +01:00
parent 5ccdcf0219
commit 7c96d6059c
1 changed files with 19 additions and 0 deletions

View File

@ -39,10 +39,29 @@
__LOCK_INIT(static, _arc4random_mutex); __LOCK_INIT(static, _arc4random_mutex);
#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() __lock_acquire(_arc4random_mutex) #define _ARC4_LOCK() __lock_acquire(_arc4random_mutex)
#define _ARC4_UNLOCK() __lock_release(_arc4random_mutex) #define _ARC4_UNLOCK() __lock_release(_arc4random_mutex)
#endif
#ifdef _ARC4RANDOM_DATA #ifdef _ARC4RANDOM_DATA
_ARC4RANDOM_DATA _ARC4RANDOM_DATA
#else #else