diff options
author | Ian Lance Taylor <iant@google.com> | 2007-10-17 06:24:50 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-10-17 06:24:50 +0000 |
commit | fe9a4c1201a3e0867cbc0324c55cfe90dce9415b (patch) | |
tree | 1cfc4aa11a0b71f31000b3fb7abecc367dd52180 /gold/gold-threads.cc | |
parent | ae326da8ebcb14de70678bb726732a1c8923d63c (diff) | |
download | binutils-gdb-fe9a4c1201a3e0867cbc0324c55cfe90dce9415b.tar.gz |
Add infrastructure for threading support.
Diffstat (limited to 'gold/gold-threads.cc')
-rw-r--r-- | gold/gold-threads.cc | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/gold/gold-threads.cc b/gold/gold-threads.cc index ad9506cc994..396e6c10631 100644 --- a/gold/gold-threads.cc +++ b/gold/gold-threads.cc @@ -22,6 +22,9 @@ #include "gold.h" +#include <cerrno> +#include <cstring> + #ifdef ENABLE_THREADS #include <pthread.h> #endif @@ -63,37 +66,37 @@ Lock_impl::Lock_impl() { pthread_mutexattr_t attr; if (pthread_mutexattr_init(&attr) != 0) - gold_fatal(_("pthead_mutextattr_init failed"), true); + gold_fatal(_("pthead_mutextattr_init failed: %s"), strerror(errno)); #ifdef PTHREAD_MUTEXT_ADAPTIVE_NP if (pthread_mutextattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP) != 0) - gold_fatal(_("pthread_mutextattr_settype failed"), true); + gold_fatal(_("pthread_mutextattr_settype failed: %s"), strerror(errno)); #endif if (pthread_mutex_init (&this->mutex_, &attr) != 0) - gold_fatal(_("pthread_mutex_init failed"), true); + gold_fatal(_("pthread_mutex_init failed: %s"), strerror(errno)); if (pthread_mutexattr_destroy(&attr) != 0) - gold_fatal(_("pthread_mutexattr_destroy failed"), true); + gold_fatal(_("pthread_mutexattr_destroy failed: %s"), strerror(errno)); } Lock_impl::~Lock_impl() { if (pthread_mutex_destroy(&this->mutex_) != 0) - gold_fatal(_("pthread_mutex_destroy failed"), true); + gold_fatal(_("pthread_mutex_destroy failed: %s"), strerror(errno)); } void Lock_impl::acquire() { if (pthread_mutex_lock(&this->mutex_) != 0) - gold_fatal(_("pthread_mutex_lock failed"), true); + gold_fatal(_("pthread_mutex_lock failed: %s"), strerror(errno)); } void Lock_impl::release() { if (pthread_mutex_unlock(&this->mutex_) != 0) - gold_fatal(_("pthread_mutex_unlock failed"), true); + gold_fatal(_("pthread_mutex_unlock failed: %s"), strerror(errno)); } #else // !defined(ENABLE_THREADS) @@ -174,27 +177,27 @@ class Condvar_impl Condvar_impl::Condvar_impl() { if (pthread_cond_init(&this->cond_, NULL) != 0) - gold_fatal(_("pthread_cond_init failed"), true); + gold_fatal(_("pthread_cond_init failed: %s"), strerror(errno)); } Condvar_impl::~Condvar_impl() { if (pthread_cond_destroy(&this->cond_) != 0) - gold_fatal(_("pthread_cond_destroy failed"), true); + gold_fatal(_("pthread_cond_destroy failed: %s"), strerror(errno)); } void Condvar_impl::wait(Lock_impl* li) { if (pthread_cond_wait(&this->cond_, &li->mutex_) != 0) - gold_fatal(_("pthread_cond_wait failed"), true); + gold_fatal(_("pthread_cond_wait failed: %s"), strerror(errno)); } void Condvar_impl::signal() { if (pthread_cond_signal(&this->cond_) != 0) - gold_fatal(_("pthread_cond_signal failed"), true); + gold_fatal(_("pthread_cond_signal failed: %s"), strerror(errno)); } #else // !defined(ENABLE_THREADS) |