changeset 17737:f6edaeb5841e

sys_select: fix FD_ZERO problem on Solaris 10 * lib/sys_select.in.h: Fix Solaris 10 bug where "#include <sys/time.h>" followed by "#include <sys/select.h>" caused FD_ZERO to expand to an expression that invoked memset without necessarily including <string.h>. The problem was that the first include defined _SYS_TIME_H, causing the second include to short-circuit. Fix a similar problem with <sys/types.h> followed by <sys/select.h>. Also, fix what appears to be a cut-and-paste typo, by replacing _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H with _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 05 Aug 2014 13:19:57 -0700
parents 62c4fda43d49
children 586e46ada98b
files ChangeLog lib/sys_select.in.h
diffstat 2 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Aug 05 13:14:04 2014 -0700
+++ b/ChangeLog	Tue Aug 05 13:19:57 2014 -0700
@@ -1,5 +1,16 @@
 2014-08-05  Paul Eggert  <eggert@cs.ucla.edu>
 
+	sys_select: fix FD_ZERO problem on Solaris 10
+	* lib/sys_select.in.h: Fix Solaris 10 bug where "#include
+	<sys/time.h>" followed by "#include <sys/select.h>" caused FD_ZERO
+	to expand to an expression that invoked memset without necessarily
+	including <string.h>.  The problem was that the first include
+	defined _SYS_TIME_H, causing the second include to short-circuit.
+	Fix a similar problem with <sys/types.h> followed by <sys/select.h>.
+	Also, fix what appears to be a cut-and-paste typo, by replacing
+	_GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H with
+	_GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H.
+
 	accept: document Solaris 10 type glitch
 	* doc/posix-functions/accept.texi (accept): Mention that
 	Solaris 10 'accept' takes void * last arg, not socklen_t *.
--- a/lib/sys_select.in.h	Tue Aug 05 13:14:04 2014 -0700
+++ b/lib/sys_select.in.h	Tue Aug 05 13:19:57 2014 -0700
@@ -24,8 +24,8 @@
    On Cygwin, <sys/time.h> includes <sys/select.h>.
    Simply delegate to the system's header in this case.  */
 #if (@HAVE_SYS_SELECT_H@                                                \
+     && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H             \
      && ((defined __osf__ && defined _SYS_TYPES_H_                      \
-          && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H         \
           && defined _OSF_SOURCE)                                       \
          || (defined __sun && defined _SYS_TYPES_H                      \
              && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE)   \
@@ -36,12 +36,13 @@
 
 #elif (@HAVE_SYS_SELECT_H@                                              \
        && (defined _CYGWIN_SYS_TIME_H                                   \
-           || (defined __osf__ && defined _SYS_TIME_H_                  \
-               && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H    \
-               && defined _OSF_SOURCE)                                  \
-           || (defined __sun && defined _SYS_TIME_H                     \
-               && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE) \
-                   || defined __EXTENSIONS__))))
+           || (!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H       \
+               && ((defined __osf__ && defined _SYS_TIME_H_             \
+                    && defined _OSF_SOURCE)                             \
+                   || (defined __sun && defined _SYS_TIME_H             \
+                       && (! (defined _XOPEN_SOURCE                     \
+                              || defined _POSIX_C_SOURCE)               \
+                           || defined __EXTENSIONS__))))))
 
 # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H
 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@