Author: vangyzen
Date: Sun Mar 19 00:51:12 2017
New Revision: 315526
URL: https://svnweb.freebsd.org/changeset/base/315526
Log:
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.
Reviewed by: kib, ngie, jilles
MFC after:3 weeks
Relnotes: yes
Sponsored by: Dell EMC
Differential Revision:https://reviews.freebsd.org/D10020
Added:
head/lib/libc/sys/clock_nanosleep.c
- copied, changed from r315525, head/lib/libc/sys/nanosleep.c
Modified:
head/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c
head/include/time.h
head/lib/libc/include/libc_private.h
head/lib/libc/include/namespace.h
head/lib/libc/include/un-namespace.h
head/lib/libc/sys/Makefile.inc
head/lib/libc/sys/Symbol.map
head/lib/libc/sys/interposing_table.c
head/lib/libc/sys/nanosleep.2
head/lib/libc/tests/sys/Makefile
head/lib/libthr/thread/thr_private.h
head/lib/libthr/thread/thr_syscalls.c
head/share/man/man3/pthread_testcancel.3
head/sys/compat/freebsd32/freebsd32_misc.c
head/sys/compat/freebsd32/syscalls.master
head/sys/kern/kern_time.c
head/sys/kern/syscalls.master
head/sys/sys/syscallsubr.h
Modified: head/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c
==
--- head/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c Sun Mar 19
00:36:29 2017(r315525)
+++ head/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c Sun Mar 19
00:51:12 2017(r315526)
@@ -46,7 +46,11 @@ ATF_TC_BODY(clock_nanosleep_remain, tc)
rqtp.tv_sec = 0; rqtp.tv_nsec = 0;
rmtp.tv_sec = -1; rmtp.tv_nsec = -1;
ATF_REQUIRE(clock_nanosleep(CLOCK_REALTIME, 0, &rqtp, &rmtp) == 0);
+#ifdef __FreeBSD__
+ ATF_CHECK(rmtp.tv_sec == -1 && rmtp.tv_nsec == -1);
+#else
ATF_CHECK(rmtp.tv_sec == 0 && rmtp.tv_nsec == 0);
+#endif
ATF_REQUIRE(clock_gettime(CLOCK_REALTIME, &rqtp) == 0);
rmtp.tv_sec = -1; rmtp.tv_nsec = -1;
Modified: head/include/time.h
==
--- head/include/time.h Sun Mar 19 00:36:29 2017(r315525)
+++ head/include/time.h Sun Mar 19 00:51:12 2017(r315526)
@@ -169,12 +169,12 @@ void tzset(void);
int clock_getres(clockid_t, struct timespec *);
int clock_gettime(clockid_t, struct timespec *);
int clock_settime(clockid_t, const struct timespec *);
-/* XXX missing: clock_nanosleep() */
int nanosleep(const struct timespec *, struct timespec *);
#endif /* __POSIX_VISIBLE >= 199309 */
#if __POSIX_VISIBLE >= 200112
int clock_getcpuclockid(pid_t, clockid_t *);
+int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec
*);
#endif
#if __POSIX_VISIBLE >= 199506
Modified: head/lib/libc/include/libc_private.h
==
--- head/lib/libc/include/libc_private.hSun Mar 19 00:36:29 2017
(r315525)
+++ head/lib/libc/include/libc_private.hSun Mar 19 00:51:12 2017
(r315526)
@@ -229,6 +229,7 @@ enum {
INTERPOS_ppoll,
INTERPOS_map_stacks_exec,
INTERPOS_fdatasync,
+ INTERPOS_clock_nanosleep,
INTERPOS_MAX
};
@@ -318,6 +319,8 @@ int __sys_aio_suspend(const struct aioc
int__sys_accept(int, struct sockaddr *, __socklen_t *);
int__sys_accept4(int, struct sockaddr *, __socklen_t *, int);
int__sys_clock_gettime(__clockid_t, struct timespec *ts);
+int__sys_clock_nanosleep(__clockid_t, int,
+ const struct timespec *, struct timespec *);
int__sys_close(int);
int__sys_connect(int, const struct sockaddr *, __socklen_t);
int__sys_fcntl(int, int, ...);
Modified: head/lib/libc/include/namespace.h
==
--- head/lib/libc/include/namespace.h Sun Mar 19 00:36:29 2017
(r315525)
+++ head/lib/libc/include/namespace.h Sun Mar 19 00:51:12 2017
(r315526)
@@ -56,6 +56,7 @@
#definebind_bind
#define__cap_get_fd___cap_get_fd
#define__cap_set_fd___cap_set_fd
+#defineclock_nanosleep _