diff options
author | Ian Lance Taylor <ian@airs.com> | 2009-03-24 17:32:43 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2009-03-24 17:32:43 +0000 |
commit | 22fd9730a06b23ad93f31fed3377fcc51f3447df (patch) | |
tree | a10aa0539c5af876eb062af7f6a418ef8449a7cc /gold/target-select.cc | |
parent | 76a39ba7a1ba8d1ed51482ac5fb0091c98e02c2f (diff) | |
download | fsf-binutils-gdb-22fd9730a06b23ad93f31fed3377fcc51f3447df.zip fsf-binutils-gdb-22fd9730a06b23ad93f31fed3377fcc51f3447df.tar.gz fsf-binutils-gdb-22fd9730a06b23ad93f31fed3377fcc51f3447df.tar.bz2 |
* target-select.cc (instantiate_target): Don't acquire the lock if
the instantiated_target_ field has already been set.
Diffstat (limited to 'gold/target-select.cc')
-rw-r--r-- | gold/target-select.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/gold/target-select.cc b/gold/target-select.cc index 55d63b2..dcd3017 100644 --- a/gold/target-select.cc +++ b/gold/target-select.cc @@ -60,10 +60,15 @@ Target_selector::Target_selector(int machine, int size, bool is_big_endian, Target* Target_selector::instantiate_target() { - this->initialize_lock_.initialize(); - Hold_optional_lock hl(this->lock_); + // We assume that the pointer will either be written entirely or not + // at all. if (this->instantiated_target_ == NULL) - this->instantiated_target_ = this->do_instantiate_target(); + { + this->initialize_lock_.initialize(); + Hold_optional_lock hl(this->lock_); + if (this->instantiated_target_ == NULL) + this->instantiated_target_ = this->do_instantiate_target(); + } return this->instantiated_target_; } |