Mercurial > hg > octave-lojdl > gnulib-hg
changeset 12947:c2b20f3765ff
sys_time: Avoid #define replacements in C++ mode.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 08 Mar 2010 01:41:33 +0100 |
parents | 9e4da0c0da6a |
children | ea38eeab7d0f |
files | ChangeLog lib/sys_time.in.h modules/sys_time |
diffstat | 3 files changed, 37 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 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,
--- a/lib/sys_time.in.h +++ b/lib/sys_time.in.h @@ -39,13 +39,15 @@ # 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 @@ -55,15 +57,33 @@ }; # endif +# ifdef __cplusplus +} +# endif + # if @GNULIB_GETTIMEOFDAY@ # if @REPLACE_GETTIMEOFDAY@ -# undef gettimeofday -# define gettimeofday rpl_gettimeofday +# 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 -# if @REPLACE_GETTIMEOFDAY@ || !@HAVE_GETTIMEOFDAY@ -extern int gettimeofday (struct timeval *restrict, void *restrict) - _GL_ARG_NONNULL ((1)); -# endif +_GL_CXXALIASWARN (gettimeofday); # elif defined GNULIB_POSIXCHECK # undef gettimeofday # if HAVE_RAW_DECL_GETTIMEOFDAY @@ -72,8 +92,4 @@ # endif # endif -#ifdef __cplusplus -} -#endif - #endif /* _GL_SYS_TIME_H */
--- a/modules/sys_time +++ b/modules/sys_time @@ -8,6 +8,7 @@ Depends-on: include_next arg-nonnull +c++defs warn-on-use configure.ac: @@ -19,7 +20,7 @@ # 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! */'; \ @@ -31,6 +32,7 @@ -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; \