summaryrefslogtreecommitdiff
path: root/lib/libpthread/uthread/uthread_cond.c
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-08-21 19:24:54 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-08-21 19:24:54 +0000
commit16d25a545116e8f7dfac9140d654821d417a8eba (patch)
tree3f00c8ca19e17cde8d276fc02cb5f85fa1d8e5f3 /lib/libpthread/uthread/uthread_cond.c
parent3cfb4c4b00852105397632dba44ff455c6e1cb8f (diff)
Start syncing with FreeBSD:
o Implement _get_curthread() and _set_curthread(). Use it where possible. o Add missing _thread_[enter|leave]_cancellation_point(). o Add a couple of not yet used vars to pthread_private.h. o Remove return's from void functions. This is by no means complete, but instead of doing a big commit, i'll split it in small ones, minimizing diffs.
Diffstat (limited to 'lib/libpthread/uthread/uthread_cond.c')
-rw-r--r--lib/libpthread/uthread/uthread_cond.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/libpthread/uthread/uthread_cond.c b/lib/libpthread/uthread/uthread_cond.c
index 1991bb472c8..48ee72a6b2f 100644
--- a/lib/libpthread/uthread/uthread_cond.c
+++ b/lib/libpthread/uthread/uthread_cond.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_cond.c,v 1.9 2000/01/06 07:14:47 d Exp $ */
+/* $OpenBSD: uthread_cond.c,v 1.10 2001/08/21 19:24:53 fgsch Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -158,6 +158,7 @@ pthread_cond_destroy(pthread_cond_t * cond)
int
pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
{
+ struct pthread *curthread = _get_curthread();
int rval = 0;
/* This is a cancellation point: */
@@ -197,19 +198,19 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
rval = EINVAL;
} else {
/* Reset the timeout flag: */
- _thread_run->timeout = 0;
+ curthread->timeout = 0;
/*
* Queue the running thread for the condition
* variable:
*/
- cond_queue_enq(*cond, _thread_run);
+ cond_queue_enq(*cond, curthread);
/* Remember the mutex that is being used: */
(*cond)->c_mutex = *mutex;
/* Wait forever: */
- _thread_run->wakeup_time.tv_sec = -1;
+ curthread->wakeup_time.tv_sec = -1;
/* Unlock the mutex: */
if ((rval = _mutex_cv_unlock(mutex)) != 0) {
@@ -218,7 +219,7 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
* the running thread from the condition
* variable queue:
*/
- cond_queue_remove(*cond, _thread_run);
+ cond_queue_remove(*cond, curthread);
/* Check for no more waiters: */
if (TAILQ_FIRST(&(*cond)->c_queue) ==
@@ -264,6 +265,7 @@ int
pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
const struct timespec * abstime)
{
+ struct pthread *curthread = _get_curthread();
int rval = 0;
/* This is a cancellation point: */
@@ -307,19 +309,19 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
_SPINUNLOCK(&(*cond)->lock);
} else {
/* Set the wakeup time: */
- _thread_run->wakeup_time.tv_sec =
+ curthread->wakeup_time.tv_sec =
abstime->tv_sec;
- _thread_run->wakeup_time.tv_nsec =
+ curthread->wakeup_time.tv_nsec =
abstime->tv_nsec;
/* Reset the timeout flag: */
- _thread_run->timeout = 0;
+ curthread->timeout = 0;
/*
* Queue the running thread for the condition
* variable:
*/
- cond_queue_enq(*cond, _thread_run);
+ cond_queue_enq(*cond, curthread);
/* Remember the mutex that is being used: */
(*cond)->c_mutex = *mutex;
@@ -331,7 +333,7 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
* the running thread from the condition
* variable queue:
*/
- cond_queue_remove(*cond, _thread_run);
+ cond_queue_remove(*cond, curthread);
/* Check for no more waiters: */
if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
@@ -348,7 +350,7 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
&(*cond)->lock, __FILE__, __LINE__);
/* Check if the wait timedout: */
- if (_thread_run->timeout == 0) {
+ if (curthread->timeout == 0) {
/* Lock the mutex: */
rval = _mutex_cv_lock(mutex);
}
@@ -362,7 +364,7 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
* variable queue:
*/
cond_queue_remove(*cond,
- _thread_run);
+ curthread);
/* Check for no more waiters: */
if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)