X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fopenat.c;h=0768b48f3dc95a1c9f15d37bfe1cc45a81b43501;hb=204966e4dadc046098cb5deea7031e307028ad7f;hp=18491a6f6d980f83533db563ee0ed4089283e165;hpb=3d50b6043ac61690f0b163a1618cfd5516238c81;p=gnulib.git diff --git a/lib/openat.c b/lib/openat.c index 18491a6f6..0768b48f3 100644 --- a/lib/openat.c +++ b/lib/openat.c @@ -16,8 +16,29 @@ /* written by Jim Meyering */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_openat doesn't recurse to + rpl_openat. */ +#define __need_system_fcntl_h #include +/* Get the original definition of open. It might be defined as a macro. */ +#include +#include +#undef __need_system_fcntl_h + +#if HAVE_OPENAT +static inline int +orig_openat (int fd, char const *filename, int flags, mode_t mode) +{ + return openat (fd, filename, flags, mode); +} +#endif + +/* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates + this include because of the preliminary #include above. */ +#include "fcntl.h" + #include "openat.h" #include @@ -31,8 +52,6 @@ #if HAVE_OPENAT -# undef openat - /* Like openat, but work around Solaris 9 bugs with trailing slash. */ int rpl_openat (int dfd, char const *filename, int flags, ...) @@ -86,7 +105,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...) } # endif - fd = openat (dfd, filename, flags, mode); + fd = orig_openat (dfd, filename, flags, mode); # if OPEN_TRAILING_SLASH_BUG /* If the filename ends in a slash and fd does not refer to a directory,