diff options
author | Chris Hall <GMCH@hestia.halldom.com> | 2010-04-06 02:10:30 +0100 |
---|---|---|
committer | Chris Hall <GMCH@hestia.halldom.com> | 2010-04-06 02:10:30 +0100 |
commit | 8fea5ca7104c0d95108947661a4991b61b2ee06e (patch) | |
tree | 7ad44a658a61d4a8dfb43ca5b6122c5626f68ea0 /lib/qpthreads.h | |
parent | c933cf7233f51f677ab01689f175ceb3dc5361f6 (diff) | |
download | quagga-8fea5ca7104c0d95108947661a4991b61b2ee06e.tar.bz2 quagga-8fea5ca7104c0d95108947661a4991b61b2ee06e.tar.xz |
First beta release
Various bug fixes and improvements.
Running with a fair amount of debug/assert code, which must be
removed at some date.
Diffstat (limited to 'lib/qpthreads.h')
-rw-r--r-- | lib/qpthreads.h | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/qpthreads.h b/lib/qpthreads.h index 4d71e12d..d73182ef 100644 --- a/lib/qpthreads.h +++ b/lib/qpthreads.h @@ -27,6 +27,7 @@ #include <pthread.h> #include <unistd.h> #include <errno.h> +#include <stdbool.h> #include "zassert.h" #include "qtime.h" @@ -142,20 +143,30 @@ private int qpt_freeze_qpthreads_enabled(void) ; /* get and freeze qpthreads_enabled */ /*============================================================================== - * Thread self knowledge -- returns 'NULL' if !qpthreads_enabled + * Thread self knowledge -- even when !qpthreads_enabled there is one thread */ Inline qpt_thread_t qpt_thread_self(void) { - return qpthreads_enabled ? pthread_self() : (qpt_thread_t)NULL; + return pthread_self() ; } ; -/*============================================================================== - * Thread equality -- returns non-zero (true) if threads are *equal* - * -- all threads are equal if !qpthreads_enabled +/*------------------------------------------------------------------------------ + * Thread equality -- returns true iff threads are *equal* + * -- even when !qpthreads_enabled there is one thread + */ +Inline bool qpt_threads_equal(qpt_thread_t a_id, qpt_thread_t b_id) +{ + return pthread_equal(a_id, b_id) != 0 ; +} ; + +/*------------------------------------------------------------------------------ + * Thread identity -- returns true iff current thread is the given thread + * -- even when !qpthreads_enabled there is one thread */ -Inline int qpt_threads_equal(qpt_thread_t a, qpt_thread_t b) +Inline bool qpt_thread_is_self(qpt_thread_t id) { - return !qpthreads_enabled || pthread_equal(a, b) ? 1 : 0 ; + pthread_t self = pthread_self() ; + return pthread_equal(self, id) != 0 ; } ; /*============================================================================== |