This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] Define RtlGenRandom correctly in ntsecapi.h wrapper
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 14 Dec 2016 13:14:38 -0000
- Subject: [newlib-cygwin] Define RtlGenRandom correctly in ntsecapi.h wrapper
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=86fc4bf065d2f71c955ba2356b5b442fec596014
commit 86fc4bf065d2f71c955ba2356b5b442fec596014
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Wed Dec 14 14:14:28 2016 +0100
Define RtlGenRandom correctly in ntsecapi.h wrapper
Include ntsecapi.h where required and just redefine RtlGenRandom
correctly in the ntsecapi.h wrapper.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/fhandler_random.cc | 1 +
winsup/cygwin/fhandler_socket.cc | 1 +
winsup/cygwin/miscfuncs.cc | 1 +
winsup/cygwin/ntdll.h | 6 ------
winsup/cygwin/ntsecapi.h | 26 ++++++++++++++++++++++++++
5 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/winsup/cygwin/fhandler_random.cc b/winsup/cygwin/fhandler_random.cc
index c56ce73..1a3edd1 100644
--- a/winsup/cygwin/fhandler_random.cc
+++ b/winsup/cygwin/fhandler_random.cc
@@ -7,6 +7,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
+#include <ntsecapi.h>
#include <unistd.h>
#include <sys/param.h>
#include "cygerrno.h"
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 801a731..f3d1d69 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -21,6 +21,7 @@
#undef u_long
#define u_long __ms_u_long
#endif
+#include <ntsecapi.h>
#include <ws2tcpip.h>
#include <mswsock.h>
#include <iphlpapi.h>
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index 0b19b28..e92ccba 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -8,6 +8,7 @@ details. */
#include "winsup.h"
#include "miscfuncs.h"
+#include <ntsecapi.h>
#include <sys/uio.h>
#include <assert.h>
#include <alloca.h>
diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h
index bf5a7cf..448eadf 100644
--- a/winsup/cygwin/ntdll.h
+++ b/winsup/cygwin/ntdll.h
@@ -1608,10 +1608,4 @@ extern "C"
}
}
-
-/* There's a bug in ntsecapi.h (Mingw as well as MSFT). SystemFunction036
- is, in fact, a WINAPI function, but it's not defined as such. Therefore
- we have to do it correctly here. *Strictly*, this is not ntdll... */
-#define RtlGenRandom SystemFunction036
-extern "C" BOOLEAN WINAPI RtlGenRandom (PVOID, ULONG);
#endif
diff --git a/winsup/cygwin/ntsecapi.h b/winsup/cygwin/ntsecapi.h
new file mode 100644
index 0000000..8b0a7e7
--- /dev/null
+++ b/winsup/cygwin/ntsecapi.h
@@ -0,0 +1,26 @@
+#ifndef _CYGWIN_NTSECAPI_H
+#define _CYGWIN_NTSECAPI_H
+
+/* There's a bug in ntsecapi.h (Mingw as well as MSFT). SystemFunction036
+ is, in fact, a WINAPI function, but it's not defined as such. Therefore
+ we have to do it correctly here in the ntsecapi.h wrapper. */
+
+#define SystemFunction036 __nonexistant_SystemFunction036__
+
+#include_next <ntsecapi.h>
+
+#undef SystemFunction036
+
+#define RtlGenRandom SystemFunction036
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+BOOLEAN WINAPI RtlGenRandom (PVOID, ULONG);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _CYGWIN_NTSECAPI_H */