Correctly check failed syscall.

This commit is contained in:
davidxu 2006-12-12 05:26:39 +00:00
parent fec8d2cf34
commit 229aca4634

View File

@ -41,7 +41,7 @@ _thr_umutex_init(struct umutex *mtx)
int
__thr_umutex_lock(struct umutex *mtx)
{
if (_umtx_op(mtx, UMTX_OP_MUTEX_LOCK, 0, 0, 0) == 0)
if (_umtx_op(mtx, UMTX_OP_MUTEX_LOCK, 0, 0, 0) != -1)
return 0;
return (errno);
}
@ -54,7 +54,7 @@ __thr_umutex_timedlock(struct umutex *mtx,
timeout->tv_nsec <= 0)))
return (ETIMEDOUT);
if (_umtx_op(mtx, UMTX_OP_MUTEX_LOCK, 0, 0,
__DECONST(void *, timeout)) == 0)
__DECONST(void *, timeout)) != -1)
return (0);
return (errno);
}
@ -62,7 +62,7 @@ __thr_umutex_timedlock(struct umutex *mtx,
int
__thr_umutex_unlock(struct umutex *mtx)
{
if (_umtx_op(mtx, UMTX_OP_MUTEX_UNLOCK, 0, 0, 0) == 0)
if (_umtx_op(mtx, UMTX_OP_MUTEX_UNLOCK, 0, 0, 0) != -1)
return (0);
return (errno);
}
@ -70,7 +70,7 @@ __thr_umutex_unlock(struct umutex *mtx)
int
__thr_umutex_trylock(struct umutex *mtx)
{
if (_umtx_op(mtx, UMTX_OP_MUTEX_TRYLOCK, 0, 0, 0) == 0)
if (_umtx_op(mtx, UMTX_OP_MUTEX_TRYLOCK, 0, 0, 0) != -1)
return (0);
return (errno);
}
@ -79,7 +79,7 @@ int
__thr_umutex_set_ceiling(struct umutex *mtx, uint32_t ceiling,
uint32_t *oldceiling)
{
if (_umtx_op(mtx, UMTX_OP_SET_CEILING, ceiling, oldceiling, 0) == 0)
if (_umtx_op(mtx, UMTX_OP_SET_CEILING, ceiling, oldceiling, 0) != -1)
return (0);
return (errno);
}
@ -91,7 +91,7 @@ _thr_umtx_wait(volatile umtx_t *mtx, long id, const struct timespec *timeout)
timeout->tv_nsec <= 0)))
return (ETIMEDOUT);
if (_umtx_op(__DEVOLATILE(void *, mtx), UMTX_OP_WAIT, id, 0,
__DECONST(void*, timeout)) == 0)
__DECONST(void*, timeout)) != -1)
return (0);
return (errno);
}
@ -100,7 +100,7 @@ int
_thr_umtx_wake(volatile umtx_t *mtx, int nr_wakeup)
{
if (_umtx_op(__DEVOLATILE(void *, mtx), UMTX_OP_WAKE,
nr_wakeup, 0, 0) == 0)
nr_wakeup, 0, 0) != -1)
return (0);
return (errno);
}
@ -122,7 +122,7 @@ _thr_ucond_wait(struct ucond *cv, struct umutex *m,
}
if (_umtx_op(cv, UMTX_OP_CV_WAIT,
check_unparking ? UMTX_CHECK_UNPARKING : 0,
m, __DECONST(void*, timeout)) == 0) {
m, __DECONST(void*, timeout)) != -1) {
return (0);
}
return (errno);
@ -133,7 +133,7 @@ _thr_ucond_signal(struct ucond *cv)
{
if (!cv->c_has_waiters)
return (0);
if (_umtx_op(cv, UMTX_OP_CV_SIGNAL, 0, NULL, NULL) == 0)
if (_umtx_op(cv, UMTX_OP_CV_SIGNAL, 0, NULL, NULL) != -1)
return (0);
return (errno);
}
@ -143,7 +143,7 @@ _thr_ucond_broadcast(struct ucond *cv)
{
if (!cv->c_has_waiters)
return (0);
if (_umtx_op(cv, UMTX_OP_CV_BROADCAST, 0, NULL, NULL) == 0)
if (_umtx_op(cv, UMTX_OP_CV_BROADCAST, 0, NULL, NULL) != -1)
return (0);
return (errno);
}