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