# HG changeset patch # User Bruno Haible # Date 1226750801 -3600 # Node ID 88888cd66a05b4a43864f64ef902b128b2240cfa # Parent ba850053edd1ebdc94e028c7f2139abbd72cb02f Make the 'sched' module work on platforms where is incomplete. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2008-11-15 Bruno Haible + + Make the 'sched' module work on platforms where exists but + is incomplete (such as Haiku). + * lib/sched.in.h; Include the system's if it exists. + (SCHED_FIFO, SCHED_RR, SCHED_OTHER): New macros. + * m4/sched_h.m4 (gl_SCHED_H): Test whether 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 test-argp-2: avoid test failure when PACKAGE_BUGREPORT is defined diff --git a/doc/posix-headers/sched.texi b/doc/posix-headers/sched.texi --- a/doc/posix-headers/sched.texi +++ b/doc/posix-headers/sched.texi @@ -10,6 +10,13 @@ @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: diff --git a/lib/sched.in.h b/lib/sched.in.h --- a/lib/sched.in.h +++ b/lib/sched.in.h @@ -15,11 +15,33 @@ along with this program. If not, see . */ #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 */ diff --git a/m4/sched_h.m4 b/m4/sched_h.m4 --- a/m4/sched_h.m4 +++ b/m4/sched_h.m4 @@ -1,4 +1,4 @@ -# 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, @@ -8,11 +8,29 @@ 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 + 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 ]) + AC_SUBST([HAVE_STRUCT_SCHED_PARAM]) + ]) AC_SUBST([SCHED_H]) ]) diff --git a/modules/sched b/modules/sched --- a/modules/sched +++ b/modules/sched @@ -6,6 +6,7 @@ m4/sched_h.m4 Depends-on: +include_next configure.ac: gl_SCHED_H @@ -18,7 +19,12 @@ 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