Manual: improve out-of-memory documentation.
[gnulib.git] / lib / fcntl.in.h
index a1d9e23..a7e4a95 100644 (file)
@@ -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.  */
 
 /* Declare overridden functions.  */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #if @GNULIB_FCNTL@
 # if @REPLACE_FCNTL@
-#  undef fcntl
-#  define fcntl rpl_fcntl
-# endif
-# if !@HAVE_FCNTL@ || @REPLACE_FCNTL@
-extern int fcntl (int fd, int action, ...);
+#  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
+_GL_CXXALIASWARN (fcntl);
 #elif defined GNULIB_POSIXCHECK
 # undef fcntl
 # if HAVE_RAW_DECL_FCNTL
@@ -79,10 +84,17 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
 
 #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 @@ _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
 
 #if @GNULIB_OPENAT@
 # if @REPLACE_OPENAT@
-#  undef openat
-#  define openat rpl_openat
-# endif
-# if !@HAVE_OPENAT@ || @REPLACE_OPENAT@
-extern int openat (int fd, char const *file, int flags, /* mode_t mode */ ...)
-     _GL_ARG_NONNULL ((2));
+#  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
+_GL_CXXALIASWARN (openat);
 #elif defined GNULIB_POSIXCHECK
 # undef openat
 # if HAVE_RAW_DECL_OPENAT
@@ -107,9 +131,6 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
 # endif
 #endif
 
-#ifdef __cplusplus
-}
-#endif
 
 /* Fix up the FD_* macros, only known to be missing on mingw.  */
 
@@ -149,6 +170,10 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
 # define O_CLOEXEC O_NOINHERIT
 #endif
 
+#ifndef O_CLOEXEC
+# define O_CLOEXEC 0
+#endif
+
 #ifndef O_DIRECT
 # define O_DIRECT 0
 #endif
@@ -161,6 +186,10 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
 # define O_DSYNC 0
 #endif
 
+#ifndef O_EXEC
+# define O_EXEC O_RDONLY /* This is often close enough in older systems.  */
+#endif
+
 #ifndef O_NDELAY
 # define O_NDELAY 0
 #endif
@@ -189,6 +218,10 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
 # define O_RSYNC 0
 #endif
 
+#ifndef O_SEARCH
+# define O_SEARCH O_RDONLY /* This is often close enough in older systems.  */
+#endif
+
 #ifndef O_SYNC
 # define O_SYNC 0
 #endif