2010-03-07 Bruno Haible <bruno@clisp.org>
+ sys_time: Avoid #define replacements in C++ mode.
+ * lib/sys_time.in.h: Include c++defs.h.
+ (gettimeofday): In C++, define a namespaced alias symbol.
+ * modules/sys_time (Depends-on): Add c++defs.
+ (Makefile.am): Update sys/time.h rule.
+
sys_stat: Avoid #define replacements in C++ mode.
* lib/sys_stat.in.h: Include c++defs.h.
(fchmodat, fstat, fstatat, futimens, lchmod, lstat, mkdir, mkdirat,
# include <time.h>
# endif
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
# if ! @HAVE_STRUCT_TIMEVAL@
struct timeval
};
# endif
+# ifdef __cplusplus
+}
+# endif
+
# if @GNULIB_GETTIMEOFDAY@
# if @REPLACE_GETTIMEOFDAY@
-# undef gettimeofday
-# define gettimeofday rpl_gettimeofday
-# endif
-# if @REPLACE_GETTIMEOFDAY@ || !@HAVE_GETTIMEOFDAY@
-extern int gettimeofday (struct timeval *restrict, void *restrict)
- _GL_ARG_NONNULL ((1));
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef gettimeofday
+# define gettimeofday rpl_gettimeofday
+# endif
+_GL_FUNCDECL_RPL (gettimeofday, int,
+ (struct timeval *restrict, void *restrict)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (gettimeofday, int,
+ (struct timeval *restrict, void *restrict));
+# else
+# if !@HAVE_GETTIMEOFDAY@
+_GL_FUNCDECL_SYS (gettimeofday, int,
+ (struct timeval *restrict, void *restrict)
+ _GL_ARG_NONNULL ((1)));
+# endif
+/* Need to cast, because on glibc systems, by default, the second argument is
+ struct timezone *. */
+_GL_CXXALIAS_SYS_CAST (gettimeofday, int,
+ (struct timeval *restrict, void *restrict));
# endif
+_GL_CXXALIASWARN (gettimeofday);
# elif defined GNULIB_POSIXCHECK
# undef gettimeofday
# if HAVE_RAW_DECL_GETTIMEOFDAY
# endif
# endif
-#ifdef __cplusplus
-}
-#endif
-
#endif /* _GL_SYS_TIME_H */
Depends-on:
include_next
arg-nonnull
+c++defs
warn-on-use
configure.ac:
# We need the following in order to create <sys/time.h> when the system
# doesn't have one that works with the given compiler.
-sys/time.h: sys_time.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+sys/time.h: sys_time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \
-e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
-e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/sys_time.in.h; \