+2020-06-28 Bruno Haible <bruno@clisp.org>
+
+ 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.
+
2020-06-28 Bruno Haible <bruno@clisp.org>
clean-temp: Fix wrong errno in error message.
#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
-# getrandom.m4 serial 5
+# getrandom.m4 serial 6
dnl Copyright 2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
case "$host_os" in
mingw*)
+ AC_CHECK_HEADERS([bcrypt.h])
AC_CACHE_CHECK([whether the bcrypt library is guaranteed to be present],
[gl_cv_lib_assume_bcrypt],
[AC_COMPILE_IFELSE(