* [PATCH] nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64
@ 2020-11-12 14:25 Lukasz Majewski
2020-11-12 14:35 ` Adhemerval Zanella
2020-11-13 0:33 ` Alistair Francis
0 siblings, 2 replies; 3+ messages in thread
From: Lukasz Majewski @ 2020-11-12 14:25 UTC (permalink / raw)
To: Joseph Myers, Paul Eggert, Adhemerval Zanella
Cc: Alistair Francis, Arnd Bergmann, Alistair Francis, GNU C Library,
Florian Weimer, Carlos O'Donell, Stepan Golosunov,
Andreas Schwab, Zack Weinberg, Lukasz Majewski
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>
---
sysdeps/unix/sysv/linux/clock_nanosleep.c | 3 ++-
sysdeps/unix/sysv/linux/nanosleep.c | 2 +-
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 6ad3321435..82cd11a564 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 8f4ee0f744..e58815c4d0 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);
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64
2020-11-12 14:25 [PATCH] nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64 Lukasz Majewski
@ 2020-11-12 14:35 ` Adhemerval Zanella
2020-11-13 0:33 ` Alistair Francis
1 sibling, 0 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2020-11-12 14:35 UTC (permalink / raw)
To: Lukasz Majewski, Joseph Myers, Paul Eggert
Cc: Alistair Francis, Arnd Bergmann, Alistair Francis, GNU C Library,
Florian Weimer, Carlos O'Donell, Stepan Golosunov,
Andreas Schwab, Zack Weinberg
On 12/11/2020 11:25, Lukasz Majewski wrote:
> 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>
LGTM, thanks.
> ---
> sysdeps/unix/sysv/linux/clock_nanosleep.c | 3 ++-
> sysdeps/unix/sysv/linux/nanosleep.c | 2 +-
> 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 6ad3321435..82cd11a564 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);
Ok.
> diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c
> index 8f4ee0f744..e58815c4d0 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);
>
Ok.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64
2020-11-12 14:25 [PATCH] nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64 Lukasz Majewski
2020-11-12 14:35 ` Adhemerval Zanella
@ 2020-11-13 0:33 ` Alistair Francis
1 sibling, 0 replies; 3+ messages in thread
From: Alistair Francis @ 2020-11-13 0:33 UTC (permalink / raw)
To: Lukasz Majewski
Cc: Joseph Myers, Paul Eggert, Adhemerval Zanella, Arnd Bergmann,
Alistair Francis, GNU C Library, Florian Weimer,
Carlos O'Donell, Stepan Golosunov, Andreas Schwab,
Zack Weinberg
On Thu, Nov 12, 2020 at 6:26 AM Lukasz Majewski <lukma@denx.de> wrote:
>
> 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>
Alistair
> ---
> sysdeps/unix/sysv/linux/clock_nanosleep.c | 3 ++-
> sysdeps/unix/sysv/linux/nanosleep.c | 2 +-
> 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 6ad3321435..82cd11a564 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 8f4ee0f744..e58815c4d0 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);
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-13 0:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 14:25 [PATCH] nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64 Lukasz Majewski
2020-11-12 14:35 ` Adhemerval Zanella
2020-11-13 0:33 ` Alistair Francis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).