* 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.
This commit is contained in:
Thomas Pfaff 2003-04-17 19:57:01 +00:00
parent 62b0142655
commit a4cea44072
3 changed files with 19 additions and 8 deletions

View File

@ -1,3 +1,9 @@
2003-04-17 Thomas Pfaff <tpfaff@gmx.net>
* 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 <cgf@redhat.com> 2003-04-15 Christopher Faylor <cgf@redhat.com>
* termios.cc (setspeed): New function. * termios.cc (setspeed): New function.

View File

@ -373,7 +373,7 @@ pthread::exit (void *value_ptr)
mutex.lock (); mutex.lock ();
// cleanup if thread is in detached state and not joined // cleanup if thread is in detached state and not joined
if (pthread_equal (joiner, thread)) if (equal (joiner, thread))
delete this; delete this;
else else
{ {
@ -404,7 +404,7 @@ pthread::cancel (void)
return 0; return 0;
} }
else if (pthread_equal (thread, self)) else if (equal (thread, self))
{ {
mutex.unlock (); mutex.unlock ();
cancel_self (); 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 * 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> pthread_mutex::mutexes; List<pthread_mutex> pthread_mutex::mutexes;
@ -1508,7 +1508,7 @@ pthread_mutex::_lock (pthread_t self)
if (InterlockedIncrement ((long *)&lock_counter) == 1) if (InterlockedIncrement ((long *)&lock_counter) == 1)
set_owner (self); 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); InterlockedDecrement ((long *) &lock_counter);
if (type == PTHREAD_MUTEX_RECURSIVE) if (type == PTHREAD_MUTEX_RECURSIVE)
@ -1532,7 +1532,7 @@ pthread_mutex::_trylock (pthread_t self)
if (InterlockedCompareExchange ((long *)&lock_counter, 1, 0 ) == 0) if (InterlockedCompareExchange ((long *)&lock_counter, 1, 0 ) == 0)
set_owner (self); 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 (); result = lock_recursive ();
else else
result = EBUSY; result = EBUSY;
@ -1543,7 +1543,7 @@ pthread_mutex::_trylock (pthread_t self)
int int
pthread_mutex::_unlock (pthread_t self) pthread_mutex::_unlock (pthread_t self)
{ {
if (!pthread_equal (owner, self)) if (!pthread::equal (owner, self))
return EPERM; return EPERM;
if (--recursion_counter == 0) if (--recursion_counter == 0)
@ -2139,7 +2139,7 @@ pthread::join (pthread_t *thread, void **return_val)
if (!is_good_object (thread)) if (!is_good_object (thread))
return ESRCH; return ESRCH;
if (pthread_equal (*thread,joiner)) if (equal (*thread,joiner))
return EDEADLK; return EDEADLK;
(*thread)->mutex.lock (); (*thread)->mutex.lock ();
@ -2765,7 +2765,7 @@ pthread_sigmask (int operation, const sigset_t *set, sigset_t *old_set)
extern "C" int extern "C" int
pthread_equal (pthread_t t1, pthread_t t2) pthread_equal (pthread_t t1, pthread_t t2)
{ {
return t1 == t2; return pthread::equal (t1, t2);
} }
/* Mutexes */ /* Mutexes */

View File

@ -438,6 +438,11 @@ public:
virtual unsigned long getsequence_np(); virtual unsigned long getsequence_np();
static int equal (pthread_t t1, pthread_t t2)
{
return t1 == t2;
}
private: private:
DWORD thread_id; DWORD thread_id;
__pthread_cleanup_handler *cleanup_stack; __pthread_cleanup_handler *cleanup_stack;