summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorvangyzen <vangyzen@FreeBSD.org>2017-05-01 01:36:54 +0000
committervangyzen <vangyzen@FreeBSD.org>2017-05-01 01:36:54 +0000
commit1f3f7c15d6db5da93247e3a10bb3f1ff40f61915 (patch)
tree2c49170567af964db6609d58aff8eb6a7649f4ce /sys
parent57723a7d7f1db867d4acce11b84c8389cefc9acd (diff)
downloadFreeBSD-src-1f3f7c15d6db5da93247e3a10bb3f1ff40f61915.zip
FreeBSD-src-1f3f7c15d6db5da93247e3a10bb3f1ff40f61915.tar.gz
MFC r315526
Add clock_nanosleep() Add a clock_nanosleep() syscall, as specified by POSIX. Make nanosleep() a wrapper around it. Attach the clock_nanosleep test from NetBSD. Adjust it for the FreeBSD behavior of updating rmtp only when interrupted by a signal. I believe this to be POSIX-compliant, since POSIX mentions the rmtp parameter only in the paragraph about EINTR. This is also what Linux does. (NetBSD updates rmtp unconditionally.) Copy the whole nanosleep.2 man page from NetBSD because it is complete and closely resembles the POSIX description. Edit, polish, and reword it a bit, being sure to keep any relevant text from the FreeBSD page. Regenerate syscall files. Relnotes: yes Sponsored by: Dell EMC
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c34
-rw-r--r--sys/compat/freebsd32/freebsd32_proto.h8
-rw-r--r--sys/compat/freebsd32/freebsd32_syscall.h1
-rw-r--r--sys/compat/freebsd32/freebsd32_syscalls.c2
-rw-r--r--sys/compat/freebsd32/freebsd32_sysent.c2
-rw-r--r--sys/compat/freebsd32/freebsd32_systrace_args.c34
-rw-r--r--sys/compat/freebsd32/syscalls.master5
-rw-r--r--sys/kern/init_sysent.c2
-rw-r--r--sys/kern/kern_time.c138
-rw-r--r--sys/kern/syscalls.c2
-rw-r--r--sys/kern/syscalls.master4
-rw-r--r--sys/kern/systrace_args.c34
-rw-r--r--sys/sys/syscall.h1
-rw-r--r--sys/sys/syscall.mk1
-rw-r--r--sys/sys/syscallsubr.h2
-rw-r--r--sys/sys/sysproto.h8
16 files changed, 236 insertions, 42 deletions
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 86b1399..08a072f 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -129,6 +129,8 @@ CTASSERT(sizeof(struct sigaction32) == 24);
static int freebsd32_kevent_copyout(void *arg, struct kevent *kevp, int count);
static int freebsd32_kevent_copyin(void *arg, struct kevent *kevp, int count);
+static int freebsd32_user_clock_nanosleep(struct thread *td, clockid_t clock_id,
+ int flags, const struct timespec32 *ua_rqtp, struct timespec32 *ua_rmtp);
void
freebsd32_rusage_out(const struct rusage *s, struct rusage32 *s32)
@@ -2226,28 +2228,48 @@ ofreebsd32_sigstack(struct thread *td,
int
freebsd32_nanosleep(struct thread *td, struct freebsd32_nanosleep_args *uap)
{
+
+ return (freebsd32_user_clock_nanosleep(td, CLOCK_REALTIME,
+ TIMER_RELTIME, uap->rqtp, uap->rmtp));
+}
+
+int
+freebsd32_clock_nanosleep(struct thread *td,
+ struct freebsd32_clock_nanosleep_args *uap)
+{
+ int error;
+
+ error = freebsd32_user_clock_nanosleep(td, uap->clock_id, uap->flags,
+ uap->rqtp, uap->rmtp);
+ return (kern_posix_error(td, error));
+}
+
+static int
+freebsd32_user_clock_nanosleep(struct thread *td, clockid_t clock_id,
+ int flags, const struct timespec32 *ua_rqtp, struct timespec32 *ua_rmtp)
+{
struct timespec32 rmt32, rqt32;
struct timespec rmt, rqt;
int error;
- error = copyin(uap->rqtp, &rqt32, sizeof(rqt32));
+ error = copyin(ua_rqtp, &rqt32, sizeof(rqt32));
if (error)
return (error);
CP(rqt32, rqt, tv_sec);
CP(rqt32, rqt, tv_nsec);
- if (uap->rmtp &&
- !useracc((caddr_t)uap->rmtp, sizeof(rmt), VM_PROT_WRITE))
+ if (ua_rmtp != NULL && (flags & TIMER_ABSTIME) == 0 &&
+ !useracc(ua_rmtp, sizeof(rmt32), VM_PROT_WRITE))
return (EFAULT);
- error = kern_nanosleep(td, &rqt, &rmt);
- if (error == EINTR && uap->rmtp) {
+ error = kern_clock_nanosleep(td, clock_id, flags, &rqt, &rmt);
+ if (error == EINTR && ua_rmtp != NULL && (flags & TIMER_ABSTIME) == 0) {
int error2;
CP(rmt, rmt32, tv_sec);
CP(rmt, rmt32, tv_nsec);
- error2 = copyout(&rmt32, uap->rmtp, sizeof(rmt32));
+ error2 = copyout(&rmt32, ua_rmtp, sizeof(rmt32));
if (error2)
error = error2;
}
diff --git a/sys/compat/freebsd32/freebsd32_proto.h b/sys/compat/freebsd32/freebsd32_proto.h
index 2ef4bbe..1d341f6 100644
--- a/sys/compat/freebsd32/freebsd32_proto.h
+++ b/sys/compat/freebsd32/freebsd32_proto.h
@@ -236,6 +236,12 @@ struct freebsd32_nanosleep_args {
char rqtp_l_[PADL_(const struct timespec32 *)]; const struct timespec32 * rqtp; char rqtp_r_[PADR_(const struct timespec32 *)];
char rmtp_l_[PADL_(struct timespec32 *)]; struct timespec32 * rmtp; char rmtp_r_[PADR_(struct timespec32 *)];
};
+struct freebsd32_clock_nanosleep_args {
+ char clock_id_l_[PADL_(clockid_t)]; clockid_t clock_id; char clock_id_r_[PADR_(clockid_t)];
+ char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
+ char rqtp_l_[PADL_(const struct timespec32 *)]; const struct timespec32 * rqtp; char rqtp_r_[PADR_(const struct timespec32 *)];
+ char rmtp_l_[PADL_(struct timespec32 *)]; struct timespec32 * rmtp; char rmtp_r_[PADR_(struct timespec32 *)];
+};
struct freebsd32_clock_getcpuclockid2_args {
char id1_l_[PADL_(uint32_t)]; uint32_t id1; char id1_r_[PADR_(uint32_t)];
char id2_l_[PADL_(uint32_t)]; uint32_t id2; char id2_r_[PADR_(uint32_t)];
@@ -728,6 +734,7 @@ int freebsd32_ktimer_create(struct thread *, struct freebsd32_ktimer_create_args
int freebsd32_ktimer_settime(struct thread *, struct freebsd32_ktimer_settime_args *);
int freebsd32_ktimer_gettime(struct thread *, struct freebsd32_ktimer_gettime_args *);
int freebsd32_nanosleep(struct thread *, struct freebsd32_nanosleep_args *);
+int freebsd32_clock_nanosleep(struct thread *, struct freebsd32_clock_nanosleep_args *);
int freebsd32_clock_getcpuclockid2(struct thread *, struct freebsd32_clock_getcpuclockid2_args *);
int freebsd32_aio_read(struct thread *, struct freebsd32_aio_read_args *);
int freebsd32_aio_write(struct thread *, struct freebsd32_aio_write_args *);
@@ -1186,6 +1193,7 @@ int freebsd10_freebsd32_pipe(struct thread *, struct freebsd10_freebsd32_pipe_ar
#define FREEBSD32_SYS_AUE_freebsd32_ktimer_settime AUE_NULL
#define FREEBSD32_SYS_AUE_freebsd32_ktimer_gettime AUE_NULL
#define FREEBSD32_SYS_AUE_freebsd32_nanosleep AUE_NULL
+#define FREEBSD32_SYS_AUE_freebsd32_clock_nanosleep AUE_NULL
#define FREEBSD32_SYS_AUE_freebsd32_clock_getcpuclockid2 AUE_NULL
#define FREEBSD32_SYS_AUE_freebsd32_aio_read AUE_NULL
#define FREEBSD32_SYS_AUE_freebsd32_aio_write AUE_NULL
diff --git a/sys/compat/freebsd32/freebsd32_syscall.h b/sys/compat/freebsd32/freebsd32_syscall.h
index a80e1e4..9cf249d 100644
--- a/sys/compat/freebsd32/freebsd32_syscall.h
+++ b/sys/compat/freebsd32/freebsd32_syscall.h
@@ -215,6 +215,7 @@
#define FREEBSD32_SYS_ffclock_getcounter 241
#define FREEBSD32_SYS_ffclock_setestimate 242
#define FREEBSD32_SYS_ffclock_getestimate 243
+#define FREEBSD32_SYS_freebsd32_clock_nanosleep 244
#define FREEBSD32_SYS_freebsd32_clock_getcpuclockid2 247
#define FREEBSD32_SYS_minherit 250
#define FREEBSD32_SYS_rfork 251
diff --git a/sys/compat/freebsd32/freebsd32_syscalls.c b/sys/compat/freebsd32/freebsd32_syscalls.c
index 6b3b4a0..5ef6c83 100644
--- a/sys/compat/freebsd32/freebsd32_syscalls.c
+++ b/sys/compat/freebsd32/freebsd32_syscalls.c
@@ -254,7 +254,7 @@ const char *freebsd32_syscallnames[] = {
"ffclock_getcounter", /* 241 = ffclock_getcounter */
"ffclock_setestimate", /* 242 = ffclock_setestimate */
"ffclock_getestimate", /* 243 = ffclock_getestimate */
- "#244", /* 244 = nosys */
+ "freebsd32_clock_nanosleep", /* 244 = freebsd32_clock_nanosleep */
"#245", /* 245 = nosys */
"#246", /* 246 = nosys */
"freebsd32_clock_getcpuclockid2", /* 247 = freebsd32_clock_getcpuclockid2 */
diff --git a/sys/compat/freebsd32/freebsd32_sysent.c b/sys/compat/freebsd32/freebsd32_sysent.c
index 9a5547f..b709679 100644
--- a/sys/compat/freebsd32/freebsd32_sysent.c
+++ b/sys/compat/freebsd32/freebsd32_sysent.c
@@ -297,7 +297,7 @@ struct sysent freebsd32_sysent[] = {
{ AS(ffclock_getcounter_args), (sy_call_t *)sys_ffclock_getcounter, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 241 = ffclock_getcounter */
{ AS(ffclock_setestimate_args), (sy_call_t *)sys_ffclock_setestimate, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 242 = ffclock_setestimate */
{ AS(ffclock_getestimate_args), (sy_call_t *)sys_ffclock_getestimate, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 243 = ffclock_getestimate */
- { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 244 = nosys */
+ { AS(freebsd32_clock_nanosleep_args), (sy_call_t *)freebsd32_clock_nanosleep, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 244 = freebsd32_clock_nanosleep */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 245 = nosys */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 246 = nosys */
{ AS(freebsd32_clock_getcpuclockid2_args), (sy_call_t *)freebsd32_clock_getcpuclockid2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 247 = freebsd32_clock_getcpuclockid2 */
diff --git a/sys/compat/freebsd32/freebsd32_systrace_args.c b/sys/compat/freebsd32/freebsd32_systrace_args.c
index ed4722a..002d4a2 100644
--- a/sys/compat/freebsd32/freebsd32_systrace_args.c
+++ b/sys/compat/freebsd32/freebsd32_systrace_args.c
@@ -1260,6 +1260,16 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
*n_args = 1;
break;
}
+ /* freebsd32_clock_nanosleep */
+ case 244: {
+ struct freebsd32_clock_nanosleep_args *p = params;
+ iarg[0] = p->clock_id; /* clockid_t */
+ iarg[1] = p->flags; /* int */
+ uarg[2] = (intptr_t) p->rqtp; /* const struct timespec32 * */
+ uarg[3] = (intptr_t) p->rmtp; /* struct timespec32 * */
+ *n_args = 4;
+ break;
+ }
/* freebsd32_clock_getcpuclockid2 */
case 247: {
struct freebsd32_clock_getcpuclockid2_args *p = params;
@@ -5312,6 +5322,25 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
};
break;
+ /* freebsd32_clock_nanosleep */
+ case 244:
+ switch(ndx) {
+ case 0:
+ p = "clockid_t";
+ break;
+ case 1:
+ p = "int";
+ break;
+ case 2:
+ p = "const struct timespec32 *";
+ break;
+ case 3:
+ p = "struct timespec32 *";
+ break;
+ default:
+ break;
+ };
+ break;
/* freebsd32_clock_getcpuclockid2 */
case 247:
switch(ndx) {
@@ -9651,6 +9680,11 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
if (ndx == 0 || ndx == 1)
p = "int";
break;
+ /* freebsd32_clock_nanosleep */
+ case 244:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* freebsd32_clock_getcpuclockid2 */
case 247:
if (ndx == 0 || ndx == 1)
diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master
index 276d79c..d9afd24 100644
--- a/sys/compat/freebsd32/syscalls.master
+++ b/sys/compat/freebsd32/syscalls.master
@@ -462,7 +462,10 @@
struct ffclock_estimate *cest); }
243 AUE_NULL NOPROTO { int ffclock_getestimate( \
struct ffclock_estimate *cest); }
-244 AUE_NULL UNIMPL nosys
+244 AUE_NULL STD { int freebsd32_clock_nanosleep( \
+ clockid_t clock_id, int flags, \
+ const struct timespec32 *rqtp, \
+ struct timespec32 *rmtp); }
245 AUE_NULL UNIMPL nosys
246 AUE_NULL UNIMPL nosys
247 AUE_NULL STD { int freebsd32_clock_getcpuclockid2(\
diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c
index e5421b9..d0c1dec 100644
--- a/sys/kern/init_sysent.c
+++ b/sys/kern/init_sysent.c
@@ -290,7 +290,7 @@ struct sysent sysent[] = {
{ AS(ffclock_getcounter_args), (sy_call_t *)sys_ffclock_getcounter, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 241 = ffclock_getcounter */
{ AS(ffclock_setestimate_args), (sy_call_t *)sys_ffclock_setestimate, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 242 = ffclock_setestimate */
{ AS(ffclock_getestimate_args), (sy_call_t *)sys_ffclock_getestimate, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 243 = ffclock_getestimate */
- { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 244 = nosys */
+ { AS(clock_nanosleep_args), (sy_call_t *)sys_clock_nanosleep, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 244 = clock_nanosleep */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 245 = nosys */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 246 = nosys */
{ AS(clock_getcpuclockid2_args), (sy_call_t *)sys_clock_getcpuclockid2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 247 = clock_getcpuclockid2 */
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 6255d2d..41b086e 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -86,6 +86,9 @@ static uma_zone_t itimer_zone = NULL;
static int settime(struct thread *, struct timeval *);
static void timevalfix(struct timeval *);
+static int user_clock_nanosleep(struct thread *td, clockid_t clock_id,
+ int flags, const struct timespec *ua_rqtp,
+ struct timespec *ua_rmtp);
static void itimer_start(void);
static int itimer_init(void *, int, int);
@@ -474,47 +477,95 @@ kern_clock_getres(struct thread *td, clockid_t clock_id, struct timespec *ts)
return (0);
}
+int
+kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt)
+{
+
+ return (kern_clock_nanosleep(td, CLOCK_REALTIME, TIMER_RELTIME, rqt,
+ rmt));
+}
+
static uint8_t nanowait[MAXCPU];
int
-kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt)
+kern_clock_nanosleep(struct thread *td, clockid_t clock_id, int flags,
+ const struct timespec *rqt, struct timespec *rmt)
{
- struct timespec ts;
+ struct timespec ts, now;
sbintime_t sbt, sbtt, prec, tmp;
time_t over;
int error;
+ bool is_abs_real;
if (rqt->tv_nsec < 0 || rqt->tv_nsec >= 1000000000)
return (EINVAL);
- if (rqt->tv_sec < 0 || (rqt->tv_sec == 0 && rqt->tv_nsec == 0))
- return (0);
- ts = *rqt;
- if (ts.tv_sec > INT32_MAX / 2) {
- over = ts.tv_sec - INT32_MAX / 2;
- ts.tv_sec -= over;
- } else
- over = 0;
- tmp = tstosbt(ts);
- prec = tmp;
- prec >>= tc_precexp;
- if (TIMESEL(&sbt, tmp))
- sbt += tc_tick_sbt;
- sbt += tmp;
- error = tsleep_sbt(&nanowait[curcpu], PWAIT | PCATCH, "nanslp",
- sbt, prec, C_ABSOLUTE);
+ if ((flags & ~TIMER_ABSTIME) != 0)
+ return (EINVAL);
+ switch (clock_id) {
+ case CLOCK_REALTIME:
+ case CLOCK_REALTIME_PRECISE:
+ case CLOCK_REALTIME_FAST:
+ case CLOCK_SECOND:
+ is_abs_real = (flags & TIMER_ABSTIME) != 0;
+ break;
+ case CLOCK_MONOTONIC:
+ case CLOCK_MONOTONIC_PRECISE:
+ case CLOCK_MONOTONIC_FAST:
+ case CLOCK_UPTIME:
+ case CLOCK_UPTIME_PRECISE:
+ case CLOCK_UPTIME_FAST:
+ is_abs_real = false;
+ break;
+ case CLOCK_VIRTUAL:
+ case CLOCK_PROF:
+ case CLOCK_PROCESS_CPUTIME_ID:
+ return (ENOTSUP);
+ case CLOCK_THREAD_CPUTIME_ID:
+ default:
+ return (EINVAL);
+ }
+ do {
+ ts = *rqt;
+ if ((flags & TIMER_ABSTIME) != 0) {
+ if (is_abs_real)
+ td->td_rtcgen =
+ atomic_load_acq_int(&rtc_generation);
+ error = kern_clock_gettime(td, clock_id, &now);
+ KASSERT(error == 0, ("kern_clock_gettime: %d", error));
+ timespecsub(&ts, &now);
+ }
+ if (ts.tv_sec < 0 || (ts.tv_sec == 0 && ts.tv_nsec == 0)) {
+ error = EWOULDBLOCK;
+ break;
+ }
+ if (ts.tv_sec > INT32_MAX / 2) {
+ over = ts.tv_sec - INT32_MAX / 2;
+ ts.tv_sec -= over;
+ } else
+ over = 0;
+ tmp = tstosbt(ts);
+ prec = tmp;
+ prec >>= tc_precexp;
+ if (TIMESEL(&sbt, tmp))
+ sbt += tc_tick_sbt;
+ sbt += tmp;
+ error = tsleep_sbt(&nanowait[curcpu], PWAIT | PCATCH, "nanslp",
+ sbt, prec, C_ABSOLUTE);
+ } while (error == 0 && is_abs_real && td->td_rtcgen == 0);
+ td->td_rtcgen = 0;
if (error != EWOULDBLOCK) {
+ TIMESEL(&sbtt, tmp);
+ if (sbtt >= sbt)
+ return (0);
if (error == ERESTART)
error = EINTR;
- TIMESEL(&sbtt, tmp);
- if (rmt != NULL) {
+ if ((flags & TIMER_ABSTIME) == 0 && rmt != NULL) {
ts = sbttots(sbt - sbtt);
ts.tv_sec += over;
if (ts.tv_sec < 0)
timespecclear(&ts);
*rmt = ts;
}
- if (sbtt >= sbt)
- return (0);
return (error);
}
return (0);
@@ -530,21 +581,48 @@ struct nanosleep_args {
int
sys_nanosleep(struct thread *td, struct nanosleep_args *uap)
{
+
+ return (user_clock_nanosleep(td, CLOCK_REALTIME, TIMER_RELTIME,
+ uap->rqtp, uap->rmtp));
+}
+
+#ifndef _SYS_SYSPROTO_H_
+struct clock_nanosleep_args {
+ clockid_t clock_id;
+ int flags;
+ struct timespec *rqtp;
+ struct timespec *rmtp;
+};
+#endif
+/* ARGSUSED */
+int
+sys_clock_nanosleep(struct thread *td, struct clock_nanosleep_args *uap)
+{
+ int error;
+
+ error = user_clock_nanosleep(td, uap->clock_id, uap->flags, uap->rqtp,
+ uap->rmtp);
+ return (kern_posix_error(td, error));
+}
+
+static int
+user_clock_nanosleep(struct thread *td, clockid_t clock_id, int flags,
+ const struct timespec *ua_rqtp, struct timespec *ua_rmtp)
+{
struct timespec rmt, rqt;
int error;
- error = copyin(uap->rqtp, &rqt, sizeof(rqt));
+ error = copyin(ua_rqtp, &rqt, sizeof(rqt));
if (error)
return (error);
-
- if (uap->rmtp &&
- !useracc((caddr_t)uap->rmtp, sizeof(rmt), VM_PROT_WRITE))
- return (EFAULT);
- error = kern_nanosleep(td, &rqt, &rmt);
- if (error == EINTR && uap->rmtp) {
+ if (ua_rmtp != NULL && (flags & TIMER_ABSTIME) == 0 &&
+ !useracc(ua_rmtp, sizeof(rmt), VM_PROT_WRITE))
+ return (EFAULT);
+ error = kern_clock_nanosleep(td, clock_id, flags, &rqt, &rmt);
+ if (error == EINTR && ua_rmtp != NULL && (flags & TIMER_ABSTIME) == 0) {
int error2;
- error2 = copyout(&rmt, uap->rmtp, sizeof(rmt));
+ error2 = copyout(&rmt, ua_rmtp, sizeof(rmt));
if (error2)
error = error2;
}
diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c
index b0d782e..21145a6 100644
--- a/sys/kern/syscalls.c
+++ b/sys/kern/syscalls.c
@@ -251,7 +251,7 @@ const char *syscallnames[] = {
"ffclock_getcounter", /* 241 = ffclock_getcounter */
"ffclock_setestimate", /* 242 = ffclock_setestimate */
"ffclock_getestimate", /* 243 = ffclock_getestimate */
- "#244", /* 244 = nosys */
+ "clock_nanosleep", /* 244 = clock_nanosleep */
"#245", /* 245 = nosys */
"#246", /* 246 = nosys */
"clock_getcpuclockid2", /* 247 = clock_getcpuclockid2 */
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index 36380bd..632e05e 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -461,7 +461,9 @@
struct ffclock_estimate *cest); }
243 AUE_NULL STD { int ffclock_getestimate( \
struct ffclock_estimate *cest); }
-244 AUE_NULL UNIMPL nosys
+244 AUE_NULL STD { int clock_nanosleep(clockid_t clock_id, \
+ int flags, const struct timespec *rqtp, \
+ struct timespec *rmtp); }
245 AUE_NULL UNIMPL nosys
246 AUE_NULL UNIMPL nosys
247 AUE_NULL STD { int clock_getcpuclockid2(id_t id,\
diff --git a/sys/kern/systrace_args.c b/sys/kern/systrace_args.c
index ab98c5a..29a8aa1 100644
--- a/sys/kern/systrace_args.c
+++ b/sys/kern/systrace_args.c
@@ -1290,6 +1290,16 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
*n_args = 1;
break;
}
+ /* clock_nanosleep */
+ case 244: {
+ struct clock_nanosleep_args *p = params;
+ iarg[0] = p->clock_id; /* clockid_t */
+ iarg[1] = p->flags; /* int */
+ uarg[2] = (intptr_t) p->rqtp; /* const struct timespec * */
+ uarg[3] = (intptr_t) p->rmtp; /* struct timespec * */
+ *n_args = 4;
+ break;
+ }
/* clock_getcpuclockid2 */
case 247: {
struct clock_getcpuclockid2_args *p = params;
@@ -5374,6 +5384,25 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
};
break;
+ /* clock_nanosleep */
+ case 244:
+ switch(ndx) {
+ case 0:
+ p = "clockid_t";
+ break;
+ case 1:
+ p = "int";
+ break;
+ case 2:
+ p = "const struct timespec *";
+ break;
+ case 3:
+ p = "struct timespec *";
+ break;
+ default:
+ break;
+ };
+ break;
/* clock_getcpuclockid2 */
case 247:
switch(ndx) {
@@ -9628,6 +9657,11 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
if (ndx == 0 || ndx == 1)
p = "int";
break;
+ /* clock_nanosleep */
+ case 244:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* clock_getcpuclockid2 */
case 247:
if (ndx == 0 || ndx == 1)
diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h
index a39a9f2..806a549 100644
--- a/sys/sys/syscall.h
+++ b/sys/sys/syscall.h
@@ -219,6 +219,7 @@
#define SYS_ffclock_getcounter 241
#define SYS_ffclock_setestimate 242
#define SYS_ffclock_getestimate 243
+#define SYS_clock_nanosleep 244
#define SYS_clock_getcpuclockid2 247
#define SYS_ntp_gettime 248
#define SYS_minherit 250
diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk
index 1a073ef..113572d 100644
--- a/sys/sys/syscall.mk
+++ b/sys/sys/syscall.mk
@@ -159,6 +159,7 @@ MIASM = \
ffclock_getcounter.o \
ffclock_setestimate.o \
ffclock_getestimate.o \
+ clock_nanosleep.o \
clock_getcpuclockid2.o \
ntp_gettime.o \
minherit.o \
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index ff2a110..16af617 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -83,6 +83,8 @@ int kern_clock_getres(struct thread *td, clockid_t clock_id,
struct timespec *ts);
int kern_clock_gettime(struct thread *td, clockid_t clock_id,
struct timespec *ats);
+int kern_clock_nanosleep(struct thread *td, clockid_t clock_id, int flags,
+ const struct timespec *rqtp, struct timespec *rmtp);
int kern_clock_settime(struct thread *td, clockid_t clock_id,
struct timespec *ats);
int kern_close(struct thread *td, int fd);
diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h
index df6e8fa..9843ad5 100644
--- a/sys/sys/sysproto.h
+++ b/sys/sys/sysproto.h
@@ -698,6 +698,12 @@ struct ffclock_setestimate_args {
struct ffclock_getestimate_args {
char cest_l_[PADL_(struct ffclock_estimate *)]; struct ffclock_estimate * cest; char cest_r_[PADR_(struct ffclock_estimate *)];
};
+struct clock_nanosleep_args {
+ char clock_id_l_[PADL_(clockid_t)]; clockid_t clock_id; char clock_id_r_[PADR_(clockid_t)];
+ char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
+ char rqtp_l_[PADL_(const struct timespec *)]; const struct timespec * rqtp; char rqtp_r_[PADR_(const struct timespec *)];
+ char rmtp_l_[PADL_(struct timespec *)]; struct timespec * rmtp; char rmtp_r_[PADR_(struct timespec *)];
+};
struct clock_getcpuclockid2_args {
char id_l_[PADL_(id_t)]; id_t id; char id_r_[PADR_(id_t)];
char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
@@ -1942,6 +1948,7 @@ int sys_nanosleep(struct thread *, struct nanosleep_args *);
int sys_ffclock_getcounter(struct thread *, struct ffclock_getcounter_args *);
int sys_ffclock_setestimate(struct thread *, struct ffclock_setestimate_args *);
int sys_ffclock_getestimate(struct thread *, struct ffclock_getestimate_args *);
+int sys_clock_nanosleep(struct thread *, struct clock_nanosleep_args *);
int sys_clock_getcpuclockid2(struct thread *, struct clock_getcpuclockid2_args *);
int sys_ntp_gettime(struct thread *, struct ntp_gettime_args *);
int sys_minherit(struct thread *, struct minherit_args *);
@@ -2713,6 +2720,7 @@ int freebsd10_pipe(struct thread *, struct freebsd10_pipe_args *);
#define SYS_AUE_ffclock_getcounter AUE_NULL
#define SYS_AUE_ffclock_setestimate AUE_NULL
#define SYS_AUE_ffclock_getestimate AUE_NULL
+#define SYS_AUE_clock_nanosleep AUE_NULL
#define SYS_AUE_clock_getcpuclockid2 AUE_NULL
#define SYS_AUE_ntp_gettime AUE_NULL
#define SYS_AUE_minherit AUE_MINHERIT
OpenPOWER on IntegriCloud