sys_random_h.m4 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # sys_random_h.m4 serial 5
  2. dnl Copyright (C) 2020-2021 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.
  6. AC_DEFUN([gl_HEADER_SYS_RANDOM],
  7. [
  8. AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS])
  9. dnl <sys/random.h> is always overridden, because of GNULIB_POSIXCHECK.
  10. gl_CHECK_NEXT_HEADERS([sys/random.h])
  11. if test $ac_cv_header_sys_random_h = yes; then
  12. HAVE_SYS_RANDOM_H=1
  13. else
  14. HAVE_SYS_RANDOM_H=0
  15. fi
  16. AC_SUBST([HAVE_SYS_RANDOM_H])
  17. m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])])
  18. if test $ac_cv_header_sys_random_h = yes; then
  19. UNISTD_H_HAVE_SYS_RANDOM_H=1
  20. fi
  21. dnl Check for declarations of anything we want to poison if the
  22. dnl corresponding gnulib module is not in use.
  23. gl_WARN_ON_USE_PREPARE([[
  24. #if HAVE_SYS_RANDOM_H
  25. /* Additional includes are needed before <sys/random.h> on uClibc
  26. and Mac OS X. */
  27. # include <sys/types.h>
  28. # include <stdlib.h>
  29. # include <sys/random.h>
  30. #endif
  31. ]],
  32. [getrandom])
  33. ])
  34. AC_DEFUN([gl_SYS_RANDOM_MODULE_INDICATOR],
  35. [
  36. dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
  37. AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS])
  38. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  39. dnl Define it also as a C macro, for the benefit of the unit tests.
  40. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  41. ])
  42. AC_DEFUN([gl_SYS_RANDOM_H_DEFAULTS],
  43. [
  44. GNULIB_GETRANDOM=0; AC_SUBST([GNULIB_GETRANDOM])
  45. dnl Assume proper GNU behavior unless another module says otherwise.
  46. HAVE_GETRANDOM=1; AC_SUBST([HAVE_GETRANDOM])
  47. REPLACE_GETRANDOM=0; AC_SUBST([REPLACE_GETRANDOM])
  48. ])