Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2016-03-18 16:40:26 +0300
committerCorinna Vinschen <corinna@vinschen.de>2016-03-18 16:40:26 +0300
commit7c96d6059c81b15916112ecafbb3a6bcd81a3271 (patch)
tree09dcf5a2c6c776cf9bd63b56328af64ebb417bb5 /newlib/libc
parent5ccdcf02192aa7dad6bf29fe661c0ca666c4d00f (diff)
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>
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/stdlib/arc4random.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/newlib/libc/stdlib/arc4random.h b/newlib/libc/stdlib/arc4random.h
index 938a80b2e..8bb72f40e 100644
--- a/newlib/libc/stdlib/arc4random.h
+++ b/newlib/libc/stdlib/arc4random.h
@@ -39,10 +39,29 @@
__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_UNLOCK() __lock_release(_arc4random_mutex)
+#endif
+
#ifdef _ARC4RANDOM_DATA
_ARC4RANDOM_DATA
#else