diff options
author | David Xu <davidxu@FreeBSD.org> | 2012-02-27 13:38:52 +0000 |
---|---|---|
committer | David Xu <davidxu@FreeBSD.org> | 2012-02-27 13:38:52 +0000 |
commit | 24c209494ac3278b4a16f6a490ac8029b353e760 (patch) | |
tree | 9e46c0856016e3264151a062bf52ebb933fca926 /lib/libthr/thread/thr_umtx.c | |
parent | 36acfc6507aa0b7b905b746aec19671e3ca6ae50 (diff) | |
download | src-24c209494ac3278b4a16f6a490ac8029b353e760.tar.gz src-24c209494ac3278b4a16f6a490ac8029b353e760.zip |
Follow changes made in revision 232144, pass absolute timeout to kernel,
this eliminates a clock_gettime() syscall.
Notes
Notes:
svn path=/head/; revision=232209
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 38c3b042b2af..f32596f6eafd 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 |