2 dnl Copyright (C) 2012-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 AC_DEFUN([gl_FUNC_RANDOM],
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
11 dnl We can't use AC_CHECK_FUNC here, because random() is defined as a
12 dnl static inline function when compiling for Android 4.4 or older.
13 AC_CACHE_CHECK([for random], [gl_cv_func_random],
16 [[#include <stdlib.h>]],
17 [[return random() == 0;]])
19 [gl_cv_func_random=yes],
20 [gl_cv_func_random=no])
22 if test $gl_cv_func_random = no; then
27 AC_CHECK_FUNCS([initstate setstate])
28 if test $ac_cv_func_initstate = no; then
31 if test $ac_cv_func_setstate = no; then
34 if test $ac_cv_func_initstate = no || test $ac_cv_func_setstate = no; then
35 dnl In order to define initstate or setstate, we need to define all the
36 dnl functions at once.
38 if test $ac_cv_func_initstate = yes; then
41 if test $ac_cv_func_setstate = yes; then
47 AC_CHECK_DECLS_ONCE([initstate])
48 if test $ac_cv_have_decl_initstate = no; then
52 AC_CHECK_DECLS_ONCE([setstate])
53 if test $ac_cv_have_decl_setstate = no; then
58 # Prerequisites of lib/random.c.
59 AC_DEFUN([gl_PREREQ_RANDOM], [