summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2012-02-22 03:22:49 +0000
committerdavidxu <davidxu@FreeBSD.org>2012-02-22 03:22:49 +0000
commitd177303078ee8f6069218009d6c3c2b6d9d9ca97 (patch)
tree243668cadaadb4cb39ffc1650b45f200ef00ac6c /lib/libthr
parent1ec5baaef2e3798db4f06efbac2ca27d4d5506a5 (diff)
downloadFreeBSD-src-d177303078ee8f6069218009d6c3c2b6d9d9ca97.zip
FreeBSD-src-d177303078ee8f6069218009d6c3c2b6d9d9ca97.tar.gz
Use unused fourth argument of umtx_op to pass flags to kernel for operation
UMTX_OP_WAIT. Upper 16bits is enough to hold a clock id, and lower 16bits is used to pass flags. The change saves a clock_gettime() syscall from libthr.
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_umtx.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/libthr/thread/thr_umtx.c b/lib/libthr/thread/thr_umtx.c
index 0a8f861..f7acac3 100644
--- a/lib/libthr/thread/thr_umtx.c
+++ b/lib/libthr/thread/thr_umtx.c
@@ -200,20 +200,10 @@ int
_thr_umtx_timedwait_uint(volatile u_int *mtx, u_int id, int clockid,
const struct timespec *abstime, int shared)
{
- struct timespec ts, ts2, *tsp;
-
- if (abstime != NULL) {
- clock_gettime(clockid, &ts);
- TIMESPEC_SUB(&ts2, abstime, &ts);
- if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0))
- return (ETIMEDOUT);
- tsp = &ts2;
- } else {
- tsp = NULL;
- }
return _umtx_op_err(__DEVOLATILE(void *, mtx),
- shared ? UMTX_OP_WAIT_UINT : UMTX_OP_WAIT_UINT_PRIVATE, id, NULL,
- tsp);
+ shared ? UMTX_OP_WAIT_UINT : UMTX_OP_WAIT_UINT_PRIVATE, id,
+ abstime != NULL ? (void *)(uintptr_t)((clockid << 16) | UMTX_WAIT_ABSTIME) : 0,
+ __DECONST(void *, abstime));
}
int
OpenPOWER on IntegriCloud