diff options
author | rpj <rpj> | 1999-01-16 17:34:53 +0000 |
---|---|---|
committer | rpj <rpj> | 1999-01-16 17:34:53 +0000 |
commit | 9b75468a10363ada39a17563cca6bcd819ec8fcd (patch) | |
tree | ea082f51c28cb761f109f9a407e54c5c4fe41bd2 /private.c | |
parent | 677bfb0881c56dad767a07b31ac543db284e16c6 (diff) |
Sun Jan 17 12:01:26 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>snapshot-1999-01-17
* private.c (_pthread_sem_timedwait): Move from semaphore.c.
* semaphore.c : Remove redundant #includes.
(_pthread_sem_timedwait): Move to private.c.
(sem_wait): Add missing abstime arg to pthreadCancelableWait() call.
1999-01-17 Ross Johnson <rpj@ise.canberra.edu.au>
* runtest: New script to build and run a test in the tests directory.
Diffstat (limited to 'private.c')
-rw-r--r-- | private.c | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -437,3 +437,63 @@ _pthread_callUserDestroyRoutines (pthread_t thread) /* </JEB> */ + +int +_pthread_sem_timedwait (sem_t * sem, const struct timespec * abstime) + /* + * ------------------------------------------------------ + * DOCPUBLIC + * This function waits on a semaphore for at most + * 'abstime'. + * + * PARAMETERS + * sem + * pointer to an instance of sem_t + * + * abstime + * pointer to an instance of struct timespec + * + * DESCRIPTION + * This function waits on a semaphore. If the + * semaphore value is greater than zero, it decreases + * its value by one. If the semaphore value is zero, then + * the calling thread (or process) is blocked until it can + * successfully decrease the value or until interrupted by + * a signal. + * + * If 'abstime' is a NULL pointer then this function will + * block until it can successfully decrease the value or + * until interrupted by a signal. + * + * RESULTS + * 0 successfully decreased semaphore, + * EINVAL 'sem' is not a valid semaphore, + * ENOSYS semaphores are not supported, + * EINTR the function was interrupted by a signal, + * EDEADLK a deadlock condition was detected. + * ETIMEDOUT abstime elapsed before success. + * + * ------------------------------------------------------ + */ +{ + DWORD msecs; + + if (abstime == NULL) + { + msecs = INFINITE; + } + else + { + /* Calculate the number of milliseconds in abstime. */ + msecs = abstime->tv_sec * 1000; + msecs += abstime->tv_nsec / 1000000; + } + + return ((sem == NULL) + ? EINVAL + : pthreadCancelableWait (*sem, msecs) + ); + +} /* _pthread_sem_timedwait */ + + |