int
compat_50_netbsd32_timer_settime(struct lwp *l,
    const struct compat_50_netbsd32_timer_settime_args *uap, register_t *retval)
{
	/* {
		syscallarg(netbsd32_timer_t) timerid;
		syscallarg(int) flags;
		syscallarg(const netbsd32_itimerspec50p_t) value;
		syscallarg(netbsd32_itimerspec50p_t) ovalue;
	} */
	int error;
	struct itimerspec value, ovalue, *ovp = NULL;
	struct netbsd32_itimerspec50 its32;

	if ((error = copyin(SCARG_P32(uap, value), &its32, sizeof(its32))) != 0)
		return (error);
	netbsd32_to_timespec50(&its32.it_interval, &value.it_interval);
	netbsd32_to_timespec50(&its32.it_value, &value.it_value);

	if (SCARG_P32(uap, ovalue))
		ovp = &ovalue;

	if ((error = dotimer_settime(SCARG(uap, timerid), &value, ovp,
	    SCARG(uap, flags), l->l_proc)) != 0)
		return error;

	if (ovp) {
		netbsd32_from_timespec50(&ovp->it_interval, &its32.it_interval);
		netbsd32_from_timespec50(&ovp->it_value, &its32.it_value);
		return copyout(&its32, SCARG_P32(uap, ovalue), sizeof(its32));
	}
	return 0;
}
int
compat_50_netbsd32__lwp_park(struct lwp *l,
    const struct compat_50_netbsd32__lwp_park_args *uap, register_t *retval)
{
	/* {
		syscallarg(const netbsd32_timespec50p) ts;
		syscallarg(lwpid_t) unpark;
		syscallarg(netbsd32_voidp) hint;
		syscallarg(netbsd32_voidp) unparkhint;
	} */
	struct timespec ts, *tsp;
	struct netbsd32_timespec50 ts32;
	int error;

	if (SCARG_P32(uap, ts) == NULL)
		tsp = NULL;
	else {
		error = copyin(SCARG_P32(uap, ts), &ts32, sizeof ts32);
		if (error != 0)
			return error;
		netbsd32_to_timespec50(&ts32, &ts);
		tsp = &ts;
	}

	if (SCARG(uap, unpark) != 0) {
		error = lwp_unpark(SCARG(uap, unpark),
		    SCARG_P32(uap, unparkhint));
		if (error != 0)
			return error;
	}

	return lwp_park(CLOCK_REALTIME, TIMER_ABSTIME, tsp,
	    SCARG_P32(uap, hint));
	return 0;
}
int
compat_50_netbsd32_nanosleep(struct lwp *l,
    const struct compat_50_netbsd32_nanosleep_args *uap, register_t *retval)
{
	/* {
		syscallarg(const netbsd32_timespec50p_t) rqtp;
		syscallarg(netbsd32_timespecp_t) rmtp;
	} */
	struct netbsd32_timespec50 ts32;
	struct timespec rqt, rmt;
	int error, error1;

	error = copyin(SCARG_P32(uap, rqtp), &ts32, sizeof(ts32));
	if (error)
		return (error);
	netbsd32_to_timespec50(&ts32, &rqt);

	error = nanosleep1(l, CLOCK_MONOTONIC, 0, &rqt,
	    SCARG_P32(uap, rmtp) ? &rmt : NULL);
	if (SCARG_P32(uap, rmtp) == NULL || (error != 0 && error != EINTR))
		return error;

	netbsd32_from_timespec50(&rmt, &ts32);
	error1 = copyout(&ts32, SCARG_P32(uap,rmtp), sizeof(ts32));
	return error1 ? error1 : error;
}
Esempio n. 4
0
int
compat_50_netbsd32_mq_timedsend(struct lwp *l,
    const struct compat_50_netbsd32_mq_timedsend_args *uap,
    register_t *retval)
{
	/* {
		syscallarg(mqd_t) mqdes;
		syscallarg(const netbsd32_charp) msg_ptr;
		syscallarg(netbsd32_size_t) msg_len;
		syscallarg(unsigned) msg_prio;
		syscallarg(const netbsd32_timespec50p_t) abs_timeout;
	} */
	struct timespec ts, *tsp;
	struct netbsd32_timespec50 ts32;
	int error;

	/* Get and convert time value */
	if (SCARG_P32(uap, abs_timeout)) {
		error = copyin(SCARG_P32(uap, abs_timeout), &ts32,
		     sizeof(ts32));
		if (error)
			return error;
		netbsd32_to_timespec50(&ts32, &ts);
		tsp = &ts;
	} else {
		tsp = NULL;
	}

	return mq_send1(SCARG(uap, mqdes), SCARG_P32(uap, msg_ptr),
	    SCARG(uap, msg_len), SCARG(uap, msg_prio), tsp);
}
static int
netbsd32_kevent_fetch_timeout(const void *src, void *dest, size_t length)
{
	struct netbsd32_timespec50 ts32;
	int error;

	KASSERT(length == sizeof(struct timespec50));

	error = copyin(src, &ts32, sizeof(ts32));
	if (error)
		return error;
	netbsd32_to_timespec50(&ts32, (struct timespec *)dest);
	return 0;
}
static int
compat_50_netbsd32_sigtimedwait_fetch_timeout(const void *src, void *dst, size_t size)
{
	struct timespec *ts = dst;
	struct netbsd32_timespec50 ts32;
	int error;

	error = copyin(src, &ts32, sizeof(ts32));
	if (error)
		return error;

	netbsd32_to_timespec50(&ts32, ts);
	return 0;
}
int
compat_50_netbsd32_clock_settime(struct lwp *l,
    const struct compat_50_netbsd32_clock_settime_args *uap, register_t *retval)
{
	/* {
		syscallarg(netbsd32_clockid_t) clock_id;
		syscallarg(const netbsd32_timespec50p_t) tp;
	} */
	struct netbsd32_timespec50 ts32;
	struct timespec ats;
	int error;

	if ((error = copyin(SCARG_P32(uap, tp), &ts32, sizeof(ts32))) != 0)
		return (error);

	netbsd32_to_timespec50(&ts32, &ats);
	return clock_settime1(l->l_proc, SCARG(uap, clock_id), &ats, true);
}