* descriptors.cc (set_close_on_exec): New function.
authorIan Lance Taylor <ian@airs.com>
Fri, 22 Apr 2011 23:20:28 +0000 (23:20 +0000)
committerIan Lance Taylor <ian@airs.com>
Fri, 22 Apr 2011 23:20:28 +0000 (23:20 +0000)
(Descriptors::open): Use set_close_on_exec.
* output.cc (S_ISLNK): Define if not defined.

gold/ChangeLog
gold/descriptors.cc
gold/output.cc

index c4c02f66702c94bb4bcdf3200c4e4d20990dbb8a..d9da5f8062b42dba41010939bfc411f8b744e487 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-22  Vladimir Simonov  <sv@sw.ru>
+
+       * descriptors.cc (set_close_on_exec): New function.
+       (Descriptors::open): Use set_close_on_exec.
+       * output.cc (S_ISLNK): Define if not defined.
+
 2011-04-22 Cary Coutant  <ccoutant@google.com>
 
        * incremental.cc (Sized_incremental_binary::setup_readers): Allocate
index db8ad6753dea4b921a479e3b17e909e0308724ac..2ab0d5c8816306dd58d561bf69a08e47d0f6ef57 100644 (file)
@@ -1,6 +1,6 @@
 // descriptors.cc -- manage file descriptors for gold
 
-// Copyright 2008, 2009 Free Software Foundation, Inc.
+// Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
 #include "descriptors.h"
 #include "binary-io.h"
 
+// O_CLOEXEC is only available on newer systems.
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+
 // Very old systems may not define FD_CLOEXEC.
 #ifndef FD_CLOEXEC
 #define FD_CLOEXEC 1
 #endif
 
-// O_CLOEXEC is only available on newer systems.
-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0
+static inline void
+set_close_on_exec(int fd)
+{
+// Mingw does not define F_SETFD.
+#ifdef F_SETFD
+  fcntl(fd, F_SETFD, FD_CLOEXEC);
 #endif
+}
 
 namespace gold
 {
@@ -133,7 +142,7 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
          if (O_CLOEXEC == 0
              && parameters->options_valid()
              && parameters->options().has_plugins())
-           fcntl(new_descriptor, F_SETFD, FD_CLOEXEC);
+           set_close_on_exec(new_descriptor);
 
          {
            Hold_optional_lock hl(this->lock_);
index 26f843c60d3af03b1c4094e0996f44241c41159c..70379bbce7fdd13e09da27d1cfc01767187ea427 100644 (file)
@@ -121,6 +121,11 @@ posix_fallocate(int o, off_t offset, off_t len)
 }
 #endif // !defined(HAVE_POSIX_FALLOCATE)
 
+// Mingw does not have S_ISLNK.
+#ifndef S_ISLNK
+# define S_ISLNK(mode) 0
+#endif
+
 namespace gold
 {
 
This page took 0.033636 seconds and 4 git commands to generate.