summaryrefslogtreecommitdiffstats
path: root/lib/librthread/rthread_sched.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2011-12-28 04:59:31 +0000
committerguenther <guenther@openbsd.org>2011-12-28 04:59:31 +0000
commit1bbb51b7c7b26224d8ceef9e36ec869b4343a38f (patch)
tree7d68c44d9d21a8e168f82264b923916c422d221c /lib/librthread/rthread_sched.c
parentThese utilities were already part of 1BSD, and some authors are known. (diff)
downloadwireguard-openbsd-1bbb51b7c7b26224d8ceef9e36ec869b4343a38f.tar.xz
wireguard-openbsd-1bbb51b7c7b26224d8ceef9e36ec869b4343a38f.zip
pthread_self() may be much cheaper and never more expensive than getthrid()
so prefer it for identifying the current thread
Diffstat (limited to 'lib/librthread/rthread_sched.c')
-rw-r--r--lib/librthread/rthread_sched.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/librthread/rthread_sched.c b/lib/librthread/rthread_sched.c
index c11c369ae2a..25e4b4c804e 100644
--- a/lib/librthread/rthread_sched.c
+++ b/lib/librthread/rthread_sched.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_sched.c,v 1.8 2011/11/06 11:48:59 guenther Exp $ */
+/* $OpenBSD: rthread_sched.c,v 1.9 2011/12/28 04:59:31 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -123,13 +123,13 @@ pthread_suspend_np(pthread_t thread)
{
int errn = 0;
- if (thread->tid == getthrid())
+ if (thread == pthread_self())
return (EDEADLK);
/*
* XXX Avoid a bug in current signal handling by refusing to
* suspend the main thread.
*/
- if (thread->tid != _initial_thread.tid)
+ if (thread != &_initial_thread)
if (kill(thread->tid, SIGSTOP) == -1)
errn = errno;
return (errn);
@@ -139,11 +139,11 @@ void
pthread_suspend_all_np(void)
{
pthread_t t;
- pid_t me = getthrid();
+ pthread_t self = pthread_self();
_spinlock(&_thread_lock);
LIST_FOREACH(t, &_thread_list, threads)
- if (t->tid != me)
+ if (t != self)
pthread_suspend_np(t);
_spinunlock(&_thread_lock);
}
@@ -163,11 +163,11 @@ void
pthread_resume_all_np(void)
{
pthread_t t;
- pid_t me = getthrid();
+ pthread_t self = pthread_self();
_spinlock(&_thread_lock);
LIST_FOREACH(t, &_thread_list, threads)
- if (t->tid != me)
+ if (t != self)
pthread_resume_np(t);
_spinunlock(&_thread_lock);
}