aboutsummaryrefslogtreecommitdiff
path: root/gold/descriptors.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2009-03-24 04:50:32 +0000
committerIan Lance Taylor <ian@airs.com>2009-03-24 04:50:32 +0000
commit7f055c204a4371154123a1816fbec9855ee60ad5 (patch)
tree847b6ee09451800cc64d2f3fd933daf82f3a699b /gold/descriptors.cc
parentc39465150b2129c17f0a520d91dad23cc0632694 (diff)
downloadgdb-7f055c204a4371154123a1816fbec9855ee60ad5.zip
gdb-7f055c204a4371154123a1816fbec9855ee60ad5.tar.gz
gdb-7f055c204a4371154123a1816fbec9855ee60ad5.tar.bz2
2009-03-23 Ian Lance Taylor <iant@google.com>
* gold-threads.h (class Initialize_lock): Define. * gold-threads.cc (class Initialize_lock_once): Define. (initialize_lock_control): New static variable. (initialize_lock_pointer): New static variable. (initialize_lock_once): New static function. (Initialize_lock::Initialize_lock): Define. (Initialize_lock::initialize): Define. * target-select.h: Include "gold-threads.h". (class Target_selector): Add lock_ and initialize_lock_ fields. Don't define instantiate_target, just declare it. * target-select.cc (Target_selector::Target_selector): Initialize new fields. (Target_selector::instantiate_target): Define. * descriptors.h: Include "gold-threads.h". (class Descriptors): Add initialize_lock_ field. * descriptors.cc (Descriptors::Descriptors): Initialize new field. (Descriptors::open): Use initialize_lock_ field * errors.h (class Errors): Add initialize_lock_ field. * errors.cc (Errors::Errors): Initialize new field. (Errors::initialize_lock): Use initialize_lock_ field. * powerpc.cc (class Target_selector_powerpc): Remove instantiated_target_ field. In do_recognize call instantiate_target rather than do_instantiate_target. In do_instantiate_target just allocate a new target. * sparc.cc (class Target_selector_sparc): Likewise.
Diffstat (limited to 'gold/descriptors.cc')
-rw-r--r--gold/descriptors.cc14
1 files changed, 5 insertions, 9 deletions
diff --git a/gold/descriptors.cc b/gold/descriptors.cc
index b05bdf1..3d059e2 100644
--- a/gold/descriptors.cc
+++ b/gold/descriptors.cc
@@ -51,8 +51,8 @@ namespace gold
// adjusted downward if we run out of file descriptors.
Descriptors::Descriptors()
- : lock_(NULL), open_descriptors_(), stack_top_(-1), current_(0),
- limit_(8192 - 16)
+ : lock_(NULL), initialize_lock_(&this->lock_), open_descriptors_(),
+ stack_top_(-1), current_(0), limit_(8192 - 16)
{
this->open_descriptors_.reserve(128);
}
@@ -66,13 +66,9 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
// initialize a Lock until we have parsed the options to find out
// whether we are running with threads. We can be called before
// options are valid when reading a linker script.
- if (this->lock_ == NULL)
- {
- if (parameters->options_valid())
- this->lock_ = new Lock();
- else
- gold_assert(descriptor < 0);
- }
+ bool lock_initialized = this->initialize_lock_.initialize();
+
+ gold_assert(lock_initialized || descriptor < 0);
if (descriptor >= 0)
{