1 # getrandom.m4 serial 6
2 dnl Copyright 2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 dnl Written by Paul Eggert.
9 AC_DEFUN([gl_FUNC_GETRANDOM],
11 AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS])
12 AC_CHECK_FUNCS_ONCE([getrandom])
13 if test "$ac_cv_func_getrandom" != yes; then
16 dnl On Solaris 11.4 the return type is 'int', not 'ssize_t'.
17 AC_CACHE_CHECK([whether getrandom is compatible with its GNU+BSD signature],
18 [gl_cv_func_getrandom_ok],
21 [[/* Additional includes are needed before <sys/random.h> on Mac OS X. */
22 #include <sys/types.h>
24 #include <sys/random.h>
25 ssize_t getrandom (void *, size_t, unsigned int);
29 [gl_cv_func_getrandom_ok=yes],
30 [gl_cv_func_getrandom_ok=no])
32 if test $gl_cv_func_getrandom_ok = no; then
39 AC_CHECK_HEADERS([bcrypt.h])
40 AC_CACHE_CHECK([whether the bcrypt library is guaranteed to be present],
41 [gl_cv_lib_assume_bcrypt],
44 [[#include <windows.h>]],
45 [[#if !(_WIN32_WINNT >= _WIN32_WINNT_WIN7)
50 [gl_cv_lib_assume_bcrypt=yes],
51 [gl_cv_lib_assume_bcrypt=no])
53 if test $gl_cv_lib_assume_bcrypt = yes; then
54 AC_DEFINE([HAVE_LIB_BCRYPT], [1],
55 [Define to 1 if the bcrypt library is guaranteed to be present.])
56 LIB_GETRANDOM='-lbcrypt'
58 LIB_GETRANDOM='-ladvapi32'
64 AC_SUBST([LIB_GETRANDOM])