This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC v1 01/16] sysdeps/nanosleep: Use clock_nanosleep_time64 instead of nanosleep
- From: Alistair Francis <alistair dot francis at wdc dot com>
- To: libc-alpha at sourceware dot org
- Cc: alistair dot francis at wdc dot com, alistair23 at gmail dot com
- Date: Fri, 21 Jun 2019 21:37:15 -0700
- Subject: [RFC v1 01/16] sysdeps/nanosleep: Use clock_nanosleep_time64 instead of nanosleep
- Ironport-sdr: 1tS2bbF51aXJgVTjkbPpMArowVIGfVJhkttNGNd9YrfHePq/jdwloGhXIkwhiZM8Y1r17MTGdY iLp8HOg0/ct1Cxqb1wMvKu/WqbDOn/a+J3wWqLM03rcriazFpatdyDtekIngsRbKPNwSUE85UN VMznFVYeu6tJbVAgbF1Wm3rHN87VH+W69h7N0pZueTubzF9BSjJ2+eodtWTr24KaSb2nB9lw3n VLmz7g/RHyf7Gakjk3Yh03c/DjFHzLpmwDDTSMxHhCuoVmu0Q/XExb7IohNwKVxl7xhC+yjB66 A7VZ7QZtozhVZNfZUR+Q9fpj
- Ironport-sdr: OCkxCpkRg9iJ9D9ervZOX60Q/FGYZw7EDV4hBaDrLuyX8yfFPiEmRTZpzQNkhlid3kW84pvmUo E1HUoSCTO786QP0LC4H6zoj9kDMJddeXaDQlbFTFZ3MSefB8D3VAcUbK351iGHqxYELvFKH8fj 82g9FacX7M6jhBA2/m2q26xa/U2pI/C0fEkH1uZLZdU/+wtkkTu0b0fT/YnypEapjpshHuX+Dj aN70936GQPde5nikKwxYpxqL7Im/ulUf41BRg2C1fnHGvji4UQ9fOJeTbkm2aiT6uOiobdEC1v eCQ=
- References: <cover.1561177967.git.alistair.francis@wdc.com>
The nanosleep syscall is not supported on newer 32-bit platforms (such
as RV32). To fix this issue let's change to using clock_nanosleep_time64
instead.
Let's use CLOCK_REALTIME when calling clock_nanosleep_time64 as the
Linux specification says:
"POSIX.1 specifies that nanosleep() should measure time against the
CLOCK_REALTIME clock. However, Linux measures the time using the
CLOCK_MONOTONIC clock. This probably does not matter, since the POSIX.1
specification for clock_settime(2) says that discontinuous changes in
CLOCK_REALTIME should not affect nanosleep()"
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
ChangeLog | 6 ++++++
nptl/thrd_sleep.c | 3 ++-
sysdeps/unix/sysv/linux/nanosleep.c | 3 ++-
sysdeps/unix/sysv/linux/nanosleep_nocancel.c | 3 ++-
4 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 05291d7825..b90c5ab60c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-06-21 Alistair Francis <alistair.francis@wdc.com>
+
+ * nptl/thrd_sleep.c: Use clock_nanosleep_time64 instead of nanosleep.
+ * sysdeps/unix/sysv/linux/nanosleep.c: Likewise.
+ * sysdeps/unix/sysv/linux/nanosleep_nocancel.c: Likewise.
+
2019-06-20 Dmitry V. Levin <ldv@altlinux.org>
Florian Weimer <fweimer@redhat.com>
diff --git a/nptl/thrd_sleep.c b/nptl/thrd_sleep.c
index 07a51808df..82a3b84366 100644
--- a/nptl/thrd_sleep.c
+++ b/nptl/thrd_sleep.c
@@ -25,7 +25,8 @@ int
thrd_sleep (const struct timespec* time_point, struct timespec* remaining)
{
INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL_CANCEL (nanosleep, err, time_point, remaining);
+ int ret = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, err,
+ CLOCK_REALTIME, 0, time_point, remaining);
if (INTERNAL_SYSCALL_ERROR_P (ret, err))
{
/* C11 states thrd_sleep function returns -1 if it has been interrupted
diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c
index f14ae565af..bb40121fb6 100644
--- a/sysdeps/unix/sysv/linux/nanosleep.c
+++ b/sysdeps/unix/sysv/linux/nanosleep.c
@@ -25,7 +25,8 @@ int
__nanosleep (const struct timespec *requested_time,
struct timespec *remaining)
{
- return SYSCALL_CANCEL (nanosleep, requested_time, remaining);
+ return SYSCALL_CANCEL (clock_nanosleep_time64, CLOCK_REALTIME, 0,
+ requested_time, remaining);
}
hidden_def (__nanosleep)
weak_alias (__nanosleep, nanosleep)
diff --git a/sysdeps/unix/sysv/linux/nanosleep_nocancel.c b/sysdeps/unix/sysv/linux/nanosleep_nocancel.c
index 122ba627ff..8cc56f42d0 100644
--- a/sysdeps/unix/sysv/linux/nanosleep_nocancel.c
+++ b/sysdeps/unix/sysv/linux/nanosleep_nocancel.c
@@ -24,6 +24,7 @@ int
__nanosleep_nocancel (const struct timespec *requested_time,
struct timespec *remaining)
{
- return INLINE_SYSCALL_CALL (nanosleep, requested_time, remaining);
+ return INLINE_SYSCALL_CALL (clock_nanosleep_time64, CLOCK_REALTIME, 0,
+ requested_time, remaining);
}
hidden_def (__nanosleep_nocancel)
--
2.22.0