#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include @ABSOLUTE_FCNTL_H@
+#if @HAVE_INCLUDE_NEXT@
+# include_next <fcntl.h>
+#else
+# include @ABSOLUTE_FCNTL_H@
+#endif
+
+
+/* Declare overridden functions. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef FCHDIR_REPLACEMENT
+# define open rpl_open
+extern int open (const char *, int, ...);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* Fix up the O_* macros. */
#if !defined O_DIRECT && defined O_DIRECTIO
/* Tru64 spells it `O_DIRECTIO'. */
# define O_NOCTTY 0
#endif
-#ifdef O_NOFOLLOW_IS_INEFFECTIVE
-# undef O_NOFOLLOW
-#endif
#ifndef O_NOFOLLOW
# define O_NOFOLLOW 0
#endif