aboutsummaryrefslogtreecommitdiff
path: root/gold/gold-threads.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/gold-threads.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/gold-threads.h')
-rw-r--r--gold/gold-threads.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/gold/gold-threads.h b/gold/gold-threads.h
index c901e42..9c49b57 100644
--- a/gold/gold-threads.h
+++ b/gold/gold-threads.h
@@ -35,6 +35,7 @@ namespace gold
{
class Condvar;
+class Initialize_lock_once;
// The interface for the implementation of a Lock.
@@ -190,6 +191,33 @@ class Condvar
Condvar_impl* condvar_;
};
+// A class used to initialize a lock exactly once, after the options
+// have been read. This is needed because the implementation of locks
+// depends on whether we've seen the --threads option. Before the
+// options have been read, we know we are single-threaded, so we can
+// get by without using a lock. This class should be an instance
+// variable of the class which has a lock which needs to be
+// initialized.
+
+class Initialize_lock
+{
+ public:
+ // The class which uses this will have a pointer to a lock. This
+ // must be constructed with a pointer to that pointer.
+ Initialize_lock(Lock** pplock);
+
+ // Initialize the lock. Return true if the lock is now initialized,
+ // false if it is not (because the options have not yet been read).
+ bool
+ initialize();
+
+ private:
+ // A pointer to the lock pointer which must be initialized.
+ Lock** const pplock_;
+ // If needed, a pointer to a pthread_once_t structure.
+ Initialize_lock_once* once_;
+};
+
} // End namespace gold.
#endif // !defined(GOLD_THREADS_H)