// descriptors.h -- manage file descriptors for gold -*- C++ -*-
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright (C) 2008-2020 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
#include <vector>
+#include "gold-threads.h"
+
namespace gold
{
-class Lock;
-
// This class manages file descriptors for gold.
class Descriptors
void
release(int descriptor, bool permanent);
- // Claim the file descriptor DESCRIPTOR for a plugin. This effectively
- // removes the descriptor from the pool of linker-managed descriptors,
- // as the plugin will assume responsibility for closing it.
+ // Close all the descriptors open for reading.
void
- claim_for_plugin(int descriptor);
+ close_all();
private:
// Information kept for a descriptor.
bool inuse;
// Whether this is a write descriptor.
bool is_write;
- // Whether the descriptor has been claimed for a plugin.
- bool is_claimed;
+ // Whether the descriptor is on the stack.
+ bool is_on_stack;
};
bool
// We need to lock before accessing any fields.
Lock* lock_;
+ // Used to initialize the lock_ field exactly once.
+ Initialize_lock initialize_lock_;
// Information for descriptors.
std::vector<Open_descriptor> open_descriptors_;
// Top of stack.
{ descriptors.release(descriptor, permanent); }
inline void
-claim_descriptor_for_plugin(int descriptor)
-{ descriptors.claim_for_plugin(descriptor); }
+close_all_descriptors()
+{ descriptors.close_all(); }
} // End namespace gold.