summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2010-03-07 16:10:57 +0100
committerBruno Haible <bruno@clisp.org>2010-03-07 16:10:57 +0100
commit979260e3a53de91ae4792e57a6bb801a723a4539 (patch)
tree38f36e3d8d26b12aabcc3308f2d724965fd26e2e
parent3753983927e2b3036817bb59293dffee6001b5f4 (diff)
downloadgnulib-979260e3a53de91ae4792e57a6bb801a723a4539.tar.gz
Ensure posix_spawnattr_{get,set}sched{policy,param} are defined.
-rw-r--r--ChangeLog30
-rw-r--r--lib/spawn.in.h32
-rw-r--r--lib/spawnattr_getschedparam.c5
-rw-r--r--lib/spawnattr_getschedpolicy.c5
-rw-r--r--lib/spawnattr_setschedparam.c5
-rw-r--r--lib/spawnattr_setschedpolicy.c5
-rw-r--r--m4/posix_spawn.m445
-rw-r--r--modules/posix_spawnattr_getschedparam4
-rw-r--r--modules/posix_spawnattr_getschedpolicy4
-rw-r--r--modules/posix_spawnattr_setschedparam4
-rw-r--r--modules/posix_spawnattr_setschedpolicy4
-rw-r--r--tests/test-spawn.c6
12 files changed, 118 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index 0db6644e50..e91b6cc3f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,35 @@
2010-03-07 Bruno Haible <bruno@clisp.org>
+ Ensure posix_spawnattr_{get,set}sched{policy,param} are defined.
+ * lib/spawn.in.h (POSIX_SPAWN_SETSCHEDPARAM): Define fallback.
+ (POSIX_SPAWN_SETSCHEDULER): Likewise.
+ (POSIX_SPAWN_USEVFORK): Define in a way that works when
+ POSIX_SPAWN_SETSCHEDPARAM and POSIX_SPAWN_SETSCHEDULER are zero.
+ (posix_spawnattr_getschedpolicy, posix_spawnattr_setschedpolicy): Also
+ declare when POSIX_SPAWN_SETSCHEDULER is zero.
+ (posix_spawnattr_getschedparam, posix_spawnattr_setschedparam): Also
+ declare when POSIX_SPAWN_SETSCHEDPARAM is zero.
+ * m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): Test whether
+ POSIX_SPAWN_SETSCHEDULER or POSIX_SPAWN_SETSCHEDPARAM are zero.
+ * modules/posix_spawnattr_getschedparam (configure.ac): Enable the
+ replacement also when POSIX_SPAWN_SETSCHEDPARAM is zero.
+ * modules/posix_spawnattr_setschedparam (configure.ac): Likewise.
+ * modules/posix_spawnattr_getschedpolicy (configure.ac): Enable the
+ replacement also when POSIX_SPAWN_SETSCHEDULER is zero.
+ * modules/posix_spawnattr_setschedpolicy (configure.ac): Likewise.
+ * lib/spawnattr_getschedparam.c (posix_spawnattr_getschedparam): Do
+ nothing if POSIX_SPAWN_SETSCHEDPARAM is zero.
+ * lib/spawnattr_setschedparam.c (posix_spawnattr_setschedparam):
+ Likewise.
+ * lib/spawnattr_getschedpolicy.c (posix_spawnattr_getschedpolicy): Do
+ nothing if POSIX_SPAWN_SETSCHEDULER is zero.
+ * lib/spawnattr_setschedpolicy.c (posix_spawnattr_setschedpolicy):
+ Likewise.
+ * tests/test-spawn.c (main): Make it work when
+ POSIX_SPAWN_SETSCHEDPARAM and POSIX_SPAWN_SETSCHEDULER are zero.
+
+2010-03-07 Bruno Haible <bruno@clisp.org>
+
Fix incorrect Makefile.am generation in German locale.
* gnulib-tool (func_emit_lib_Makefile_am, func_emit_tests_Makefile_am):
Execute sed command with character range in C locale.
diff --git a/lib/spawn.in.h b/lib/spawn.in.h
index 1e8c936bd7..d049c040a9 100644
--- a/lib/spawn.in.h
+++ b/lib/spawn.in.h
@@ -110,7 +110,15 @@ typedef struct
/* Flags to be set in the `posix_spawnattr_t'. */
-#if !@HAVE_POSIX_SPAWN@
+#if @HAVE_POSIX_SPAWN@
+/* Use the values from the system, but provide the missing ones. */
+# ifndef POSIX_SPAWN_SETSCHEDPARAM
+# define POSIX_SPAWN_SETSCHEDPARAM 0
+# endif
+# ifndef POSIX_SPAWN_SETSCHEDULER
+# define POSIX_SPAWN_SETSCHEDULER 0
+# endif
+#else
# if @REPLACE_POSIX_SPAWN@
/* Use the values from the system, for better compatibility. */
/* But this implementation does not support AIX extensions. */
@@ -126,12 +134,14 @@ typedef struct
#endif
/* A GNU extension. Use the next free bit position. */
#define POSIX_SPAWN_USEVFORK \
- ((POSIX_SPAWN_RESETIDS | (POSIX_SPAWN_RESETIDS - 1) \
- | POSIX_SPAWN_SETPGROUP | (POSIX_SPAWN_SETPGROUP - 1) \
- | POSIX_SPAWN_SETSIGDEF | (POSIX_SPAWN_SETSIGDEF - 1) \
- | POSIX_SPAWN_SETSIGMASK | (POSIX_SPAWN_SETSIGMASK - 1) \
- | POSIX_SPAWN_SETSCHEDPARAM | (POSIX_SPAWN_SETSCHEDPARAM - 1) \
- | POSIX_SPAWN_SETSCHEDULER | (POSIX_SPAWN_SETSCHEDULER - 1)) \
+ ((POSIX_SPAWN_RESETIDS | (POSIX_SPAWN_RESETIDS - 1) \
+ | POSIX_SPAWN_SETPGROUP | (POSIX_SPAWN_SETPGROUP - 1) \
+ | POSIX_SPAWN_SETSIGDEF | (POSIX_SPAWN_SETSIGDEF - 1) \
+ | POSIX_SPAWN_SETSIGMASK | (POSIX_SPAWN_SETSIGMASK - 1) \
+ | POSIX_SPAWN_SETSCHEDPARAM \
+ | (POSIX_SPAWN_SETSCHEDPARAM > 0 ? POSIX_SPAWN_SETSCHEDPARAM - 1 : 0) \
+ | POSIX_SPAWN_SETSCHEDULER \
+ | (POSIX_SPAWN_SETSCHEDULER > 0 ? POSIX_SPAWN_SETSCHEDULER - 1 : 0)) \
+ 1)
typedef int verify_POSIX_SPAWN_USEVFORK_no_overlap
[2 * (((POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP
@@ -379,7 +389,7 @@ _GL_WARN_ON_USE (posix_spawnattr_setpgroup, "posix_spawnattr_setpgroup is unport
# if @REPLACE_POSIX_SPAWN@
# define posix_spawnattr_getschedpolicy rpl_posix_spawnattr_getschedpolicy
# endif
-# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
+# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0
extern int posix_spawnattr_getschedpolicy (const posix_spawnattr_t *_Restrict_ __attr,
int *_Restrict_ __schedpolicy)
__THROW _GL_ARG_NONNULL ((1, 2));
@@ -397,7 +407,7 @@ _GL_WARN_ON_USE (posix_spawnattr_getschedpolicy, "posix_spawnattr_getschedpolicy
# if @REPLACE_POSIX_SPAWN@
# define posix_spawnattr_setschedpolicy rpl_posix_spawnattr_setschedpolicy
# endif
-# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
+# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0
extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
int __schedpolicy)
__THROW _GL_ARG_NONNULL ((1));
@@ -415,7 +425,7 @@ _GL_WARN_ON_USE (posix_spawnattr_setschedpolicy, "posix_spawnattr_setschedpolicy
# if @REPLACE_POSIX_SPAWN@
# define posix_spawnattr_getschedparam rpl_posix_spawnattr_getschedparam
# endif
-# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
+# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0
extern int posix_spawnattr_getschedparam (const posix_spawnattr_t *_Restrict_ __attr,
struct sched_param *_Restrict_ __schedparam)
__THROW _GL_ARG_NONNULL ((1, 2));
@@ -433,7 +443,7 @@ _GL_WARN_ON_USE (posix_spawnattr_getschedparam, "posix_spawnattr_getschedparam i
# if @REPLACE_POSIX_SPAWN@
# define posix_spawnattr_setschedparam rpl_posix_spawnattr_setschedparam
# endif
-# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@
+# if !@HAVE_POSIX_SPAWN@ || @REPLACE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0
extern int posix_spawnattr_setschedparam (posix_spawnattr_t *_Restrict_ __attr,
const struct sched_param *_Restrict_ __schedparam)
__THROW _GL_ARG_NONNULL ((1, 2));
diff --git a/lib/spawnattr_getschedparam.c b/lib/spawnattr_getschedparam.c
index 4ac9c45879..631ec0c190 100644
--- a/lib/spawnattr_getschedparam.c
+++ b/lib/spawnattr_getschedparam.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2008, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2008-2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@ -24,8 +24,11 @@ int
posix_spawnattr_getschedparam (const posix_spawnattr_t *attr,
struct sched_param *schedparam)
{
+ /* Do nothing if POSIX_SPAWN_SETSCHEDPARAM is unsupported. */
+#if POSIX_SPAWN_SETSCHEDPARAM != 0
/* Copy the scheduling parameters. */
*schedparam = attr->_sp;
+#endif
return 0;
}
diff --git a/lib/spawnattr_getschedpolicy.c b/lib/spawnattr_getschedpolicy.c
index c94a93203f..248e05a864 100644
--- a/lib/spawnattr_getschedpolicy.c
+++ b/lib/spawnattr_getschedpolicy.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2009-2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@ -26,8 +26,11 @@ int
posix_spawnattr_getschedpolicy (const posix_spawnattr_t *attr,
int *schedpolicy)
{
+ /* Do nothing if POSIX_SPAWN_SETSCHEDULER is unsupported. */
+#if POSIX_SPAWN_SETSCHEDULER != 0
/* Copy the scheduling policy. */
*schedpolicy = attr->_policy;
+#endif
return 0;
}
diff --git a/lib/spawnattr_setschedparam.c b/lib/spawnattr_setschedparam.c
index 4e832c7e14..e01e6fcca4 100644
--- a/lib/spawnattr_setschedparam.c
+++ b/lib/spawnattr_setschedparam.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2009-2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@ -24,8 +24,11 @@ int
posix_spawnattr_setschedparam (posix_spawnattr_t *attr,
const struct sched_param *schedparam)
{
+ /* Do nothing if POSIX_SPAWN_SETSCHEDPARAM is unsupported. */
+#if POSIX_SPAWN_SETSCHEDPARAM != 0
/* Store the scheduling parameters. */
attr->_sp = *schedparam;
+#endif
return 0;
}
diff --git a/lib/spawnattr_setschedpolicy.c b/lib/spawnattr_setschedpolicy.c
index b12da4b5d2..b166e7278f 100644
--- a/lib/spawnattr_setschedpolicy.c
+++ b/lib/spawnattr_setschedpolicy.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2009-2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@ -25,12 +25,15 @@
int
posix_spawnattr_setschedpolicy (posix_spawnattr_t *attr, int schedpolicy)
{
+ /* Do nothing if POSIX_SPAWN_SETSCHEDULER is unsupported. */
+#if POSIX_SPAWN_SETSCHEDULER != 0
if (schedpolicy != SCHED_OTHER && schedpolicy != SCHED_FIFO
&& schedpolicy != SCHED_RR)
return EINVAL;
/* Store the policy. */
attr->_policy = schedpolicy;
+#endif
return 0;
}
diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4
index e8f12c40c7..89e2f7f064 100644
--- a/m4/posix_spawn.m4
+++ b/m4/posix_spawn.m4
@@ -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
diff --git a/modules/posix_spawnattr_getschedparam b/modules/posix_spawnattr_getschedparam
index 4691523503..e93479a50b 100644
--- a/modules/posix_spawnattr_getschedparam
+++ b/modules/posix_spawnattr_getschedparam
@@ -11,7 +11,9 @@ spawn
configure.ac:
gl_POSIX_SPAWN
-if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
+if test $HAVE_POSIX_SPAWN = 0 \
+ || test $REPLACE_POSIX_SPAWN = 1 \
+ || test $gl_cv_func_spawnattr_setschedparam = no; then
gl_REPLACE_SPAWN_H
AC_LIBOBJ([spawnattr_getschedparam])
fi
diff --git a/modules/posix_spawnattr_getschedpolicy b/modules/posix_spawnattr_getschedpolicy
index 9663e37a36..47f15f99e6 100644
--- a/modules/posix_spawnattr_getschedpolicy
+++ b/modules/posix_spawnattr_getschedpolicy
@@ -11,7 +11,9 @@ spawn
configure.ac:
gl_POSIX_SPAWN
-if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
+if test $HAVE_POSIX_SPAWN = 0 \
+ || test $REPLACE_POSIX_SPAWN = 1 \
+ || test $gl_cv_func_spawnattr_setschedpolicy = no; then
gl_REPLACE_SPAWN_H
AC_LIBOBJ([spawnattr_getschedpolicy])
fi
diff --git a/modules/posix_spawnattr_setschedparam b/modules/posix_spawnattr_setschedparam
index abef5f28dd..8330c87d30 100644
--- a/modules/posix_spawnattr_setschedparam
+++ b/modules/posix_spawnattr_setschedparam
@@ -11,7 +11,9 @@ spawn
configure.ac:
gl_POSIX_SPAWN
-if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
+if test $HAVE_POSIX_SPAWN = 0 \
+ || test $REPLACE_POSIX_SPAWN = 1 \
+ || test $gl_cv_func_spawnattr_setschedparam = no; then
gl_REPLACE_SPAWN_H
AC_LIBOBJ([spawnattr_setschedparam])
fi
diff --git a/modules/posix_spawnattr_setschedpolicy b/modules/posix_spawnattr_setschedpolicy
index 2ee661ae63..fd2046307b 100644
--- a/modules/posix_spawnattr_setschedpolicy
+++ b/modules/posix_spawnattr_setschedpolicy
@@ -11,7 +11,9 @@ spawn
configure.ac:
gl_POSIX_SPAWN
-if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
+if test $HAVE_POSIX_SPAWN = 0 \
+ || test $REPLACE_POSIX_SPAWN = 1 \
+ || test $gl_cv_func_spawnattr_setschedpolicy = no; then
gl_REPLACE_SPAWN_H
AC_LIBOBJ([spawnattr_setschedpolicy])
fi
diff --git a/tests/test-spawn.c b/tests/test-spawn.c
index dc6b0a8e79..3caf8ee6b8 100644
--- a/tests/test-spawn.c
+++ b/tests/test-spawn.c
@@ -1,5 +1,5 @@
/* Test of <spawn.h> substitute.
- Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -46,8 +46,8 @@ main (void)
case POSIX_SPAWN_SETPGROUP:
case POSIX_SPAWN_SETSIGDEF:
case POSIX_SPAWN_SETSIGMASK:
- case POSIX_SPAWN_SETSCHEDPARAM:
- case POSIX_SPAWN_SETSCHEDULER:
+ case (POSIX_SPAWN_SETSCHEDPARAM != 0 ? POSIX_SPAWN_SETSCHEDPARAM : -1):
+ case (POSIX_SPAWN_SETSCHEDULER != 0 ? POSIX_SPAWN_SETSCHEDULER : -2):
;
}
return s.c + s.d;