aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorLukasz Majewski <lukma@denx.de>2020-11-12 12:24:04 +0100
committerLukasz Majewski <lukma@denx.de>2020-11-14 22:12:40 +0100
commit7ed2b6921feb51d3fecdd0b72e8ab7a7f37ba4ae (patch)
tree397047b7c0f29a7f2967606bd2a70dd70d199d76 /sysdeps
parenteb60eda2b97ce19aba72e7f544e88e49899bc1fd (diff)
downloadglibc-7ed2b6921feb51d3fecdd0b72e8ab7a7f37ba4ae.zip
glibc-7ed2b6921feb51d3fecdd0b72e8ab7a7f37ba4ae.tar.gz
glibc-7ed2b6921feb51d3fecdd0b72e8ab7a7f37ba4ae.tar.bz2
nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64
On ports with __TIMESIZE != 64 the remaining time argument always receives pointer to struct __timespec64 instance. This is the different behavior when compared to 64 bit versions of clock_nanosleep and nanosleep functions, which receive NULL. To avoid any potential issues, we also pass NULL when *rem pointer is NULL. Reported-by: Andreas Schwab <schwab@suse.de> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/sysv/linux/clock_nanosleep.c3
-rw-r--r--sysdeps/unix/sysv/linux/nanosleep.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c
index 6ad3321..82cd11a 100644
--- a/sysdeps/unix/sysv/linux/clock_nanosleep.c
+++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c
@@ -78,7 +78,8 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
struct __timespec64 treq64, trem64;
treq64 = valid_timespec_to_timespec64 (*req);
- r = __clock_nanosleep_time64 (clock_id, flags, &treq64, &trem64);
+ r = __clock_nanosleep_time64 (clock_id, flags, &treq64,
+ rem != NULL ? &trem64 : NULL);
if (r == EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0)
*rem = valid_timespec64_to_timespec (trem64);
diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c
index 8f4ee0f..e58815c 100644
--- a/sysdeps/unix/sysv/linux/nanosleep.c
+++ b/sysdeps/unix/sysv/linux/nanosleep.c
@@ -39,7 +39,7 @@ __nanosleep (const struct timespec *req, struct timespec *rem)
struct __timespec64 treq64, trem64;
treq64 = valid_timespec_to_timespec64 (*req);
- int ret = __nanosleep64 (&treq64, &trem64);
+ int ret = __nanosleep64 (&treq64, rem != NULL ? &trem64 : NULL);
if (ret != 0 && errno == EINTR && rem != NULL)
*rem = valid_timespec64_to_timespec (trem64);