Mercurial > hg > octave-lyh > gnulib-hg
changeset 12931:82b0c98fe7aa
fcntl-h: Avoid #define replacements in C++ mode.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 08 Mar 2010 00:51:34 +0100 |
parents | 8de7d7c428e7 |
children | fecbba7601e9 |
files | ChangeLog lib/fcntl.in.h modules/fcntl-h |
diffstat | 3 files changed, 51 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-03-07 Bruno Haible <bruno@clisp.org> + fcntl-h: Avoid #define replacements in C++ mode. + * lib/fcntl.in.h: Include c++defs.h. + (fcntl, open, openat): In C++, define a namespaced alias symbol. + * modules/fcntl-h (Depends-on): Add c++defs. + (Makefile.am): Update fcntl.h rule. + dirent: Avoid #define replacements in C++ mode. * lib/dirent.in.h: Include c++defs.h. (closedir, fdopendir, opendir, scandir, alphasort): In C++, define a
--- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -50,6 +50,8 @@ #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. */ @@ -57,18 +59,21 @@ /* Declare overridden functions. */ -#ifdef __cplusplus -extern "C" { -#endif - #if @GNULIB_FCNTL@ # if @REPLACE_FCNTL@ -# undef fcntl -# define fcntl rpl_fcntl +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fcntl +# define fcntl rpl_fcntl +# endif +_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); +_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); +# else +# if !@HAVE_FCNTL@ +_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); +# endif +_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...)); # endif -# if !@HAVE_FCNTL@ || @REPLACE_FCNTL@ -extern int fcntl (int fd, int action, ...); -# endif +_GL_CXXALIASWARN (fcntl); #elif defined GNULIB_POSIXCHECK # undef fcntl # if HAVE_RAW_DECL_FCNTL @@ -79,10 +84,17 @@ #if @GNULIB_OPEN@ # if @REPLACE_OPEN@ -# undef open -# define open rpl_open -extern int open (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1)); +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef open +# define open rpl_open +# endif +_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); +# else +_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); # endif +_GL_CXXALIASWARN (open); #elif defined GNULIB_POSIXCHECK # undef open /* Assume open is always declared. */ @@ -92,13 +104,25 @@ #if @GNULIB_OPENAT@ # if @REPLACE_OPENAT@ -# undef openat -# define openat rpl_openat +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef openat +# define openat rpl_openat +# endif +_GL_FUNCDECL_RPL (openat, int, + (int fd, char const *file, int flags, /* mode_t mode */ ...) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (openat, int, + (int fd, char const *file, int flags, /* mode_t mode */ ...)); +# else +# if !@HAVE_OPENAT@ +_GL_FUNCDECL_SYS (openat, int, + (int fd, char const *file, int flags, /* mode_t mode */ ...) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (openat, int, + (int fd, char const *file, int flags, /* mode_t mode */ ...)); # endif -# if !@HAVE_OPENAT@ || @REPLACE_OPENAT@ -extern int openat (int fd, char const *file, int flags, /* mode_t mode */ ...) - _GL_ARG_NONNULL ((2)); -# endif +_GL_CXXALIASWARN (openat); #elif defined GNULIB_POSIXCHECK # undef openat # if HAVE_RAW_DECL_OPENAT @@ -107,9 +131,6 @@ # endif #endif -#ifdef __cplusplus -} -#endif /* Fix up the FD_* macros, only known to be missing on mingw. */
--- a/modules/fcntl-h +++ b/modules/fcntl-h @@ -8,6 +8,7 @@ Depends-on: arg-nonnull +c++defs extensions include_next unistd @@ -21,7 +22,7 @@ # We need the following in order to create <fcntl.h> when the system # doesn't have one that works with the given compiler. -fcntl.h: fcntl.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H) +fcntl.h: fcntl.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -35,6 +36,7 @@ -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \ -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|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)/fcntl.in.h; \