From: Bruno Haible <bruno@clisp.org>
Date: Mon, 8 Mar 2010 00:33:25 +0000 (+0100)
Subject: sys_select: Avoid #define replacements in C++ mode.
X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1133754bf7a631401ad32244041088fb639b819;p=pspp

sys_select: Avoid #define replacements in C++ mode.
---

diff --git a/ChangeLog b/ChangeLog
index f7abd58535..12812528a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-03-07  Bruno Haible  <bruno@clisp.org>
 
+	sys_select: Avoid #define replacements in C++ mode.
+	* lib/sys_select.in.h: Include c++defs.h. Enable the function
+	definitions also when the system has a <sys/select.h>.
+	(select): In C++, define a namespaced alias symbol.
+	* modules/sys_select (Depends-on): Add c++defs.
+	(Makefile.am): Update sys/select.h rule.
+
 	sys_ioctl: Avoid #define replacements in C++ mode.
 	* lib/sys_ioctl.in.h: Include c++defs.h.
 	(ioctl): In C++, define a namespaced alias symbol.
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
index b506e9fca7..ae2a3d23b9 100644
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -64,40 +64,42 @@
 #define _GL_SYS_SELECT_H
 
 #if !@HAVE_SYS_SELECT_H@ || @REPLACE_SELECT@
-
 /* A platform that lacks <sys/select.h>.  */
-
 # include <sys/socket.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
-# ifdef __cplusplus
-extern "C" {
-# endif
 
-# if @GNULIB_SELECT@
-#  if @HAVE_WINSOCK2_H@ || @REPLACE_SELECT@
+#if @GNULIB_SELECT@
+# if @HAVE_WINSOCK2_H@ || @REPLACE_SELECT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef select
 #   define select rpl_select
-extern int rpl_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
 #  endif
-# elif @HAVE_WINSOCK2_H@
-#  undef select
-#  define select select_used_without_requesting_gnulib_module_select
-# elif defined GNULIB_POSIXCHECK
-#  undef select
-#  if HAVE_RAW_DECL_SELECT
+_GL_FUNCDECL_RPL (select, int,
+                  (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+_GL_CXXALIAS_RPL (select, int,
+                  (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+# else
+_GL_CXXALIAS_SYS (select, int,
+                  (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+# endif
+_GL_CXXALIASWARN (select);
+#elif @HAVE_WINSOCK2_H@
+# undef select
+# define select select_used_without_requesting_gnulib_module_select
+#elif defined GNULIB_POSIXCHECK
+# undef select
+# if HAVE_RAW_DECL_SELECT
 _GL_WARN_ON_USE (select, "select is not always POSIX compliant - "
                  "use gnulib module select for portability");
-#  endif
-# endif
-
-# ifdef __cplusplus
-}
 # endif
-
 #endif
 
+
 #endif /* _GL_SYS_SELECT_H */
 #endif /* _GL_SYS_SELECT_H */
 #endif /* OSF/1 */
diff --git a/modules/sys_select b/modules/sys_select
index 27d9a48cb4..4f4d6d9bb3 100644
--- a/modules/sys_select
+++ b/modules/sys_select
@@ -7,6 +7,7 @@ m4/sys_select_h.m4
 
 Depends-on:
 include_next
+c++defs
 sys_socket
 sys_time
 warn-on-use
@@ -20,7 +21,7 @@ BUILT_SOURCES += sys/select.h
 
 # We need the following in order to create <sys/select.h> when the system
 # doesn't have one that works with the given compiler.
-sys/select.h: sys_select.in.h $(WARN_ON_USE_H)
+sys/select.h: sys_select.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
 	$(AM_V_at)$(MKDIR_P) sys
 	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -31,6 +32,7 @@ sys/select.h: sys_select.in.h $(WARN_ON_USE_H)
 	      -e 's|@''GNULIB_SELECT''@|$(GNULIB_SELECT)|g' \
 	      -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
 	      -e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
 	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
 	      < $(srcdir)/sys_select.in.h; \
 	} > $@-t && \