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 20:01:07 +0300
committerCorinna Vinschen <corinna@vinschen.de>2016-03-20 23:30:08 +0300
commitf7f26f65ab61fe39fe57a9ae38029c4d0cd10653 (patch)
treee45bcb5598120bd6952afca293d51180ef5f064a
parent472d0a228c56bd4783ebb0561667cda2de3cd168 (diff)
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 <corinna@vinschen.de>
-rw-r--r--newlib/libc/stdlib/arc4random.h23
-rw-r--r--winsup/cygwin/include/machine/_arc4random.h30
2 files changed, 35 insertions, 18 deletions
diff --git a/newlib/libc/stdlib/arc4random.h b/newlib/libc/stdlib/arc4random.h
index 8bb72f40e..54bcbe8ae 100644
--- a/newlib/libc/stdlib/arc4random.h
+++ b/newlib/libc/stdlib/arc4random.h
@@ -37,30 +37,17 @@
#include <sys/lock.h>
#include <signal.h>
-__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
diff --git a/winsup/cygwin/include/machine/_arc4random.h b/winsup/cygwin/include/machine/_arc4random.h
new file mode 100644
index 000000000..3ce245809
--- /dev/null
+++ b/winsup/cygwin/include/machine/_arc4random.h
@@ -0,0 +1,30 @@
+/* machine/_arc4random.h
+
+ Copyright 2016 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifndef _MACHINE_ARC4RANDOM_H
+#define _MACHINE_ARC4RANDOM_H
+
+extern int __isthreaded;
+
+#define _ARC4_LOCK_INIT __LOCK_INIT(static, _arc4random_mutex);
+
+#define _ARC4_LOCK() \
+ do { \
+ if (__isthreaded) \
+ __lock_acquire (_arc4random_mutex); \
+ } while (0)
+
+#define _ARC4_UNLOCK() \
+ do { \
+ if (__isthreaded) \
+ __lock_release (_arc4random_mutex); \
+ } while (0)
+
+#endif /* _MACHINE_ARC4RANDOM_H */