From f345edc03da1a81f313dd70305764025bffeb1fa Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 22 May 2014 00:05:01 -0700 Subject: [PATCH] fchdir: port 'open' and 'close' redefinitions to AIX 7.1 * lib/chown.c, lib/clean-temp.c, lib/copy-file.c, lib/execute.c: * lib/fsusage.c, lib/gc-gnulib.c, lib/javacomp.c, lib/mountlist.c: * lib/openat-proc.c, lib/pagealign_alloc.c, lib/progreloc.c: * lib/spawn-pipe.c: Do not #undef 'open' and 'close'. AIX 7 does '#define open open64' and then 'int open64(const char *, int, ...);', which means the declaration for 'open' gets lost if we later '#undef open'. Discovered while building grep pretest 2.18.151-1c770 on AIX 7.1, where the compilation reported the non-fatal error "In function 'openat_proc_name' ... warning: implicit declaration of function 'open'". In this case the error is relatively harmless, but in other cases it might not be so minor. --- ChangeLog | 16 ++++++++++++++++ lib/chown.c | 5 ----- lib/clean-temp.c | 7 ------- lib/copy-file.c | 5 ----- lib/execute.c | 5 ----- lib/fsusage.c | 5 ----- lib/gc-gnulib.c | 5 ----- lib/javacomp.c | 5 ----- lib/mountlist.c | 5 ----- lib/openat-proc.c | 8 -------- lib/pagealign_alloc.c | 5 ----- lib/progreloc.c | 5 ----- lib/spawn-pipe.c | 5 ----- 13 files changed, 16 insertions(+), 65 deletions(-) diff --git a/ChangeLog b/ChangeLog index 488a0dad57..35ddc055dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2014-05-21 Paul Eggert + + fchdir: port 'open' and 'close' redefinitions to AIX 7.1 + * lib/chown.c, lib/clean-temp.c, lib/copy-file.c, lib/execute.c: + * lib/fsusage.c, lib/gc-gnulib.c, lib/javacomp.c, lib/mountlist.c: + * lib/openat-proc.c, lib/pagealign_alloc.c, lib/progreloc.c: + * lib/spawn-pipe.c: + Do not #undef 'open' and 'close'. AIX 7 does '#define open open64' + and then 'int open64(const char *, int, ...);', which means the + declaration for 'open' gets lost if we later '#undef open'. + Discovered while building grep pretest 2.18.151-1c770 on AIX 7.1, + where the compilation reported the non-fatal error "In function + 'openat_proc_name' ... warning: implicit declaration of function + 'open'". In this case the error is relatively harmless, but in + other cases it might not be so minor. + 2014-05-20 Paul Eggert xalloc: don't potentially generate invalid code for xmemdup calls diff --git a/lib/chown.c b/lib/chown.c index 15038416be..691cebe47f 100644 --- a/lib/chown.c +++ b/lib/chown.c @@ -45,11 +45,6 @@ chown (const char *file _GL_UNUSED, uid_t uid _GL_UNUSED, /* Below we refer to the system's chown(). */ # undef chown -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -# undef open -# undef close - /* Provide a more-closely POSIX-conforming version of chown on systems with one or both of the following problems: - chown doesn't treat an ID of -1 as meaning diff --git a/lib/clean-temp.c b/lib/clean-temp.c index 5e400d5166..057700a670 100644 --- a/lib/clean-temp.c +++ b/lib/clean-temp.c @@ -69,13 +69,6 @@ # define uintptr_t unsigned long #endif -#if !GNULIB_FCNTL_SAFER -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -# undef open -# undef close -#endif - /* The use of 'volatile' in the types below (and ISO C 99 section 5.1.2.3.(5)) ensure that while constructing or modifying the data structures, the field diff --git a/lib/copy-file.c b/lib/copy-file.c index 04d518df5a..488cc94c1c 100644 --- a/lib/copy-file.c +++ b/lib/copy-file.c @@ -48,11 +48,6 @@ #define _(str) gettext (str) -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close - enum { IO_SIZE = 32 * 1024 }; int diff --git a/lib/execute.c b/lib/execute.c index e7b4496309..15a487b833 100644 --- a/lib/execute.c +++ b/lib/execute.c @@ -48,11 +48,6 @@ #endif -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close - #if defined EINTR && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) diff --git a/lib/fsusage.c b/lib/fsusage.c index 6b8f7424d9..5bfc9cd092 100644 --- a/lib/fsusage.c +++ b/lib/fsusage.c @@ -55,11 +55,6 @@ # include "full-read.h" #endif -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close - /* Many space usage primitives use all 1 bits to denote a value that is not applicable or unknown. Propagate this information by returning a uintmax_t value that is all 1 bits if X is all 1 bits, even if X diff --git a/lib/gc-gnulib.c b/lib/gc-gnulib.c index 573cc9815a..dcd368b211 100644 --- a/lib/gc-gnulib.c +++ b/lib/gc-gnulib.c @@ -66,11 +66,6 @@ # include "rijndael-api-fst.h" #endif -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close - #ifdef GNULIB_GC_RANDOM # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # include diff --git a/lib/javacomp.c b/lib/javacomp.c index 6a15f10eb2..f54fb59d03 100644 --- a/lib/javacomp.c +++ b/lib/javacomp.c @@ -51,11 +51,6 @@ #define _(str) gettext (str) -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close - /* Survey of Java compilers. diff --git a/lib/mountlist.c b/lib/mountlist.c index d59c9937f5..78af951818 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -143,11 +143,6 @@ # include "unlocked-io.h" #endif -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close - /* The results of opendir() in this file are not used with dirfd and fchdir, therefore save some unnecessary work in fchdir.c. */ #undef opendir diff --git a/lib/openat-proc.c b/lib/openat-proc.c index 6a4f6ad1cf..7b40bb8f05 100644 --- a/lib/openat-proc.c +++ b/lib/openat-proc.c @@ -32,14 +32,6 @@ #include "intprops.h" -/* The results of open() in this file are not used with fchdir, - and we do not leak fds to any single-threaded code that could use stdio, - therefore save some unnecessary work in fchdir.c. - FIXME - if the kernel ever adds support for multi-thread safety for - avoiding standard fds, then we should use open_safer. */ -#undef open -#undef close - #define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/%s" #define PROC_SELF_FD_NAME_SIZE_BOUND(len) \ diff --git a/lib/pagealign_alloc.c b/lib/pagealign_alloc.c index 94a85fcf9b..f7fa825f1b 100644 --- a/lib/pagealign_alloc.c +++ b/lib/pagealign_alloc.c @@ -48,11 +48,6 @@ # endif #endif -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close - #if HAVE_MMAP || ! HAVE_POSIX_MEMALIGN diff --git a/lib/progreloc.c b/lib/progreloc.c index dcfe309936..3d7b6a9026 100644 --- a/lib/progreloc.c +++ b/lib/progreloc.c @@ -89,11 +89,6 @@ extern char * canonicalize_file_name (const char *name); # define FILE_SYSTEM_PREFIX_LEN(P) 0 #endif -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close - /* Use the system functions, not the gnulib overrides in this file. */ #undef sprintf diff --git a/lib/spawn-pipe.c b/lib/spawn-pipe.c index b3f9e0c11c..656980dd84 100644 --- a/lib/spawn-pipe.c +++ b/lib/spawn-pipe.c @@ -48,11 +48,6 @@ #endif -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close - #ifdef EINTR -- 2.39.5