changeset 15350:f61aaaf49e43

sys_select: define sigset_t more portably * lib/sys_select.in.h: Always include <sys/types.h>, since we now need sigset_t and mingw defines it there. Include <signal.h> before split inclusion guard, to avoid mishaps on Solaris, whose <signal.h> eventually includes us. * m4/signal_h.m4 (gl_SIGNAL_H): Require gl_CHECK_TYPE_SIGSET_T. (gl_CHECK_TYPE_SIGSET_T): New macro, most of the contents of which come from ... * m4/signalblocking.m4 (gl_SIGNALBLOCKING): Require gl_CHECK_TYPE_SIGSET_T. (gl_PREREQ_SIGPROCMASK): Now a no-op, since gl_CHECK_TYPE_SIGSET_T does the real work. * modules/sys_select (Depends-on): Add 'signal'.
author Paul Eggert <eggert@cs.ucla.edu>
date Wed, 06 Jul 2011 00:42:24 -0700
parents b3eeae7bf93e
children 68df2553ba3d
files ChangeLog lib/sys_select.in.h m4/signal_h.m4 m4/signalblocking.m4 modules/sys_select
diffstat 5 files changed, 47 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2011-07-06  Paul Eggert  <eggert@cs.ucla.edu>
 
+	sys_select: define sigset_t more portably
+	* lib/sys_select.in.h: Always include <sys/types.h>, since
+	we now need sigset_t and mingw defines it there.
+	Include <signal.h> before split inclusion guard, to avoid
+	mishaps on Solaris, whose <signal.h> eventually includes us.
+	* m4/signal_h.m4 (gl_SIGNAL_H): Require gl_CHECK_TYPE_SIGSET_T.
+	(gl_CHECK_TYPE_SIGSET_T): New macro, most of the contents of
+	which come from ...
+	* m4/signalblocking.m4 (gl_SIGNALBLOCKING): Require
+	gl_CHECK_TYPE_SIGSET_T.
+	(gl_PREREQ_SIGPROCMASK): Now a no-op, since gl_CHECK_TYPE_SIGSET_T
+	does the real work.
+	* modules/sys_select (Depends-on): Add 'signal'.
+
 	* m4/sys_select_h.m4 (gl_HEADER_SYS_SELECT): Poison pselect.
 	Suggested by Bruno Haible.
 
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -36,11 +36,18 @@
 
 #ifndef _@GUARD_PREFIX@_SYS_SELECT_H
 
-#if @HAVE_SYS_SELECT_H@
+/* On many platforms, <sys/select.h> assumes prior inclusion of
+   <sys/types.h>.  Also, mingw defines sigset_t there, instead of
+   in <signal.h> where it belongs.  */
+#include <sys/types.h>
 
-/* On many platforms, <sys/select.h> assumes prior inclusion of
-   <sys/types.h>.  */
-# include <sys/types.h>
+/* Get definition of 'sigset_t'.
+   But avoid namespace pollution on glibc systems.  */
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
+# include <signal.h>
+#endif
+
+#if @HAVE_SYS_SELECT_H@
 
 /* On OSF/1 4.0, <sys/select.h> provides only a forward declaration
    of 'struct timeval', and no definition of this type.
@@ -85,12 +92,6 @@
 # endif
 #endif
 
-/* Get definition of 'sigset_t'.
-   But avoid namespace pollution on glibc systems.  */
-#if !(defined __GLIBC__ && !defined __UCLIBC__)
-# include <signal.h>
-#endif
-
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
--- a/m4/signal_h.m4
+++ b/m4/signal_h.m4
@@ -1,4 +1,4 @@
-# signal_h.m4 serial 13
+# signal_h.m4 serial 14
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,6 +7,7 @@
 AC_DEFUN([gl_SIGNAL_H],
 [
   AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
+  AC_REQUIRE([gl_CHECK_TYPE_SIGSET_T])
   gl_NEXT_HEADERS([signal.h])
 
 # AIX declares sig_atomic_t to already include volatile, and C89 compilers
@@ -32,6 +33,20 @@
     sigpending sigprocmask])
 ])
 
+AC_DEFUN([gl_CHECK_TYPE_SIGSET_T],
+[
+  AC_CHECK_TYPES([sigset_t],
+    [gl_cv_type_sigset_t=yes], [gl_cv_type_sigset_t=no],
+    [[
+      #include <signal.h>
+      /* Mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.  */
+      #include <sys/types.h>
+    ]])
+  if test $gl_cv_type_sigset_t != yes; then
+    HAVE_SIGSET_T=0
+  fi
+])
+
 AC_DEFUN([gl_SIGNAL_MODULE_INDICATOR],
 [
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
--- a/m4/signalblocking.m4
+++ b/m4/signalblocking.m4
@@ -1,4 +1,4 @@
-# signalblocking.m4 serial 11
+# signalblocking.m4 serial 12
 dnl Copyright (C) 2001-2002, 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,9 +12,8 @@
 AC_DEFUN([gl_SIGNALBLOCKING],
 [
   AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
-  signals_not_posix=
-  AC_EGREP_HEADER([sigset_t], [signal.h], , [signals_not_posix=1])
-  if test -z "$signals_not_posix"; then
+  AC_REQUIRE([gl_CHECK_TYPE_SIGSET_T])
+  if test $gl_cv_type_sigset_t = yes; then
     AC_CHECK_FUNC([sigprocmask], [gl_cv_func_sigprocmask=1])
   fi
   if test -z "$gl_cv_func_sigprocmask"; then
@@ -22,19 +21,5 @@
   fi
 ])
 
-# Prerequisites of the part of lib/signal.in.h and of lib/sigprocmask.c.
-AC_DEFUN([gl_PREREQ_SIGPROCMASK],
-[
-  AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
-  AC_CHECK_TYPES([sigset_t],
-    [gl_cv_type_sigset_t=yes], [gl_cv_type_sigset_t=no],
-    [#include <signal.h>
-/* Mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.  */
-#include <sys/types.h>])
-  if test $gl_cv_type_sigset_t != yes; then
-    HAVE_SIGSET_T=0
-  fi
-  dnl HAVE_SIGSET_T is 1 if the system lacks the sigprocmask function but has
-  dnl the sigset_t type.
-  AC_SUBST([HAVE_SIGSET_T])
-])
+# Prerequisites of lib/sigprocmask.c.
+AC_DEFUN([gl_PREREQ_SIGPROCMASK], [:])
--- a/modules/sys_select
+++ b/modules/sys_select
@@ -9,6 +9,7 @@
 Depends-on:
 include_next
 c++defs
+signal
 sys_time
 warn-on-use