Move more flags to lib/fcntl.in.h.
authorPaolo Bonzini <bonzini@gnu.org>
Thu, 20 Aug 2009 08:24:19 +0000 (10:24 +0200)
committerPaolo Bonzini <bonzini@gnu.org>
Fri, 21 Aug 2009 12:05:25 +0000 (14:05 +0200)
* lib/cloexec.c: Do not define FD_CLOEXEC here.
* lib/popen-safer.c: Do not alias O_NOINHERIT to O_CLOEXEC here.
* lib/fcntl.in.h: Do both things here.

ChangeLog
lib/cloexec.c
lib/fcntl.in.h
lib/popen-safer.c

index 8210003..a1b015d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-21  Paolo Bonzini  <bonzini@gnu.org>
+
+       fcntl: move more flags to the header
+       * lib/cloexec.c: Do not define FD_CLOEXEC here.
+       * lib/popen-safer.c: Do not alias O_NOINHERIT to O_CLOEXEC here.
+       * lib/fcntl.in.h: Do both things here.
+
 2009-08-21  Jim Meyering  <meyering@redhat.com>
 
        consistently remove $@-t before redirecting to it
index ff8105b..0fb227c 100644 (file)
 #include <unistd.h>
 #include <fcntl.h>
 
-#ifndef FD_CLOEXEC
-# define FD_CLOEXEC 1
-#endif
-
 /* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
    or clear the flag if VALUE is false.
    Return 0 on success, or -1 on error with `errno' set. */
index fd7520e..a688fb4 100644 (file)
@@ -67,6 +67,11 @@ extern void _gl_register_fd (int fd, const char *filename);
 }
 #endif
 
+/* Fix up the FD_* macros.  */
+
+#ifndef FD_CLOEXEC
+# define FD_CLOEXEC 1
+#endif
 
 /* Fix up the O_* macros.  */
 
@@ -75,6 +80,12 @@ extern void _gl_register_fd (int fd, const char *filename);
 # define O_DIRECT O_DIRECTIO
 #endif
 
+#if !defined O_CLOEXEC && defined O_NOINHERIT
+/* Mingw spells it `O_NOINHERIT'.  Intentionally leave it
+   undefined if not available.  */
+# define O_CLOEXEC O_NOINHERIT
+#endif
+
 #ifndef O_DIRECT
 # define O_DIRECT 0
 #endif
index 2182a2c..1905be5 100644 (file)
@@ -27,9 +27,7 @@
 
 #include "cloexec.h"
 
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# define O_CLOEXEC O_NOINHERIT
-#elif !defined O_CLOEXEC
+#ifndef O_CLOEXEC
 # define O_CLOEXEC 0
 #endif