stdopen: Fix compilation error with IRIX cc.
[gnulib.git] / m4 / random.m4
blob996c406bbba6023384442558ee2fe1a07588a4bf
1 # random.m4 serial 3
2 dnl Copyright (C) 2012-2019 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],
14     [AC_LINK_IFELSE(
15        [AC_LANG_PROGRAM(
16           [[#include <stdlib.h>]],
17           [[return random() == 0;]])
18        ],
19        [gl_cv_func_random=yes],
20        [gl_cv_func_random=no])
21     ])
22   if test $gl_cv_func_random = no; then
23     HAVE_RANDOM=0
24   fi
26   AC_CHECK_DECLS_ONCE([initstate])
27   if test $ac_cv_have_decl_initstate = no; then
28     HAVE_DECL_INITSTATE=0
29   fi
31   AC_CHECK_DECLS_ONCE([setstate])
32   if test $ac_cv_have_decl_setstate = no; then
33     HAVE_DECL_SETSTATE=0
34   fi
37 # Prerequisites of lib/random.c.
38 AC_DEFUN([gl_PREREQ_RANDOM], [
39   :