diff options
author | davidxu <davidxu@FreeBSD.org> | 2005-01-18 13:53:10 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2005-01-18 13:53:10 +0000 |
commit | b3a53fc0e61db0db29d06418cb57c6714f273863 (patch) | |
tree | d9420e1af067a0e9da1eb384d1ace85f57b5d7c1 | |
parent | 7f3c7f0d461522fe0390e72d21fa729bed8807bf (diff) | |
download | FreeBSD-src-b3a53fc0e61db0db29d06418cb57c6714f273863.zip FreeBSD-src-b3a53fc0e61db0db29d06418cb57c6714f273863.tar.gz |
Revert my previous errno hack, that is certainly an issue,
and always has been, but the system call itself returns
errno in a register so the problem is really a function of
libc, not the system call.
Discussed with : Matthew Dillion <dillon@apollo.backplane.com>
-rw-r--r-- | sys/kern/kern_umtx.c | 3 | ||||
-rw-r--r-- | sys/sys/umtx.h | 17 |
2 files changed, 13 insertions, 7 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 1e93a66..31a5cb1 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -756,6 +756,5 @@ _umtx_op(struct thread *td, struct _umtx_op_args *uap) error = EINVAL; break; } - td->td_retval[0] = -error; - return (0); + return (error); } diff --git a/sys/sys/umtx.h b/sys/sys/umtx.h index c9cfcb7..527beb9 100644 --- a/sys/sys/umtx.h +++ b/sys/sys/umtx.h @@ -81,7 +81,8 @@ umtx_lock(struct umtx *umtx, long id) { if (atomic_cmpset_acq_ptr(&umtx->u_owner, (void *)UMTX_UNOWNED, (void *)id) == 0) - return (- _umtx_op(umtx, UMTX_OP_LOCK, id, 0, 0)); + if (_umtx_op(umtx, UMTX_OP_LOCK, id, 0, 0) == -1) + return (errno); return (0); } @@ -99,7 +100,8 @@ umtx_timedlock(struct umtx *umtx, long id, const struct timespec *timeout) { if (atomic_cmpset_acq_ptr(&umtx->u_owner, (void *)UMTX_UNOWNED, (void *)id) == 0) - return (- _umtx_op(umtx, UMTX_OP_LOCK, id, 0, (void *)timeout)); + if (_umtx_op(umtx, UMTX_OP_LOCK, id, 0, (void *)timeout) == -1) + return (errno); return (0); } @@ -108,21 +110,26 @@ umtx_unlock(struct umtx *umtx, long id) { if (atomic_cmpset_rel_ptr(&umtx->u_owner, (void *)id, (void *)UMTX_UNOWNED) == 0) - return (- _umtx_op(umtx, UMTX_OP_UNLOCK, id, 0, 0)); + if (_umtx_op(umtx, UMTX_OP_UNLOCK, id, 0, 0) == -1) + return (errno); return (0); } static __inline int umtx_wait(struct umtx *umtx, long id, const struct timespec *timeout) { - return (- _umtx_op(umtx, UMTX_OP_WAIT, id, 0, (void *)timeout)); + if (_umtx_op(umtx, UMTX_OP_WAIT, id, 0, (void *)timeout) == -1) + return (errno); + return (0); } /* Wake threads waiting on a user address. */ static __inline int umtx_wake(struct umtx *umtx, int nr_wakeup) { - return (- _umtx_op(umtx, UMTX_OP_WAKE, nr_wakeup, 0, 0)); + if (_umtx_op(umtx, UMTX_OP_WAKE, nr_wakeup, 0, 0) == -1) + return (errno); + return (0); } #endif /* !_KERNEL */ |