1 # getrandom.m4 serial 8
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 uClibc
23 #include <sys/types.h>
25 #include <sys/random.h>
26 ssize_t getrandom (void *, size_t, unsigned int);
30 [gl_cv_func_getrandom_ok=yes],
31 [gl_cv_func_getrandom_ok=no])
33 if test $gl_cv_func_getrandom_ok = no; then
40 AC_CHECK_HEADERS([bcrypt.h], [], [],
41 [[#include <windows.h>
43 AC_CACHE_CHECK([whether the bcrypt library is guaranteed to be present],
44 [gl_cv_lib_assume_bcrypt],
47 [[#include <windows.h>]],
48 [[#if !(_WIN32_WINNT >= _WIN32_WINNT_WIN7)
53 [gl_cv_lib_assume_bcrypt=yes],
54 [gl_cv_lib_assume_bcrypt=no])
56 if test $gl_cv_lib_assume_bcrypt = yes; then
57 AC_DEFINE([HAVE_LIB_BCRYPT], [1],
58 [Define to 1 if the bcrypt library is guaranteed to be present.])
59 LIB_GETRANDOM='-lbcrypt'
61 LIB_GETRANDOM='-ladvapi32'
67 AC_SUBST([LIB_GETRANDOM])