diff options
author | davidxu <davidxu@FreeBSD.org> | 2012-02-27 13:38:52 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2012-02-27 13:38:52 +0000 |
commit | 96aacc2279b7b65fc0c8ff707abe3d020c1e8378 (patch) | |
tree | 9e46c0856016e3264151a062bf52ebb933fca926 /lib/libthr/thread/thr_umtx.c | |
parent | 8a35bc6c4fda7b720a969d6cb7122d1667a826d5 (diff) | |
download | FreeBSD-src-96aacc2279b7b65fc0c8ff707abe3d020c1e8378.zip FreeBSD-src-96aacc2279b7b65fc0c8ff707abe3d020c1e8378.tar.gz |
Follow changes made in revision 232144, pass absolute timeout to kernel,
this eliminates a clock_gettime() syscall.
Diffstat (limited to 'lib/libthr/thread/thr_umtx.c')
-rw-r--r-- | lib/libthr/thread/thr_umtx.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/lib/libthr/thread/thr_umtx.c b/lib/libthr/thread/thr_umtx.c index 38c3b04..f32596f 100644 --- a/lib/libthr/thread/thr_umtx.c +++ b/lib/libthr/thread/thr_umtx.c @@ -265,15 +265,42 @@ _thr_ucond_broadcast(struct ucond *cv) } int -__thr_rwlock_rdlock(struct urwlock *rwlock, int flags, struct timespec *tsp) +__thr_rwlock_rdlock(struct urwlock *rwlock, int flags, + const struct timespec *tsp) { - return _umtx_op_err(rwlock, UMTX_OP_RW_RDLOCK, flags, NULL, tsp); + struct _umtx_time timeout, *tm_p; + size_t tm_size; + + if (tsp == NULL) { + tm_p = NULL; + tm_size = 0; + } else { + timeout._timeout = *tsp; + timeout._flags = UMTX_ABSTIME; + timeout._clockid = CLOCK_REALTIME; + tm_p = &timeout; + tm_size = sizeof(timeout); + } + return _umtx_op_err(rwlock, UMTX_OP_RW_RDLOCK, flags, (void *)tm_size, tm_p); } int -__thr_rwlock_wrlock(struct urwlock *rwlock, struct timespec *tsp) +__thr_rwlock_wrlock(struct urwlock *rwlock, const struct timespec *tsp) { - return _umtx_op_err(rwlock, UMTX_OP_RW_WRLOCK, 0, NULL, tsp); + struct _umtx_time timeout, *tm_p; + size_t tm_size; + + if (tsp == NULL) { + tm_p = NULL; + tm_size = 0; + } else { + timeout._timeout = *tsp; + timeout._flags = UMTX_ABSTIME; + timeout._clockid = CLOCK_REALTIME; + tm_p = &timeout; + tm_size = sizeof(timeout); + } + return _umtx_op_err(rwlock, UMTX_OP_RW_WRLOCK, 0, (void *)tm_size, tm_p); } int |