summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_umtx.c
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2005-01-12 05:55:52 +0000
committerdavidxu <davidxu@FreeBSD.org>2005-01-12 05:55:52 +0000
commit7c0e04f42e6bd24a3ed5929e9627c18ea50a2a1a (patch)
tree7c7423b4c98eb013fdc9c89300741127213429af /sys/kern/kern_umtx.c
parent336b3042682db5e8b323fe16df574b52e6a555c7 (diff)
downloadFreeBSD-src-7c0e04f42e6bd24a3ed5929e9627c18ea50a2a1a.zip
FreeBSD-src-7c0e04f42e6bd24a3ed5929e9627c18ea50a2a1a.tar.gz
Let _umtx_op directly return error code rather than from errno because
errno can be tampered potentially by nested signal handle. Now all error codes are returned in negative value, positive value are reserved for future expansion.
Diffstat (limited to 'sys/kern/kern_umtx.c')
-rw-r--r--sys/kern/kern_umtx.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index 158210c..bcdddab 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -679,7 +679,6 @@ do_wake(struct thread *td, void *uaddr, int n_wake)
ret = umtxq_signal(&key, n_wake);
umtxq_unlock(&key);
umtx_key_release(&key);
- td->td_retval[0] = ret;
return (0);
}
@@ -712,15 +711,20 @@ _umtx_op(struct thread *td, struct _umtx_op_args *uap)
else {
error = copyin(uap->uaddr2, &abstime, sizeof(abstime));
if (error != 0)
- return (error);
+ break;
+ printf("uap->abstime: %d.%ld\n", abstime.tv_sec, abstime.tv_nsec);
if (abstime.tv_nsec >= 1000000000 ||
- abstime.tv_nsec < 0)
- return (EINVAL);
+ abstime.tv_nsec < 0) {
+ error = EINVAL;
+ break;
+ }
ts = &abstime;
}
- return do_lock(td, uap->umtx, uap->id, ts);
+ error = do_lock(td, uap->umtx, uap->id, ts);
+ break;
case UMTX_OP_UNLOCK:
- return do_unlock(td, uap->umtx, uap->id);
+ error = do_unlock(td, uap->umtx, uap->id);
+ break;
case UMTX_OP_WAIT:
/* Allow a null timespec (wait forever). */
if (uap->uaddr2 == NULL)
@@ -728,16 +732,23 @@ _umtx_op(struct thread *td, struct _umtx_op_args *uap)
else {
error = copyin(uap->uaddr2, &abstime, sizeof(abstime));
if (error != 0)
- return (error);
+ break;
if (abstime.tv_nsec >= 1000000000 ||
- abstime.tv_nsec < 0)
- return (EINVAL);
+ abstime.tv_nsec < 0) {
+ error = EINVAL;
+ break;
+ }
ts = &abstime;
}
- return do_wait(td, uap->umtx, uap->id, ts);
+ error = do_wait(td, uap->umtx, uap->id, ts);
+ break;
case UMTX_OP_WAKE:
- return do_wake(td, uap->umtx, uap->id);
+ error = do_wake(td, uap->umtx, uap->id);
+ break;
default:
- return (EINVAL);
+ error = EINVAL;
+ break;
}
+ td->td_retval[0] = -error;
+ return (0);
}
OpenPOWER on IntegriCloud