changeset 12944:e105c6e52c5d

sys_select: Avoid #define replacements in C++ mode.
author Bruno Haible <bruno@clisp.org>
date Mon, 08 Mar 2010 01:33:25 +0100
parents 2c1c5f9d6a39
children 3df573edd305
files ChangeLog lib/sys_select.in.h modules/sys_select
diffstat 3 files changed, 33 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -64,39 +64,41 @@
 #define _GL_SYS_SELECT_H
 
 #if !@HAVE_SYS_SELECT_H@ || @REPLACE_SELECT@
+/* A platform that lacks <sys/select.h>.  */
+# include <sys/socket.h>
+#endif
 
-/* A platform that lacks <sys/select.h>.  */
-
-# include <sys/socket.h>
+/* 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
+#endif
 
-# ifdef __cplusplus
-}
-# endif
-
-#endif
 
 #endif /* _GL_SYS_SELECT_H */
 #endif /* _GL_SYS_SELECT_H */
--- a/modules/sys_select
+++ b/modules/sys_select
@@ -7,6 +7,7 @@
 
 Depends-on:
 include_next
+c++defs
 sys_socket
 sys_time
 warn-on-use
@@ -20,7 +21,7 @@
 
 # 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 @@
 	      -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 && \