diff options
author | Bruno Haible <bruno@clisp.org> | 2020-06-28 19:04:03 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-06-28 19:04:03 +0200 |
commit | 70872213ef6614cf52d5978a5fdf8b9e628fc786 (patch) | |
tree | bf3f6360d542ec1b345851d3503aa696060b5a41 /lib | |
parent | e6856168aaa96cbda1c01add379831eca98130c0 (diff) | |
download | gnulib-70872213ef6614cf52d5978a5fdf8b9e628fc786.tar.gz |
getrandom: Fix compilation errors on older versions of mingw.
Reported by Eli Zaretskii <eliz@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-06/msg00059.html>.
* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Test whether <bcrypt.h> exists.
* lib/getrandom.c: If <bcrypt.h> is not available, include <ntdef.h> and
define/declare BCRYPT_ALG_HANDLE, BCRYPT_USE_SYSTEM_PREFERRED_RNG,
BCryptGenRandom ourselves.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/getrandom.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/getrandom.c b/lib/getrandom.c index f0b3f53500..030a78bb08 100644 --- a/lib/getrandom.c +++ b/lib/getrandom.c @@ -29,7 +29,16 @@ #if defined _WIN32 && ! defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN # include <windows.h> -# include <bcrypt.h> +# if HAVE_BCRYPT_H +# include <bcrypt.h> +# else +# include <ntdef.h> /* NTSTATUS */ +typedef void * BCRYPT_ALG_HANDLE; +# define BCRYPT_USE_SYSTEM_PREFERRED_RNG 0x00000002 +# if HAVE_LIB_BCRYPT +extern NTSTATUS WINAPI BCryptGenRandom (BCRYPT_ALG_HANDLE, UCHAR *, ULONG, ULONG); +# endif +# endif # if !HAVE_LIB_BCRYPT # include <wincrypt.h> # ifndef CRYPT_VERIFY_CONTEXT |