From 20f77eda55f874b939719ac0abda4405ecd20bf8 Mon Sep 17 00:00:00 2001 From: rpj Date: Mon, 18 Jan 1999 23:50:07 +0000 Subject: Tue Jan 19 18:27:42 1999 Ross Johnson * pthread.h (pthreadCancelableTimedWait): New prototype. (pthreadCancelableWait): Remove second argument. * misc.c (CancelableWait): New static function is pthreadCancelableWait() renamed. (pthreadCancelableWait): Now just calls CancelableWait() with INFINITE timeout. (pthreadCancelableTimedWait): Just calls CancelableWait() with passed in timeout. * private.c (_pthread_sem_timedwait): 'abstime' arg really is absolute time. Calculate relative time to wait from current time before passing timeout to new routine pthreadCancelableTimedWait(). - Scott Lightner --- misc.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'misc.c') diff --git a/misc.c b/misc.c index d6c4b2f..49a71dd 100644 --- a/misc.c +++ b/misc.c @@ -129,8 +129,8 @@ pthread_equal (pthread_t t1, pthread_t t2) } /* pthread_equal */ -int -pthreadCancelableWait (HANDLE waitHandle, DWORD abstime) +static int +CancelableWait (HANDLE waitHandle, DWORD timeout) /* * ------------------------------------------------------------------- * This provides an extra hook into the pthread_cancel @@ -151,7 +151,6 @@ pthreadCancelableWait (HANDLE waitHandle, DWORD abstime) DWORD nHandles = 1; DWORD status; - handles[0] = waitHandle; if ((self = pthread_getspecific (_pthread_selfThreadKey)) != NULL) @@ -177,7 +176,7 @@ pthreadCancelableWait (HANDLE waitHandle, DWORD abstime) nHandles, handles, FALSE, - abstime); + timeout); if (status == WAIT_FAILED) @@ -185,10 +184,13 @@ pthreadCancelableWait (HANDLE waitHandle, DWORD abstime) result = EINVAL; } - else if (status == WAIT_ABANDONED_0) + else if (status == WAIT_TIMEOUT) { result = ETIMEDOUT; - + } + else if (status == WAIT_ABANDONED_0) + { + result = EINVAL; } else { @@ -243,6 +245,17 @@ pthreadCancelableWait (HANDLE waitHandle, DWORD abstime) } /* pthreadCancelableWait */ +int +pthreadCancelableWait (HANDLE waitHandle) +{ + return (CancelableWait(waitHandle, INFINITE)); +} + +int +pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout) +{ + return (CancelableWait(waitHandle, timeout)); +} /* */ -- cgit v1.2.3