aboutsummaryrefslogtreecommitdiff
path: root/gold/target-select.h
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/target-select.h
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/target-select.h')
-rw-r--r--gold/target-select.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/gold/target-select.h b/gold/target-select.h
index b0b1d92..d1cd44f 100644
--- a/gold/target-select.h
+++ b/gold/target-select.h
@@ -25,6 +25,8 @@
#include <vector>
+#include "gold-threads.h"
+
namespace gold
{
@@ -136,12 +138,7 @@ class Target_selector
// Instantiate the target and return it.
Target*
- instantiate_target()
- {
- if (this->instantiated_target_ == NULL)
- this->instantiated_target_ = this->do_instantiate_target();
- return this->instantiated_target_;
- }
+ instantiate_target();
private:
// ELF machine code.
@@ -157,6 +154,11 @@ class Target_selector
// The singleton Target structure--this points to an instance of the
// real implementation.
Target* instantiated_target_;
+ // Lock to make sure that we don't instantiate the target more than
+ // once.
+ Lock* lock_;
+ // We only want to initialize the lock_ pointer once.
+ Initialize_lock initialize_lock_;
};
// Select the target for an ELF file.