diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2013-02-07 13:27:27 +0100 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2013-02-07 13:27:27 +0100 |
commit | 7585facf05d927eb6df3929ce09ed5e60d905437 (patch) | |
tree | e4d14b4dc180db20356b6b01ce0112f3a2d7897e /src/libstrongswan/threading | |
parent | c1343b3278cdf99533b7902744d15969f9d6fdc1 (diff) | |
download | vyos-strongswan-7585facf05d927eb6df3929ce09ed5e60d905437.tar.gz vyos-strongswan-7585facf05d927eb6df3929ce09ed5e60d905437.zip |
Imported Upstream version 5.0.2
Diffstat (limited to 'src/libstrongswan/threading')
-rw-r--r-- | src/libstrongswan/threading/mutex.c | 10 | ||||
-rw-r--r-- | src/libstrongswan/threading/rwlock.c | 9 | ||||
-rw-r--r-- | src/libstrongswan/threading/spinlock.c | 24 | ||||
-rw-r--r-- | src/libstrongswan/threading/thread.c | 4 |
4 files changed, 14 insertions, 33 deletions
diff --git a/src/libstrongswan/threading/mutex.c b/src/libstrongswan/threading/mutex.c index 2ef918a28..f86e781c5 100644 --- a/src/libstrongswan/threading/mutex.c +++ b/src/libstrongswan/threading/mutex.c @@ -21,7 +21,7 @@ #include <errno.h> #include <library.h> -#include <debug.h> +#include <utils/debug.h> #include "condvar.h" #include "mutex.h" @@ -282,13 +282,7 @@ METHOD(condvar_t, timed_wait, bool, ms = timeout % 1000; tv.tv_sec += s; - tv.tv_usec += ms * 1000; - - if (tv.tv_usec > 1000000 /* 1s */) - { - tv.tv_usec -= 1000000; - tv.tv_sec++; - } + timeval_add_ms(&tv, ms); return timed_wait_abs(this, mutex, tv); } diff --git a/src/libstrongswan/threading/rwlock.c b/src/libstrongswan/threading/rwlock.c index 7097a8e8c..176445705 100644 --- a/src/libstrongswan/threading/rwlock.c +++ b/src/libstrongswan/threading/rwlock.c @@ -18,7 +18,7 @@ #include <pthread.h> #include <library.h> -#include <debug.h> +#include <utils/debug.h> #include "rwlock.h" #include "rwlock_condvar.h" @@ -433,13 +433,8 @@ METHOD(rwlock_condvar_t, timed_wait, bool, ms = timeout % 1000; tv.tv_sec += s; - tv.tv_usec += ms * 1000; + timeval_add_ms(&tv, ms); - if (tv.tv_usec > 1000000 /* 1s */) - { - tv.tv_usec -= 1000000; - tv.tv_sec++; - } return timed_wait_abs(this, lock, tv); } diff --git a/src/libstrongswan/threading/spinlock.c b/src/libstrongswan/threading/spinlock.c index 812cf696b..a0de02ce5 100644 --- a/src/libstrongswan/threading/spinlock.c +++ b/src/libstrongswan/threading/spinlock.c @@ -13,20 +13,15 @@ * for more details. */ -#include <unistd.h> /* for _POSIX_SPIN_LOCKS */ #include <pthread.h> #include <library.h> -#include <debug.h> +#include <utils/debug.h> #include "spinlock.h" #include "mutex.h" #include "lock_profiler.h" -#if defined(_POSIX_SPIN_LOCKS) && _POSIX_SPIN_LOCKS == -1 -#undef _POSIX_SPIN_LOCKS -#endif - typedef struct private_spinlock_t private_spinlock_t; /** @@ -39,7 +34,7 @@ struct private_spinlock_t { */ spinlock_t public; -#ifdef _POSIX_SPIN_LOCKS +#ifdef HAVE_PTHREAD_SPIN_INIT /** * wrapped pthread spin lock @@ -51,20 +46,20 @@ struct private_spinlock_t { */ lock_profile_t profile; -#else /* _POSIX_SPIN_LOCKS */ +#else /* HAVE_PTHREAD_SPIN_INIT */ /** * use a mutex if spin locks are not available */ mutex_t *mutex; -#endif /* _POSIX_SPIN_LOCKS */ +#endif /* HAVE_PTHREAD_SPIN_INIT */ }; METHOD(spinlock_t, lock, void, private_spinlock_t *this) { -#ifdef _POSIX_SPIN_LOCKS +#ifdef HAVE_PTHREAD_SPIN_INIT int err; profiler_start(&this->profile); @@ -82,7 +77,7 @@ METHOD(spinlock_t, lock, void, METHOD(spinlock_t, unlock, void, private_spinlock_t *this) { -#ifdef _POSIX_SPIN_LOCKS +#ifdef HAVE_PTHREAD_SPIN_INIT int err; err = pthread_spin_unlock(&this->spinlock); @@ -98,7 +93,7 @@ METHOD(spinlock_t, unlock, void, METHOD(spinlock_t, destroy, void, private_spinlock_t *this) { -#ifdef _POSIX_SPIN_LOCKS +#ifdef HAVE_PTHREAD_SPIN_INIT profiler_cleanup(&this->profile); pthread_spin_destroy(&this->spinlock); #else @@ -122,15 +117,12 @@ spinlock_t *spinlock_create() }, ); -#ifdef _POSIX_SPIN_LOCKS +#ifdef HAVE_PTHREAD_SPIN_INIT pthread_spin_init(&this->spinlock, PTHREAD_PROCESS_PRIVATE); profiler_init(&this->profile); #else - #warning Using mutexes as spin lock alternatives this->mutex = mutex_create(MUTEX_TYPE_DEFAULT); #endif return &this->public; } - - diff --git a/src/libstrongswan/threading/thread.c b/src/libstrongswan/threading/thread.c index 9ef514ebc..e524409c7 100644 --- a/src/libstrongswan/threading/thread.c +++ b/src/libstrongswan/threading/thread.c @@ -32,11 +32,11 @@ static inline pid_t gettid() #endif #include <library.h> -#include <debug.h> +#include <utils/debug.h> #include <threading/thread_value.h> #include <threading/mutex.h> -#include <utils/linked_list.h> +#include <collections/linked_list.h> #include "thread.h" |