From: Bruno Haible Date: Sat, 15 Nov 2008 12:06:41 +0000 (+0100) Subject: Make the 'sched' module work on platforms where is incomplete. X-Git-Tag: v0.1~6679 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=4dd30a3ea2e00bbad5091af335962c4ebe4bfcfa;p=gnulib.git Make the 'sched' module work on platforms where is incomplete. --- diff --git a/ChangeLog b/ChangeLog index a61d05bcb..041363331 100644 --- 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 index 677bb82f0..6994105df 100644 --- a/doc/posix-headers/sched.texi +++ b/doc/posix-headers/sched.texi @@ -10,6 +10,13 @@ Portability problems fixed by Gnulib: @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 index 39c35bffb..6621fa23d 100644 --- 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 index 697d82987..30c4d98ba 100644 --- 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 @@ dnl Written by Bruno Haible. 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 index d08f4f286..4bba3ddae 100644 --- a/modules/sched +++ b/modules/sched @@ -6,6 +6,7 @@ lib/sched.in.h m4/sched_h.m4 Depends-on: +include_next configure.ac: gl_SCHED_H @@ -18,7 +19,12 @@ BUILT_SOURCES += $(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