What are the differences among these similar nanosleep functions?
孙世龙 sunshilong
sunshilong369 at gmail.com
Fri Jul 3 04:17:51 CEST 2020
What are the differences among these similar nanosleep functions,
especially the second one and the third one:
https://gitlab.denx.de/Xenomai/xenomai/-/blob/v3.1/lib/cobalt/clock.c:
line:353
COBALT_IMPL(int, nanosleep, (const struct timespec *rqtp, struct timespec
*rmtp))
{
int ret;
ret = __WRAP(clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rmtp));
if (ret) {
errno = ret;
return -1;
}
return 0;
}
https://gitlab.denx.de/Xenomai/xenomai/-/blob/v3.1/kernel/cobalt/posix/clock.c
line:272
int __cobalt_clock_nanosleep(clockid_t clock_id, int flags,
const struct timespec *rqt,
struct timespec *rmt)
{
struct restart_block *restart;
struct xnthread *cur;
xnsticks_t timeout, rem;
spl_t s;
trace_cobalt_clock_nanosleep(clock_id, flags, rqt);
if (clock_id != CLOCK_MONOTONIC &&
clock_id != CLOCK_MONOTONIC_RAW &&
clock_id != CLOCK_REALTIME)
return -EOPNOTSUPP;
if (rqt->tv_sec < 0)
return -EINVAL;
if ((unsigned long)rqt->tv_nsec >= ONE_BILLION)
return -EINVAL;
if (flags & ~TIMER_ABSTIME)
return -EINVAL;
cur = xnthread_current();
...
}
https://gitlab.denx.de/Xenomai/xenomai/-/blob/v3.1/kernel/cobalt/posix/clock.c
line:360
COBALT_SYSCALL(clock_nanosleep, primary,
(clockid_t clock_id, int flags,
const struct timespec __user *u_rqt,
struct timespec __user *u_rmt))
{
struct timespec rqt, rmt, *rmtp = NULL;
int ret;
if (u_rmt)
rmtp = &rmt;
if (cobalt_copy_from_user(&rqt, u_rqt, sizeof(rqt)))
return -EFAULT;
ret = __cobalt_clock_nanosleep(clock_id, flags, &rqt, rmtp);
if (ret == -EINTR && flags == 0 && rmtp) {
if (cobalt_copy_to_user(u_rmt, rmtp, sizeof(*u_rmt)))
return -EFAULT;
}
return ret;
}
BTW, the patch that you required has been sent out in the last email
(refer to https://www.mail-archive.com/xenomai@xenomai.org/msg17909.html).
Thank you for your attention to this matter.
Looking forward to hearing from you.
Best Regards.
More information about the Xenomai
mailing list