From 78512507da6c426b0e469f2763005ddda4484261 Mon Sep 17 00:00:00 2001 From: tpfaff Date: Thu, 17 Apr 2003 19:57:00 +0000 Subject: [PATCH] * thread.h (pthread::equal): New static method. * thread.cc: Rename pthread_equal to pthread::equal throughout. (pthread_equal): Use pthread::equal to compare threads ids. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/thread.cc | 16 ++++++++-------- winsup/cygwin/thread.h | 5 +++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 49498f3cb5..f13513b5c1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2003-04-17 Thomas Pfaff + + * thread.h (pthread::equal): New static method. + * thread.cc: Rename pthread_equal to pthread::equal throughout. + (pthread_equal): Use pthread::equal to compare threads ids. + 2003-04-15 Christopher Faylor * termios.cc (setspeed): New function. diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 5f0917ad66..de5392f844 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -373,7 +373,7 @@ pthread::exit (void *value_ptr) mutex.lock (); // cleanup if thread is in detached state and not joined - if (pthread_equal (joiner, thread)) + if (equal (joiner, thread)) delete this; else { @@ -404,7 +404,7 @@ pthread::cancel (void) return 0; } - else if (pthread_equal (thread, self)) + else if (equal (thread, self)) { mutex.unlock (); cancel_self (); @@ -1446,7 +1446,7 @@ pthread_mutex::can_be_unlocked (pthread_mutex_t const *mutex) /* * Check if the mutex is owned by the current thread and can be unlocked */ - return ((*mutex)->recursion_counter == 1 && pthread_equal ((*mutex)->owner, self)); + return ((*mutex)->recursion_counter == 1 && pthread::equal ((*mutex)->owner, self)); } List pthread_mutex::mutexes; @@ -1508,7 +1508,7 @@ pthread_mutex::_lock (pthread_t self) if (InterlockedIncrement ((long *)&lock_counter) == 1) set_owner (self); - else if (type != PTHREAD_MUTEX_NORMAL && pthread_equal (owner, self)) + else if (type != PTHREAD_MUTEX_NORMAL && pthread::equal (owner, self)) { InterlockedDecrement ((long *) &lock_counter); if (type == PTHREAD_MUTEX_RECURSIVE) @@ -1532,7 +1532,7 @@ pthread_mutex::_trylock (pthread_t self) if (InterlockedCompareExchange ((long *)&lock_counter, 1, 0 ) == 0) set_owner (self); - else if (type == PTHREAD_MUTEX_RECURSIVE && pthread_equal (owner, self)) + else if (type == PTHREAD_MUTEX_RECURSIVE && pthread::equal (owner, self)) result = lock_recursive (); else result = EBUSY; @@ -1543,7 +1543,7 @@ pthread_mutex::_trylock (pthread_t self) int pthread_mutex::_unlock (pthread_t self) { - if (!pthread_equal (owner, self)) + if (!pthread::equal (owner, self)) return EPERM; if (--recursion_counter == 0) @@ -2139,7 +2139,7 @@ pthread::join (pthread_t *thread, void **return_val) if (!is_good_object (thread)) return ESRCH; - if (pthread_equal (*thread,joiner)) + if (equal (*thread,joiner)) return EDEADLK; (*thread)->mutex.lock (); @@ -2765,7 +2765,7 @@ pthread_sigmask (int operation, const sigset_t *set, sigset_t *old_set) extern "C" int pthread_equal (pthread_t t1, pthread_t t2) { - return t1 == t2; + return pthread::equal (t1, t2); } /* Mutexes */ diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index 121d35af9e..e162b32a04 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -438,6 +438,11 @@ public: virtual unsigned long getsequence_np(); + static int equal (pthread_t t1, pthread_t t2) + { + return t1 == t2; + } + private: DWORD thread_id; __pthread_cleanup_handler *cleanup_stack; -- 2.11.0