signal_h.m4 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # signal_h.m4 serial 22
  2. dnl Copyright (C) 2007-2023 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_ONCE([gl_SIGNAL_H],
  7. [
  8. AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
  9. AC_REQUIRE([gl_CHECK_TYPE_SIGSET_T])
  10. gl_NEXT_HEADERS([signal.h])
  11. # AIX declares sig_atomic_t to already include volatile, and C89 compilers
  12. # then choke on 'volatile sig_atomic_t'. C99 requires that it compile.
  13. AC_CHECK_TYPE([volatile sig_atomic_t], [],
  14. [HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=0], [[
  15. #include <signal.h>
  16. ]])
  17. dnl Ensure the type pid_t gets defined.
  18. AC_REQUIRE([AC_TYPE_PID_T])
  19. AC_REQUIRE([AC_TYPE_UID_T])
  20. dnl Persuade glibc <signal.h> to define sighandler_t.
  21. AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
  22. AC_CHECK_TYPE([sighandler_t], [], [HAVE_SIGHANDLER_T=0], [[
  23. #include <signal.h>
  24. ]])
  25. dnl Check for declarations of anything we want to poison if the
  26. dnl corresponding gnulib module is not in use.
  27. gl_WARN_ON_USE_PREPARE([[#include <signal.h>
  28. ]], [pthread_sigmask sigaction
  29. sigaddset sigdelset sigemptyset sigfillset sigismember
  30. sigpending sigprocmask])
  31. AC_REQUIRE([AC_C_RESTRICT])
  32. ])
  33. AC_DEFUN([gl_CHECK_TYPE_SIGSET_T],
  34. [
  35. AC_CHECK_TYPES([sigset_t],
  36. [gl_cv_type_sigset_t=yes], [gl_cv_type_sigset_t=no],
  37. [[
  38. #include <signal.h>
  39. /* Mingw defines sigset_t not in <signal.h>, but in <sys/types.h>. */
  40. #include <sys/types.h>
  41. ]])
  42. if test $gl_cv_type_sigset_t != yes; then
  43. HAVE_SIGSET_T=0
  44. fi
  45. ])
  46. # gl_SIGNAL_MODULE_INDICATOR([modulename])
  47. # sets the shell variable that indicates the presence of the given module
  48. # to a C preprocessor expression that will evaluate to 1.
  49. # This macro invocation must not occur in macros that are AC_REQUIREd.
  50. AC_DEFUN([gl_SIGNAL_MODULE_INDICATOR],
  51. [
  52. dnl Ensure to expand the default settings once only.
  53. gl_SIGNAL_H_REQUIRE_DEFAULTS
  54. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  55. dnl Define it also as a C macro, for the benefit of the unit tests.
  56. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  57. ])
  58. # Initializes the default values for AC_SUBSTed shell variables.
  59. # This macro must not be AC_REQUIREd. It must only be invoked, and only
  60. # outside of macros or in macros that are not AC_REQUIREd.
  61. AC_DEFUN([gl_SIGNAL_H_REQUIRE_DEFAULTS],
  62. [
  63. m4_defun(GL_MODULE_INDICATOR_PREFIX[_SIGNAL_H_MODULE_INDICATOR_DEFAULTS], [
  64. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_SIGMASK])
  65. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAISE])
  66. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNAL_H_SIGPIPE])
  67. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGPROCMASK])
  68. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGACTION])
  69. ])
  70. m4_require(GL_MODULE_INDICATOR_PREFIX[_SIGNAL_H_MODULE_INDICATOR_DEFAULTS])
  71. AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
  72. ])
  73. AC_DEFUN([gl_SIGNAL_H_DEFAULTS],
  74. [
  75. dnl Assume proper GNU behavior unless another module says otherwise.
  76. HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING])
  77. HAVE_PTHREAD_SIGMASK=1; AC_SUBST([HAVE_PTHREAD_SIGMASK])
  78. HAVE_RAISE=1; AC_SUBST([HAVE_RAISE])
  79. HAVE_SIGSET_T=1; AC_SUBST([HAVE_SIGSET_T])
  80. HAVE_SIGINFO_T=1; AC_SUBST([HAVE_SIGINFO_T])
  81. HAVE_SIGACTION=1; AC_SUBST([HAVE_SIGACTION])
  82. HAVE_STRUCT_SIGACTION_SA_SIGACTION=1;
  83. AC_SUBST([HAVE_STRUCT_SIGACTION_SA_SIGACTION])
  84. HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1;
  85. AC_SUBST([HAVE_TYPE_VOLATILE_SIG_ATOMIC_T])
  86. HAVE_SIGHANDLER_T=1; AC_SUBST([HAVE_SIGHANDLER_T])
  87. REPLACE_PTHREAD_SIGMASK=0; AC_SUBST([REPLACE_PTHREAD_SIGMASK])
  88. REPLACE_RAISE=0; AC_SUBST([REPLACE_RAISE])
  89. ])