sched_h.m4 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # sched_h.m4 serial 15
  2. dnl Copyright (C) 2008-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. dnl Written by Bruno Haible.
  7. AC_DEFUN_ONCE([gl_SCHED_H],
  8. [
  9. dnl Ensure to expand the default settings once only, before all statements
  10. dnl that occur in other macros.
  11. AC_REQUIRE([gl_SCHED_H_DEFAULTS])
  12. AC_REQUIRE([AC_CANONICAL_HOST])
  13. AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
  14. AC_CHECK_HEADERS([sched.h], [], [],
  15. [[#if HAVE_SYS_CDEFS_H
  16. #include <sys/cdefs.h>
  17. #endif
  18. ]])
  19. gl_NEXT_HEADERS([sched.h])
  20. if test "$ac_cv_header_sched_h" = yes; then
  21. HAVE_SCHED_H=1
  22. else
  23. HAVE_SCHED_H=0
  24. fi
  25. AC_SUBST([HAVE_SCHED_H])
  26. if test "$HAVE_SCHED_H" = 1; then
  27. AC_CHECK_TYPE([struct sched_param],
  28. [HAVE_STRUCT_SCHED_PARAM=1], [HAVE_STRUCT_SCHED_PARAM=0],
  29. [[#if HAVE_SYS_CDEFS_H
  30. #include <sys/cdefs.h>
  31. #endif
  32. #include <sched.h>
  33. ]])
  34. else
  35. HAVE_STRUCT_SCHED_PARAM=0
  36. case "$host_os" in
  37. os2*)
  38. dnl On OS/2 kLIBC, struct sched_param is in spawn.h.
  39. AC_CHECK_TYPE([struct sched_param],
  40. [HAVE_STRUCT_SCHED_PARAM=1], [],
  41. [#include <spawn.h>])
  42. ;;
  43. vms)
  44. dnl On OpenVMS 7.2 or newer, struct sched_param is in pthread.h.
  45. AC_CHECK_TYPE([struct sched_param],
  46. [HAVE_STRUCT_SCHED_PARAM=1], [],
  47. [#include <pthread.h>])
  48. ;;
  49. esac
  50. fi
  51. AC_SUBST([HAVE_STRUCT_SCHED_PARAM])
  52. if test "$ac_cv_header_sys_cdefs_h" = yes; then
  53. HAVE_SYS_CDEFS_H=1
  54. else
  55. HAVE_SYS_CDEFS_H=0
  56. fi
  57. AC_SUBST([HAVE_SYS_CDEFS_H])
  58. dnl Ensure the type pid_t gets defined.
  59. AC_REQUIRE([AC_TYPE_PID_T])
  60. dnl Check for declarations of anything we want to poison if the
  61. dnl corresponding gnulib module is not in use, if it is not common
  62. dnl enough to be declared everywhere.
  63. gl_WARN_ON_USE_PREPARE([[#include <sched.h>
  64. ]], [sched_yield])
  65. ])
  66. # gl_SCHED_MODULE_INDICATOR([modulename])
  67. # sets the shell variable that indicates the presence of the given module
  68. # to a C preprocessor expression that will evaluate to 1.
  69. # This macro invocation must not occur in macros that are AC_REQUIREd.
  70. AC_DEFUN([gl_SCHED_MODULE_INDICATOR],
  71. [
  72. dnl Ensure to expand the default settings once only.
  73. gl_SCHED_H_REQUIRE_DEFAULTS
  74. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  75. dnl Define it also as a C macro, for the benefit of the unit tests.
  76. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  77. ])
  78. # Initializes the default values for AC_SUBSTed shell variables.
  79. # This macro must not be AC_REQUIREd. It must only be invoked, and only
  80. # outside of macros or in macros that are not AC_REQUIREd.
  81. AC_DEFUN([gl_SCHED_H_REQUIRE_DEFAULTS],
  82. [
  83. m4_defun(GL_MODULE_INDICATOR_PREFIX[_SCHED_H_MODULE_INDICATOR_DEFAULTS], [
  84. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCHED_YIELD])
  85. ])
  86. m4_require(GL_MODULE_INDICATOR_PREFIX[_SCHED_H_MODULE_INDICATOR_DEFAULTS])
  87. AC_REQUIRE([gl_SCHED_H_DEFAULTS])
  88. ])
  89. AC_DEFUN([gl_SCHED_H_DEFAULTS],
  90. [
  91. dnl Assume proper GNU behavior unless another module says otherwise.
  92. HAVE_SCHED_YIELD=1; AC_SUBST([HAVE_SCHED_YIELD])
  93. REPLACE_SCHED_YIELD=0; AC_SUBST([REPLACE_SCHED_YIELD])
  94. ])