+2008-11-15 Bruno Haible <bruno@clisp.org>
+
+ Make the 'sched' module work on platforms where <sched.h> exists but
+ is incomplete (such as Haiku).
+ * lib/sched.in.h; Include the system's <sched.h> if it exists.
+ (SCHED_FIFO, SCHED_RR, SCHED_OTHER): New macros.
+ * m4/sched_h.m4 (gl_SCHED_H): Test whether <sched.h> exists and also
+ defines SCHED_FIFO, SCHED_RR, SCHED_OTHER. Set HAVE_SCHED_H,
+ HAVE_STRUCT_SCHED_PARAM.
+ * modules/sched (Depends-on): Add include_next.
+ (Makefile.am): Substitute HAVE_SCHED_H, INCLUDE_NEXT,
+ PRAGMA_SYSTEM_HEADER, NEXT_SCHED_H, HAVE_STRUCT_SCHED_PARAM.
+ * doc/posix-headers/sched.texi: Document the issue.
+
2008-11-13 Jim Meyering <meyering@redhat.com>
test-argp-2: avoid test failure when PACKAGE_BUGREPORT is defined
@item
This header file is missing on some platforms:
mingw, BeOS.
+@item
+@code{struct sched_param} is not defined on some platforms:
+Haiku.
+@item
+@code{SCHED_FIFO}, @code{SCHED_RR}, @code{SCHED_OTHER} are not defined on
+some platforms:
+Haiku.
@end itemize
Portability problems not fixed by Gnulib:
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#ifndef _GL_SCHED_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_SCHED_H@
+# @INCLUDE_NEXT@ @NEXT_SCHED_H@
+#endif
+
#ifndef _GL_SCHED_H
#define _GL_SCHED_H
+#if !@HAVE_STRUCT_SCHED_PARAM@
+
struct sched_param
{
int sched_priority;
};
+#endif
+
+#if !(defined SCHED_FIFO && defined SCHED_RR && defined SCHED_OTHER)
+# define SCHED_FIFO 1
+# define SCHED_RR 2
+# define SCHED_OTHER 0
+#endif
+
+#endif /* _GL_SCHED_H */
#endif /* _GL_SCHED_H */
-# sched_h.m4 serial 1
+# sched_h.m4 serial 2
dnl Copyright (C) 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFUN([gl_SCHED_H],
[
- AC_CHECK_HEADERS_ONCE([sched.h])
- if test $ac_cv_header_sched_h = yes; then
- SCHED_H=''
- else
- SCHED_H='sched.h'
- fi
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+ #include <sched.h>
+ struct sched_param a;
+ int b[] = { SCHED_FIFO, SCHED_RR, SCHED_OTHER };
+ ]])],
+ [SCHED_H=''],
+ [SCHED_H='sched.h'
+
+ gl_CHECK_NEXT_HEADERS([sched.h])
+
+ AC_CHECK_HEADERS_ONCE([sched.h])
+ if test $ac_cv_header_sched_h = yes; then
+ HAVE_SCHED_H=1
+ else
+ HAVE_SCHED_H=0
+ fi
+ AC_SUBST([HAVE_SCHED_H])
+
+ AC_CHECK_TYPE([struct sched_param],
+ [HAVE_STRUCT_SCHED_PARAM=1], [HAVE_STRUCT_SCHED_PARAM=0],
+ [#include <sched.h>])
+ AC_SUBST([HAVE_STRUCT_SCHED_PARAM])
+ ])
AC_SUBST([SCHED_H])
])
m4/sched_h.m4
Depends-on:
+include_next
configure.ac:
gl_SCHED_H
sched.h: sched.in.h
rm -f $@-t $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- cat < $(srcdir)/sched.in.h; \
+ sed -e 's|@''HAVE_SCHED_H''@|$(HAVE_SCHED_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''NEXT_SCHED_H''@|$(NEXT_SCHED_H)|g' \
+ -e 's|@''HAVE_STRUCT_SCHED_PARAM''@|$(HAVE_STRUCT_SCHED_PARAM)|g' \
+ < $(srcdir)/sched.in.h; \
} > $@-t
mv $@-t $@
MOSTLYCLEANFILES += sched.h sched.h-t