Ensure posix_spawnattr_{get,set}sched{policy,param} are defined.
[gnulib.git] / m4 / posix_spawn.m4
index e8f12c4..89e2f7f 100644 (file)
@@ -1,5 +1,5 @@
-# posix_spawn.m4 serial 4
-dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+# posix_spawn.m4 serial 5
+dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -14,8 +14,8 @@ AC_DEFUN([gl_POSIX_SPAWN_BODY],
 [
   AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
   AC_CHECK_FUNCS_ONCE([posix_spawn])
-  dnl Assume that when the main function exists, all the others are
-  dnl available as well.
+  dnl Assume that when the main function exists, all the others,
+  dnl except posix_spawnattr_{get,set}sched*, are available as well.
   dnl AC_CHECK_FUNCS_ONCE([posix_spawnp])
   dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_init])
   dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addclose])
@@ -27,10 +27,6 @@ AC_DEFUN([gl_POSIX_SPAWN_BODY],
   dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setflags])
   dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getpgroup])
   dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setpgroup])
-  dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedparam])
-  dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedparam])
-  dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedpolicy])
-  dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedpolicy])
   dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getsigdefault])
   dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setsigdefault])
   dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getsigmask])
@@ -39,7 +35,38 @@ AC_DEFUN([gl_POSIX_SPAWN_BODY],
   if test $ac_cv_func_posix_spawn = yes; then
     gl_POSIX_SPAWN_WORKS
     case "$gl_cv_func_posix_spawn_works" in
-      *yes) ;;
+      *yes)
+        dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDULER
+        dnl evaluates to nonzero.
+        dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedpolicy])
+        dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedpolicy])
+        AC_CACHE_CHECK([whether posix_spawnattr_setschedpolicy is supported],
+          [gl_cv_func_spawnattr_setschedpolicy],
+          [AC_EGREP_CPP([POSIX scheduling supported], [
+#include <spawn.h>
+#if POSIX_SPAWN_SETSCHEDULER
+ POSIX scheduling supported
+#endif
+],
+             [gl_cv_func_spawnattr_setschedpolicy=yes],
+             [gl_cv_func_spawnattr_setschedpolicy=no])
+          ])
+        dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDPARAM
+        dnl evaluates to nonzero.
+        dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedparam])
+        dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedparam])
+        AC_CACHE_CHECK([whether posix_spawnattr_setschedparam is supported],
+          [gl_cv_func_spawnattr_setschedparam],
+          [AC_EGREP_CPP([POSIX scheduling supported], [
+#include <spawn.h>
+#if POSIX_SPAWN_SETSCHEDPARAM
+ POSIX scheduling supported
+#endif
+],
+             [gl_cv_func_spawnattr_setschedparam=yes],
+             [gl_cv_func_spawnattr_setschedparam=no])
+          ])
+        ;;
       *) REPLACE_POSIX_SPAWN=1 ;;
     esac
   else