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