opcodes/
[deliverable/binutils-gdb.git] / gold / descriptors.cc
index f3f071e32b269feac69082f15c85f580ce0146f0..b7fbaa61deb922579a5e84cf42be2e797ae31ae8 100644 (file)
@@ -1,6 +1,6 @@
 // descriptors.cc -- manage file descriptors for gold
 
-// Copyright 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+// Copyright 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -251,6 +251,28 @@ Descriptors::close_some_descriptor()
   return false;
 }
 
+// Close all the descriptors open for reading.
+
+void
+Descriptors::close_all()
+{
+  Hold_optional_lock hl(this->lock_);
+
+  for (size_t i = 0; i < this->open_descriptors_.size(); i++)
+    {
+      Open_descriptor* pod = &this->open_descriptors_[i];
+      if (pod->name != NULL && !pod->inuse && !pod->is_write)
+       {
+         if (::close(i) < 0)
+           gold_warning(_("while closing %s: %s"), pod->name, strerror(errno));
+         pod->name = NULL;
+         pod->stack_next = -1;
+         pod->is_on_stack = false;
+       }
+    }
+  this->stack_top_ = -1;
+}
+
 // The single global variable which manages descriptors.
 
 Descriptors descriptors;
This page took 0.023141 seconds and 4 git commands to generate.