[PATCH 01/23] linux: Simplify clock_adjtime

classic Classic list List threaded Threaded
51 messages Options
123
Reply | Threaded
Open this post in threaded view
|

[PATCH 21/23] linux: Consolidate utimes

Sourceware - libc-alpha mailing list
The generic version does not have time64 support and Linux default
uses utimensat.  With hppa version gone, __ASSUME_UTIMES is not used
anymore.

Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
kernel).
---
 sysdeps/unix/sysv/linux/generic/utimes.c      | 46 -------------------
 .../unix/sysv/linux/hppa/kernel-features.h    |  5 --
 sysdeps/unix/sysv/linux/hppa/utimes.c         | 30 ------------
 3 files changed, 81 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/generic/utimes.c
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/utimes.c

diff --git a/sysdeps/unix/sysv/linux/generic/utimes.c b/sysdeps/unix/sysv/linux/generic/utimes.c
deleted file mode 100644
index 0a8100e1b8..0000000000
--- a/sysdeps/unix/sysv/linux/generic/utimes.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* utimes -- Change access and modification times of file.  Linux version.
-   Copyright (C) 2011-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <[hidden email]>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <stddef.h>
-#include <utime.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <sysdep.h>
-
-
-/* Change the access time of FILE to TVP[0] and
-   the modification time of FILE to TVP[1].  */
-int
-__utimes (const char *file, const struct timeval tvp[2])
-{
-  struct timespec ts[2];
-  struct timespec *tsp = NULL;
-
-  if (tvp)
-    {
-      TIMEVAL_TO_TIMESPEC (&tvp[0], &ts[0]);
-      TIMEVAL_TO_TIMESPEC (&tvp[1], &ts[1]);
-      tsp = &ts[0];
-    }
-
-  return INLINE_SYSCALL (utimensat, 4, AT_FDCWD, file, tsp, 0);
-}
-
-weak_alias (__utimes, utimes)
diff --git a/sysdeps/unix/sysv/linux/hppa/kernel-features.h b/sysdeps/unix/sysv/linux/hppa/kernel-features.h
index 8548b5c258..80eec02314 100644
--- a/sysdeps/unix/sysv/linux/hppa/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/hppa/kernel-features.h
@@ -18,11 +18,6 @@
    <https://www.gnu.org/licenses/>.  */
 
 
-/* Support for the utimes syscall was added in 3.14.  */
-#if __LINUX_KERNEL_VERSION >= 0x030e00
-# define __ASSUME_UTIMES 1
-#endif
-
 #include_next <kernel-features.h>
 
 #define __ASSUME_RECV_SYSCALL   1
diff --git a/sysdeps/unix/sysv/linux/hppa/utimes.c b/sysdeps/unix/sysv/linux/hppa/utimes.c
deleted file mode 100644
index a9c4a7ff45..0000000000
--- a/sysdeps/unix/sysv/linux/hppa/utimes.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Implement utimes for hppa.
-   Copyright (C) 2014-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-/* hppa has the utimensat syscall in all supported kernel versions but
-   gained the utimes syscall later, so use the linux-generic
-   implementation of utimes in terms of the utimensat syscall unless
-   the utimes syscall is known to be available.  */
-
-#include <kernel-features.h>
-
-#ifdef __ASSUME_UTIMES
-# include <sysdeps/unix/sysv/linux/utimes.c>
-#else
-# include <sysdeps/unix/sysv/linux/generic/utimes.c>
-#endif
--
2.25.1

Reply | Threaded
Open this post in threaded view
|

[PATCH 22/23] linux: Fix time64 support for futimesat

Sourceware - libc-alpha mailing list
In reply to this post by Sourceware - libc-alpha mailing list
The generic implementation does not support time64 and the default
one return overflow for invalid tv_sec with UTIME_NOW / UTIME_OMIT
(which is valid since tv_sec in such cases is ignored by the
kernel).

Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
kernel).
---
 sysdeps/unix/sysv/linux/generic/futimesat.c | 52 ---------------------
 sysdeps/unix/sysv/linux/utimensat.c         |  8 +++-
 2 files changed, 6 insertions(+), 54 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/generic/futimesat.c

diff --git a/sysdeps/unix/sysv/linux/generic/futimesat.c b/sysdeps/unix/sysv/linux/generic/futimesat.c
deleted file mode 100644
index 7be1fbc252..0000000000
--- a/sysdeps/unix/sysv/linux/generic/futimesat.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* futimesat -- Change access and modification times of file.  Linux version.
-   Copyright (C) 2005-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <[hidden email]>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-#include <utime.h>
-#include <sys/time.h>
-#include <sysdep.h>
-
-
-/* Change the access time of FILE relative to FD to TVP[0] and
-   the modification time of FILE to TVP[1].  */
-int
-futimesat (int fd, const char *file, const struct timeval tvp[2])
-{
-  struct timespec tsp[2];
-  int result;
-
-  if (tvp)
-    {
-      if (tvp[0].tv_usec >= 1000000 || tvp[0].tv_usec < 0
-          || tvp[1].tv_usec >= 1000000 || tvp[1].tv_usec < 0)
-        {
-          __set_errno (EINVAL);
-          return -1;
-        }
-      TIMEVAL_TO_TIMESPEC (&tvp[0], &tsp[0]);
-      TIMEVAL_TO_TIMESPEC (&tvp[1], &tsp[1]);
-    }
-
-  result = INLINE_SYSCALL (utimensat, 4, fd, file, tvp ? tsp : NULL, 0);
-  return result;
-}
diff --git a/sysdeps/unix/sysv/linux/utimensat.c b/sysdeps/unix/sysv/linux/utimensat.c
index ea23c2f051..72784d824a 100644
--- a/sysdeps/unix/sysv/linux/utimensat.c
+++ b/sysdeps/unix/sysv/linux/utimensat.c
@@ -36,9 +36,13 @@ __utimensat64_helper (int fd, const char *file,
   if (ret == 0 || errno != ENOSYS)
     return ret;
 
+  /* For UTIME_NOW and UTIME_OMIT the value of tv_sec field is ignored.  */
+# define NS_VALID(ns) \
+  ((((ns).tv_nsec == UTIME_NOW || (ns).tv_nsec == UTIME_OMIT) \
+   || in_time_t_range ((ns).tv_sec)))
+
   if (tsp64 != NULL
-      && (! in_time_t_range (tsp64[0].tv_sec)
-          || ! in_time_t_range (tsp64[1].tv_sec)))
+      && (!NS_VALID (tsp64[0]) || !NS_VALID (tsp64[1])))
     {
       __set_errno (EOVERFLOW);
       return -1;
--
2.25.1

Reply | Threaded
Open this post in threaded view
|

[PATCH 23/23] linux: Add time64 support for nanosleep

Sourceware - libc-alpha mailing list
In reply to this post by Sourceware - libc-alpha mailing list
It uses __clock_nanosleep64 and adds the __nanosleep64 symbol.

Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
kernel).
---
 include/time.h                            | 19 ++++++---
 sysdeps/unix/sysv/linux/clock_nanosleep.c |  8 ++--
 sysdeps/unix/sysv/linux/nanosleep.c       | 50 +++++++++++++++++++++++
 3 files changed, 68 insertions(+), 9 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/nanosleep.c

diff --git a/include/time.h b/include/time.h
index 936486e206..ad0476be05 100644
--- a/include/time.h
+++ b/include/time.h
@@ -271,6 +271,15 @@ extern struct tm *__tz_convert (__time64_t timer, int use_localtime,
 extern int __nanosleep (const struct timespec *__requested_time,
  struct timespec *__remaining);
 hidden_proto (__nanosleep)
+#if __TIMESIZE == 64
+# define __nanosleep64 __nanosleep
+#else
+extern int __nanosleep64 (const struct __timespec64 *__requested_time,
+  struct __timespec64 *__remaining);
+hidden_proto (__nanosleep64)
+#endif
+
+
 extern int __getdate_r (const char *__string, struct tm *__resbufp)
   attribute_hidden;
 
@@ -294,14 +303,14 @@ libc_hidden_proto (__difftime64)
 extern double __difftime (time_t time1, time_t time0);
 
 #if __TIMESIZE == 64
-# define __clock_nanosleep_time64 __clock_nanosleep
+# define __clock_nanosleep64 __clock_nanosleep
 # define __clock_gettime64 __clock_gettime
 # define __timespec_get64 __timespec_get
 #else
-extern int __clock_nanosleep_time64 (clockid_t clock_id,
-                                     int flags, const struct __timespec64 *req,
-                                     struct __timespec64 *rem);
-libc_hidden_proto (__clock_nanosleep_time64)
+extern int __clock_nanosleep64 (clockid_t clock_id,
+                                int flags, const struct __timespec64 *req,
+                                struct __timespec64 *rem);
+libc_hidden_proto (__clock_nanosleep64)
 extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp);
 libc_hidden_proto (__clock_gettime64)
 extern int __timespec_get64 (struct __timespec64 *ts, int base);
diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c
index 6ad3321435..697e403ac8 100644
--- a/sysdeps/unix/sysv/linux/clock_nanosleep.c
+++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c
@@ -27,8 +27,8 @@
 /* We can simply use the syscall.  The CPU clocks are not supported
    with this function.  */
 int
-__clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec64 *req,
-                          struct __timespec64 *rem)
+__clock_nanosleep64 (clockid_t clock_id, int flags,
+     const struct __timespec64 *req, struct __timespec64 *rem)
 {
   if (clock_id == CLOCK_THREAD_CPUTIME_ID)
     return EINVAL;
@@ -68,7 +68,7 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec
 }
 
 #if __TIMESIZE != 64
-libc_hidden_def (__clock_nanosleep_time64)
+libc_hidden_def (__clock_nanosleep64)
 
 int
 __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
@@ -78,7 +78,7 @@ __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_nanosleep64 (clock_id, flags, &treq64, &trem64);
 
   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
new file mode 100644
index 0000000000..7e13a98b4c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nanosleep.c
@@ -0,0 +1,50 @@
+/* High-resolution sleep.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <time.h>
+#include <errno.h>
+
+int
+__nanosleep64 (const struct __timespec64 *req, struct __timespec64 *rem)
+{
+  int ret = __clock_nanosleep64 (CLOCK_REALTIME, 0, req, rem);
+  if (ret != 0)
+    {
+      __set_errno (ret);
+      return -1;
+    }
+  return 0;
+}
+#if __TIMESIZE != 64
+libc_hidden_def (__nanosleep64)
+
+int
+__nanosleep (const struct timespec *req, struct timespec *rem)
+{
+  struct __timespec64 treq64, trem64;
+
+  treq64 = valid_timespec_to_timespec64 (*req);
+  int ret = __nanosleep64 (&treq64, &trem64);
+
+  if (ret != 0 && errno == EINTR && rem != NULL)
+    *rem = valid_timespec64_to_timespec (trem64);
+  return ret;
+}
+#endif
+libc_hidden_def (__nanosleep)
+weak_alias (__nanosleep, nanosleep)
--
2.25.1

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 01/23] linux: Simplify clock_adjtime

Sourceware - libc-alpha mailing list
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, Jul 13, 2020 at 10:10 AM Adhemerval Zanella
<[hidden email]> wrote:
>
> With arch-syscall.h it can now assumes the existance of either
> __NR_clock_adjtime or __NR_clock_adjtime_time64.  The 32-bit time_t
> support is now only build for !__ASSUME_TIME64_SYSCALLS.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).

Looks good.

Reviewed-by: Alistair Francis <[hidden email]>

Alistair

> ---
>  sysdeps/unix/sysv/linux/clock_adjtime.c | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/clock_adjtime.c b/sysdeps/unix/sysv/linux/clock_adjtime.c
> index 764a60b9bf..4caff2ad05 100644
> --- a/sysdeps/unix/sysv/linux/clock_adjtime.c
> +++ b/sysdeps/unix/sysv/linux/clock_adjtime.c
> @@ -26,15 +26,13 @@
>  int
>  __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64)
>  {
> -#ifdef __ASSUME_TIME64_SYSCALLS
> -# ifndef __NR_clock_adjtime64
> -#  define __NR_clock_adjtime64 __NR_clock_adjtime
> -# endif
> -       return INLINE_SYSCALL_CALL (clock_adjtime64, clock_id, tx64);
> -#else
> -  int ret = INLINE_SYSCALL_CALL (clock_adjtime64, clock_id, tx64);
> -  if (errno != ENOSYS)
> -    return ret;
> +#ifndef __NR_clock_adjtime64
> +# define __NR_clock_adjtime64 __NR_clock_adjtime
> +#endif
> +  int r = INLINE_SYSCALL_CALL (clock_adjtime64, clock_id, tx64);
> +#ifndef __ASSUME_TIME64_SYSCALLS
> +  if (r >= 0 || errno != ENOSYS)
> +    return r;
>
>    if (tx64->modes & ADJ_SETOFFSET
>        && ! in_time_t_range (tx64->time.tv_sec))
> @@ -44,12 +42,11 @@ __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64)
>      }
>
>    struct timex tx32 = valid_timex64_to_timex (*tx64);
> -  int retval = INLINE_SYSCALL_CALL (clock_adjtime, clock_id, &tx32);
> -  if (retval >= 0)
> +  r = INLINE_SYSCALL_CALL (clock_adjtime, clock_id, &tx32);
> +  if (r >= 0)
>      *tx64 = valid_timex_to_timex64 (tx32);
> -
> -  return retval;
>  #endif
> +  return r;
>  }
>
>  #if __TIMESIZE != 64
> --
> 2.25.1
>
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 07/23] linux: Simplify ppoll

Joseph Myers
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020, Adhemerval Zanella via Libc-alpha wrote:

> With arch-syscall.h it can now assumes the existance of either
> __NR_ppoll or __NR_ppoll_time64.  The 32-bit time_t support is now
> only build for !__ASSUME_TIME64_SYSCALLS.

> +#ifdef __ASSUME_TIME64_SYSCALLS
>    if (ret >= 0 || errno != ENOSYS)
>      return ret;

Should this be #ifndef?  It looks like it's building the fallback code in
exactly the case where it's not needed.

--
Joseph S. Myers
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 01/23] linux: Simplify clock_adjtime

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020 14:10:03 -0300
Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:

> With arch-syscall.h it can now assumes the existance of either
> __NR_clock_adjtime or __NR_clock_adjtime_time64.  The 32-bit time_t
> support is now only build for !__ASSUME_TIME64_SYSCALLS.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).

This will definitely simplify the code base.

> ---
>  sysdeps/unix/sysv/linux/clock_adjtime.c | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/clock_adjtime.c
> b/sysdeps/unix/sysv/linux/clock_adjtime.c index
> 764a60b9bf..4caff2ad05 100644 ---
> a/sysdeps/unix/sysv/linux/clock_adjtime.c +++
> b/sysdeps/unix/sysv/linux/clock_adjtime.c @@ -26,15 +26,13 @@
>  int
>  __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64)
>  {
> -#ifdef __ASSUME_TIME64_SYSCALLS
> -# ifndef __NR_clock_adjtime64
> -#  define __NR_clock_adjtime64 __NR_clock_adjtime
> -# endif
> - return INLINE_SYSCALL_CALL (clock_adjtime64, clock_id, tx64);
> -#else
> -  int ret = INLINE_SYSCALL_CALL (clock_adjtime64, clock_id, tx64);
> -  if (errno != ENOSYS)
> -    return ret;
> +#ifndef __NR_clock_adjtime64
> +# define __NR_clock_adjtime64 __NR_clock_adjtime
> +#endif
> +  int r = INLINE_SYSCALL_CALL (clock_adjtime64, clock_id, tx64);
> +#ifndef __ASSUME_TIME64_SYSCALLS
> +  if (r >= 0 || errno != ENOSYS)
> +    return r;
>  
>    if (tx64->modes & ADJ_SETOFFSET
>        && ! in_time_t_range (tx64->time.tv_sec))
> @@ -44,12 +42,11 @@ __clock_adjtime64 (const clockid_t clock_id,
> struct __timex64 *tx64) }
>  
>    struct timex tx32 = valid_timex64_to_timex (*tx64);
> -  int retval = INLINE_SYSCALL_CALL (clock_adjtime, clock_id, &tx32);
> -  if (retval >= 0)
> +  r = INLINE_SYSCALL_CALL (clock_adjtime, clock_id, &tx32);
> +  if (r >= 0)
>      *tx64 = valid_timex_to_timex64 (tx32);
> -
> -  return retval;
>  #endif
> +  return r;
>  }
>  
>  #if __TIMESIZE != 64
Reviewed-by: Lukasz Majewski <[hidden email]>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 03/23] linux: Simplify clock_nanosleep

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020 14:10:05 -0300
Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:

> With arch-syscall.h it can now assumes the existance of either
> __NR_clock_nanosleep or __NR_clock_nanosleep_time64.  The 32-bit
> time_t support is now only build for !__ASSUME_TIME64_SYSCALLS.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).

Reviewed-by: Lukasz Majewski <[hidden email]>

> ---
>  sysdeps/unix/sysv/linux/clock_nanosleep.c | 33
> ++++++++--------------- 1 file changed, 11 insertions(+), 22
> deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c
> b/sysdeps/unix/sysv/linux/clock_nanosleep.c index
> cc7a09569d..6ad3321435 100644 ---
> a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++
> b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -30,8 +30,6 @@ int
>  __clock_nanosleep_time64 (clockid_t clock_id, int flags, const
> struct __timespec64 *req, struct __timespec64 *rem)
>  {
> -  int r;
> -
>    if (clock_id == CLOCK_THREAD_CPUTIME_ID)
>      return EINVAL;
>    if (clock_id == CLOCK_PROCESS_CPUTIME_ID)
> @@ -39,22 +37,15 @@ __clock_nanosleep_time64 (clockid_t clock_id, int
> flags, const struct __timespec
>    /* If the call is interrupted by a signal handler or encounters an
> error, it returns a positive value similar to errno.  */
> -#ifdef __ASSUME_TIME64_SYSCALLS
> -# ifndef __NR_clock_nanosleep_time64
> -#  define __NR_clock_nanosleep_time64 __NR_clock_nanosleep
> -# endif
> -  r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id,
> -                               flags, req, rem);
> -#else
> -# ifdef __NR_clock_nanosleep_time64
> -  r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id,
> -                               flags, req, rem);
> -
> -  if (! INTERNAL_SYSCALL_ERROR_P (r))
> -    return 0;
> -  if (INTERNAL_SYSCALL_ERRNO (r) != ENOSYS)
> -    return INTERNAL_SYSCALL_ERRNO (r);
> -# endif /* __NR_clock_nanosleep_time64 */
> +#ifndef __NR_clock_nanosleep_time64
> +# define __NR_clock_nanosleep_time64 __NR_clock_nanosleep
> +#endif
> +  int r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id,
> +   flags, req, rem);
> +
> +#ifndef __ASSUME_TIME64_SYSCALLS
> +  if (r == 0 || r != -ENOSYS)
> +    return -r;
>  
>    if (! in_time_t_range (req->tv_sec))
>      {
> @@ -68,14 +59,12 @@ __clock_nanosleep_time64 (clockid_t clock_id, int
> flags, const struct __timespec &ts32, &tr32);
>    if (INTERNAL_SYSCALL_ERROR_P (r))
>      {
> -      if (INTERNAL_SYSCALL_ERRNO (r) == EINTR && rem != NULL
> -  && (flags & TIMER_ABSTIME) == 0)
> +      if (r == -EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0)
>   *rem = valid_timespec_to_timespec64 (tr32);
>      }
>  #endif /* __ASSUME_TIME64_SYSCALLS */
>  
> -  return (INTERNAL_SYSCALL_ERROR_P (r)
> -  ? INTERNAL_SYSCALL_ERRNO (r) : 0);
> +  return -r;
>  }
>  
>  #if __TIMESIZE != 64



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 04/23] linux: Simplify clock_settime

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020 14:10:06 -0300
Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:

> With arch-syscall.h it can now assumes the existance of either
> __NR_clock_settime or __NR_clock_settime_time64.  The 32-bit
> time_t support is now only build for !__ASSUME_TIME64_SYSCALLS.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).
> ---
>  sysdeps/unix/sysv/linux/clock_settime.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/clock_settime.c
> b/sysdeps/unix/sysv/linux/clock_settime.c index
> ebda871f4c..ce0bf622c0 100644 ---
> a/sysdeps/unix/sysv/linux/clock_settime.c +++
> b/sysdeps/unix/sysv/linux/clock_settime.c @@ -32,17 +32,15 @@
> __clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp)
> return -1; }
>  
> -#ifdef __ASSUME_TIME64_SYSCALLS
> -# ifndef __NR_clock_settime64
> -#  define __NR_clock_settime64 __NR_clock_settime
> -# endif
> -  return INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp);
> -#else
> -# ifdef __NR_clock_settime64
> +#ifndef __NR_clock_settime64
> +# define __NR_clock_settime64 __NR_clock_settime
> +#endif
>    int ret = INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp);
> +
> +#ifndef __ASSUME_TIME64_SYSCALLS
>    if (ret == 0 || errno != ENOSYS)
>      return ret;
> -# endif
> +
>    if (! in_time_t_range (tp->tv_sec))
>      {
>        __set_errno (EOVERFLOW);
> @@ -50,8 +48,10 @@ __clock_settime64 (clockid_t clock_id, const
> struct __timespec64 *tp) }
>  
>    struct timespec ts32 = valid_timespec64_to_timespec (*tp);
> -  return INLINE_SYSCALL_CALL (clock_settime, clock_id, &ts32);
> +  ret = INLINE_SYSCALL_CALL (clock_settime, clock_id, &ts32);
>  #endif
> +
> +  return ret;
>  }
>  
>  #if __TIMESIZE != 64
Reviewed-by: Lukasz Majewski <[hidden email]>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 05/23] linux: Simplify mq_timedreceive

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020 14:10:07 -0300
Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:

> With arch-syscall.h it can now assumes the existance of either
> __NR_mq_timedreceive or __NR_mq_timedreceive_time64.  The 32-bit
> time_t support is now only build for !__ASSUME_TIME64_SYSCALLS.
>
> The internal 64-bit time_t names is also adjusted to use the
> other y2038 symbol names.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).
> ---
>  include/mqueue.h                          | 16 ++++++------
>  sysdeps/unix/sysv/linux/mq_timedreceive.c | 32
> +++++++++++------------ 2 files changed, 24 insertions(+), 24
> deletions(-)
>
> diff --git a/include/mqueue.h b/include/mqueue.h
> index 98e4596c22..b3ee8b7462 100644
> --- a/include/mqueue.h
> +++ b/include/mqueue.h
> @@ -13,18 +13,18 @@ hidden_proto (mq_setattr)
>  #include <struct___timespec64.h>
>  #if __TIMESIZE == 64
>  # define __mq_timedsend_time64 __mq_timedsend
> -# define __mq_timedreceive_time64 __mq_timedreceive
> +# define __mq_timedreceive64 __mq_timedreceive
>  #else
>  extern int __mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr,
>                                    size_t msg_len, unsigned int
> msg_prio, const struct __timespec64 *abs_timeout);
>  librt_hidden_proto (__mq_timedsend_time64)
> -extern ssize_t __mq_timedreceive_time64 (mqd_t mqdes,
> -                                         char *__restrict msg_ptr,
> -                                         size_t msg_len,
> -                                         unsigned int *__restrict
> msg_prio,
> -                                         const struct __timespec64
> *__restrict
> -                                         abs_timeout);
> -librt_hidden_proto (__mq_timedreceive_time64)
> +extern ssize_t __mq_timedreceive64 (mqd_t mqdes,
Just informative - the Linux kernel has following naming convention:

clock_gettime -> clock_gettime64 (the 64 is appended only for syscalls
which ends with "time").

but

futex -> futex_time64 (the "time64" is appended when there is no "time"
in the last part of the syscall name).

We can have the simpler convention - by appending "64" to syscalls in
glibc.

For the rest of the patch:
Reviewed-by: Lukasz Majewski <[hidden email]>

> +                                    char *__restrict msg_ptr,
> +                                    size_t msg_len,
> +                                    unsigned int *__restrict
> msg_prio,
> +                                    const struct __timespec64
> *__restrict
> +                                    abs_timeout);
> +librt_hidden_proto (__mq_timedreceive64)
>  #endif
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/mq_timedreceive.c
> b/sysdeps/unix/sysv/linux/mq_timedreceive.c index
> 728a63d1ec..61c27fd8f7 100644 ---
> a/sysdeps/unix/sysv/linux/mq_timedreceive.c +++
> b/sysdeps/unix/sysv/linux/mq_timedreceive.c @@ -22,19 +22,17 @@
>  /* Receive the oldest from highest priority messages in message queue
>     MQDES, stop waiting if ABS_TIMEOUT expires.  */
>  ssize_t
> -__mq_timedreceive_time64 (mqd_t mqdes, char *__restrict msg_ptr,
> size_t msg_len,
> -                          unsigned int *__restrict msg_prio,
> -                          const struct __timespec64 *__restrict
> abs_timeout) +__mq_timedreceive64 (mqd_t mqdes, char *__restrict
> msg_ptr, size_t msg_len,
> +                     unsigned int *__restrict msg_prio,
> +                     const struct __timespec64 *__restrict
> abs_timeout) {
> -#ifdef __ASSUME_TIME64_SYSCALLS
> -# ifndef __NR_mq_timedreceive_time64
> -#  define __NR_mq_timedreceive_time64 __NR_mq_timedreceive
> -# endif
> -  return SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr,
> msg_len,
> -                         msg_prio, abs_timeout);
> -#else
> +#ifndef __NR_mq_timedreceive_time64
> +# define __NR_mq_timedreceive_time64 __NR_mq_timedreceive
> +#endif
>    int ret = SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr,
> msg_len,
> -                            msg_prio, abs_timeout);
> +    msg_prio, abs_timeout);
> +
> +#ifndef __ASSUME_TIME64_SYSCALLS
>    if (ret == 0 || errno != ENOSYS)
>      return ret;
>  
> @@ -50,13 +48,15 @@ __mq_timedreceive_time64 (mqd_t mqdes, char
> *__restrict msg_ptr, size_t msg_len, ts32 =
> valid_timespec64_to_timespec (*abs_timeout); }
>  
> -  return SYSCALL_CANCEL (mq_timedreceive, mqdes, msg_ptr, msg_len,
> msg_prio,
> -                         abs_timeout != NULL ? &ts32 : NULL);
> +  ret = SYSCALL_CANCEL (mq_timedreceive, mqdes, msg_ptr, msg_len,
> msg_prio,
> + abs_timeout != NULL ? &ts32 : NULL);
>  #endif
> +
> +  return ret;
>  }
>  
>  #if __TIMESIZE != 64
> -librt_hidden_def (__mq_timedreceive_time64)
> +librt_hidden_def (__mq_timedreceive64)
>  
>  ssize_t
>  __mq_timedreceive (mqd_t mqdes, char *__restrict msg_ptr, size_t
> msg_len, @@ -67,8 +67,8 @@ __mq_timedreceive (mqd_t mqdes, char
> *__restrict msg_ptr, size_t msg_len, if (abs_timeout != NULL)
>      ts64 = valid_timespec_to_timespec64 (*abs_timeout);
>  
> -  return __mq_timedreceive_time64 (mqdes, msg_ptr, msg_len, msg_prio,
> -                                   abs_timeout != NULL ? &ts64 :
> NULL);
> +  return __mq_timedreceive64 (mqdes, msg_ptr, msg_len, msg_prio,
> +      abs_timeout != NULL ? &ts64 : NULL);
>  }
>  #endif
>  



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 06/23] linux: Simplify mq_timedsend

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020 14:10:08 -0300
Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:

>  With arch-syscall.h it can now assumes the existance of either
> __NR_mq_timedsend or __NR_mq_timedsend_time64.  The 32-bit
> time_t support is now only build for !__ASSUME_TIME64_SYSCALLS.
>
> The internal 64-bit time_t names is also adjusted to use the
> other y2038 symbol names.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).
> ---
>  include/mqueue.h                       | 10 +++++-----
>  sysdeps/unix/sysv/linux/mq_timedsend.c | 26
> +++++++++++++------------- 2 files changed, 18 insertions(+), 18
> deletions(-)
>
> diff --git a/include/mqueue.h b/include/mqueue.h
> index b3ee8b7462..e0e30dc890 100644
> --- a/include/mqueue.h
> +++ b/include/mqueue.h
> @@ -12,13 +12,13 @@ hidden_proto (mq_setattr)
>  # endif
>  #include <struct___timespec64.h>
>  #if __TIMESIZE == 64
> -# define __mq_timedsend_time64 __mq_timedsend
> +# define __mq_timedsend64 __mq_timedsend
>  # define __mq_timedreceive64 __mq_timedreceive
>  #else
> -extern int __mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr,
> -                                  size_t msg_len, unsigned int
> msg_prio,
> -                                  const struct __timespec64
> *abs_timeout); -librt_hidden_proto (__mq_timedsend_time64)
> +extern int __mq_timedsend64 (mqd_t mqdes, const char *msg_ptr,
> +     size_t msg_len, unsigned int msg_prio,
> +     const struct __timespec64 *abs_timeout);
> +librt_hidden_proto (__mq_timedsend64)
>  extern ssize_t __mq_timedreceive64 (mqd_t mqdes,
>                                      char *__restrict msg_ptr,
>                                      size_t msg_len,
> diff --git a/sysdeps/unix/sysv/linux/mq_timedsend.c
> b/sysdeps/unix/sysv/linux/mq_timedsend.c index f2a43df300..6011db7112
> 100644 --- a/sysdeps/unix/sysv/linux/mq_timedsend.c
> +++ b/sysdeps/unix/sysv/linux/mq_timedsend.c
> @@ -22,19 +22,17 @@
>  /* Add message pointed by MSG_PTR to message queue MQDES, stop
> blocking on full message queue if ABS_TIMEOUT expires.  */
>  int
> -__mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr, size_t
> msg_len,
> -                       unsigned int msg_prio,
> -                       const struct __timespec64 *abs_timeout)
> +__mq_timedsend64 (mqd_t mqdes, const char *msg_ptr, size_t msg_len,
> +  unsigned int msg_prio,
> +  const struct __timespec64 *abs_timeout)
>  {
> -#ifdef __ASSUME_TIME64_SYSCALLS
>  # ifndef __NR_mq_timedsend_time64
>  #  define __NR_mq_timedsend_time64 __NR_mq_timedsend
>  # endif
> -  return SYSCALL_CANCEL (mq_timedsend_time64, mqdes, msg_ptr,
> msg_len,
> -                         msg_prio, abs_timeout);
> -#else
>    int ret = SYSCALL_CANCEL (mq_timedsend_time64, mqdes, msg_ptr,
> msg_len,
> -                            msg_prio, abs_timeout);
> +    msg_prio, abs_timeout);
> +
> +#ifndef __ASSUME_TIME64_SYSCALLS
>    if (ret == 0 || errno != ENOSYS)
>      return ret;
>  
> @@ -50,13 +48,15 @@ __mq_timedsend_time64 (mqd_t mqdes, const char
> *msg_ptr, size_t msg_len, ts32 = valid_timespec64_to_timespec
> (*abs_timeout); }
>  
> -  return SYSCALL_CANCEL (mq_timedsend, mqdes, msg_ptr, msg_len,
> msg_prio,
> -                         abs_timeout != NULL ? &ts32 : NULL);
> +  ret = SYSCALL_CANCEL (mq_timedsend, mqdes, msg_ptr, msg_len,
> msg_prio,
> + abs_timeout != NULL ? &ts32 : NULL);
>  #endif
> +
> +  return ret;
>  }
>  
>  #if __TIMESIZE != 64
> -librt_hidden_def (__mq_timedsend_time64)
> +librt_hidden_def (__mq_timedsend64)
>  
>  int
>  __mq_timedsend (mqd_t mqdes, const char *msg_ptr, size_t msg_len,
> @@ -66,8 +66,8 @@ __mq_timedsend (mqd_t mqdes, const char *msg_ptr,
> size_t msg_len, if (abs_timeout != NULL)
>      ts64 = valid_timespec_to_timespec64 (*abs_timeout);
>  
> -  return __mq_timedsend_time64 (mqdes, msg_ptr, msg_len, msg_prio,
> -                                abs_timeout != NULL ? &ts64 : NULL);
> +  return __mq_timedsend64 (mqdes, msg_ptr, msg_len, msg_prio,
> +   abs_timeout != NULL ? &ts64 : NULL);
>  }
>  #endif
>  
The same comment as for mq_timedreceive.


Reviewed-by: Lukasz Majewski <[hidden email]>

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 07/23] linux: Simplify ppoll

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020 14:10:09 -0300
Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:

> With arch-syscall.h it can now assumes the existance of either
> __NR_ppoll or __NR_ppoll_time64.  The 32-bit time_t support is now
> only build for !__ASSUME_TIME64_SYSCALLS.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).
> ---
>  sysdeps/unix/sysv/linux/ppoll.c | 23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/ppoll.c
> b/sysdeps/unix/sysv/linux/ppoll.c index 0f15636cce..079d56b5eb 100644
> --- a/sysdeps/unix/sysv/linux/ppoll.c
> +++ b/sysdeps/unix/sysv/linux/ppoll.c
> @@ -37,19 +37,16 @@ __ppoll64 (struct pollfd *fds, nfds_t nfds, const
> struct __timespec64 *timeout, timeout = &tval;
>      }
>  
> -#ifdef __ASSUME_TIME64_SYSCALLS
> -# ifndef __NR_ppoll_time64
> -#  define __NR_ppoll_time64 __NR_ppoll
> -# endif
> -  return SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout, sigmask,
> - __NSIG_BYTES);
> -#else
> -# ifdef __NR_ppoll_time64
> +#ifndef __NR_ppoll_time64
> +# define __NR_ppoll_time64 __NR_ppoll
> +#endif
>    int ret = SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout,
> sigmask,
> -                            __NSIG_BYTES);
> +    __NSIG_BYTES);
> +
> +#ifdef __ASSUME_TIME64_SYSCALLS
>    if (ret >= 0 || errno != ENOSYS)
>      return ret;
> -# endif
> +
>    struct timespec ts32;
>    if (timeout)
>      {
> @@ -62,9 +59,11 @@ __ppoll64 (struct pollfd *fds, nfds_t nfds, const
> struct __timespec64 *timeout, ts32 = valid_timespec64_to_timespec
> (*timeout); }
>  
> -  return SYSCALL_CANCEL (ppoll, fds, nfds, timeout ? &ts32 : NULL,
> sigmask,
> -                         __NSIG_BYTES);
> +  ret = SYSCALL_CANCEL (ppoll, fds, nfds, timeout ? &ts32 : NULL,
> sigmask,
> + __NSIG_BYTES);
>  #endif
> +
> +  return ret;
>  }
>  
>  #if __TIMESIZE != 64
Reviewed-by: Lukasz Majewski <[hidden email]>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 08/23] linux: Simplify sched_rr_get_interval

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020 14:10:10 -0300
Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:

> With arch-syscall.h it can now assumes the existance of either
> __NR_sched_rr_get_interval or __NR_sched_rr_get_interval_time64.
> The 32-bit time_t support is now only build for
> !__ASSUME_TIME64_SYSCALLS.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).
> ---
>  sysdeps/unix/sysv/linux/sched_rr_gi.c | 20 ++++++++------------
>  1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/sched_rr_gi.c
> b/sysdeps/unix/sysv/linux/sched_rr_gi.c index 3d7b484591..997562159f
> 100644 --- a/sysdeps/unix/sysv/linux/sched_rr_gi.c
> +++ b/sysdeps/unix/sysv/linux/sched_rr_gi.c
> @@ -25,24 +25,20 @@
>  int
>  __sched_rr_get_interval64 (pid_t pid, struct __timespec64 *tp)
>  {
> -#ifdef __ASSUME_TIME64_SYSCALLS
> -# ifndef __NR_sched_rr_get_interval_time64
> -#  define __NR_sched_rr_get_interval_time64
> __NR_sched_rr_get_interval -# endif
> -  return INLINE_SYSCALL_CALL (sched_rr_get_interval_time64, pid, tp);
> -#else
> -# ifdef __NR_sched_rr_get_interval_time64
> +#ifndef __NR_sched_rr_get_interval_time64
> +# define __NR_sched_rr_get_interval_time64 __NR_sched_rr_get_interval
> +#endif
>    int ret = INLINE_SYSCALL_CALL (sched_rr_get_interval_time64, pid,
> tp); +#ifndef __ASSUME_TIME64_SYSCALLS
>    if (ret == 0 || errno != ENOSYS)
>      return ret;
> -# endif
> +
>    struct timespec tp32;
> -  int retval = INLINE_SYSCALL_CALL (sched_rr_get_interval, pid,
> &tp32);
> -  if (retval == 0)
> +  ret = INLINE_SYSCALL_CALL (sched_rr_get_interval, pid, &tp32);
> +  if (ret == 0)
>      *tp = valid_timespec_to_timespec64 (tp32);
> -
> -  return retval;
>  #endif
> +  return ret;
>  }
>  
>  #if __TIMESIZE != 64
Reviewed-by: Lukasz Majewski <[hidden email]>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 09/23] linux: Simplify timer_gettime

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020 14:10:11 -0300
Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:

> With arch-syscall.h it can now assumes the existance of either
> __NR_timer_gettime or __NR_time_gettime_time64.  The 32-bit time_t
> support is now only build for !__ASSUME_TIME64_SYSCALLS.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).
> ---
>  sysdeps/unix/sysv/linux/timer_gettime.c | 20 ++++++++------------
>  1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/timer_gettime.c
> b/sysdeps/unix/sysv/linux/timer_gettime.c index
> 1e07d4845b..5d31c7c864 100644 ---
> a/sysdeps/unix/sysv/linux/timer_gettime.c +++
> b/sysdeps/unix/sysv/linux/timer_gettime.c @@ -28,27 +28,23 @@
> __timer_gettime64 (timer_t timerid, struct __itimerspec64 *value) {
>    struct timer *kt = (struct timer *) timerid;
>  
> -#ifdef __ASSUME_TIME64_SYSCALLS
> -# ifndef __NR_timer_gettime64
> -#  define __NR_timer_gettime64 __NR_timer_gettime
> -# endif
> -  return INLINE_SYSCALL_CALL (timer_gettime64, kt->ktimerid, value);
> -#else
> -# ifdef __NR_timer_gettime64
> +#ifndef __NR_timer_gettime64
> +# define __NR_timer_gettime64 __NR_timer_gettime
> +#endif
>    int ret = INLINE_SYSCALL_CALL (timer_gettime64, kt->ktimerid,
> value); +#ifndef __ASSUME_TIME64_SYSCALLS
>    if (ret == 0 || errno != ENOSYS)
>      return ret;
> -# endif
> +
>    struct itimerspec its32;
> -  int retval = INLINE_SYSCALL_CALL (timer_gettime, kt->ktimerid,
> &its32);
> -  if (retval == 0)
> +  ret = INLINE_SYSCALL_CALL (timer_gettime, kt->ktimerid, &its32);
> +  if (ret == 0)
>      {
>        value->it_interval = valid_timespec_to_timespec64
> (its32.it_interval); value->it_value = valid_timespec_to_timespec64
> (its32.it_value); }
> -
> -  return retval;
>  #endif
> +  return ret;
>  }
>  
>  #if __TIMESIZE != 64
Reviewed-by: Lukasz Majewski <[hidden email]>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 10/23] linux: Simplify timerfd_settime

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020 14:10:12 -0300
Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:

>  With arch-syscall.h it can now assumes the existance of either
> __NR_timer_settime or __NR_time_settime_time64.  The 32-bit time_t
> support is now only build for !__ASSUME_TIME64_SYSCALLS.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).
> ---
>  sysdeps/unix/sysv/linux/timerfd_settime.c | 23
> +++++++++-------------- 1 file changed, 9 insertions(+), 14
> deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/timerfd_settime.c
> b/sysdeps/unix/sysv/linux/timerfd_settime.c index
> 164b4e860a..7c55e7e8d6 100644 ---
> a/sysdeps/unix/sysv/linux/timerfd_settime.c +++
> b/sysdeps/unix/sysv/linux/timerfd_settime.c @@ -26,18 +26,13 @@ int
>  __timerfd_settime64 (int fd, int flags, const struct __itimerspec64
> *value, struct __itimerspec64 *ovalue)
>  {
> -#ifdef __ASSUME_TIME64_SYSCALLS
> -# ifndef __NR_timerfd_settime64
> -#  define __NR_timerfd_settime64 __NR_timerfd_settime
> -# endif
> -  return INLINE_SYSCALL_CALL (timerfd_settime64, fd, flags, value,
> ovalue); -#else
> -# ifdef __NR_timerfd_settime64
> +#ifndef __NR_timerfd_settime64
> +# define __NR_timerfd_settime64 __NR_timerfd_settime
> +#endif
>    int ret = INLINE_SYSCALL_CALL (timerfd_settime64, fd, flags,
> value, ovalue); +#ifndef __ASSUME_TIME64_SYSCALLS
>    if (ret == 0 || errno != ENOSYS)
>      return ret;
> -# endif
> -  struct itimerspec its32, oits32;
>  
>    if (! in_time_t_range ((value->it_value).tv_sec)
>        || ! in_time_t_range ((value->it_interval).tv_sec))
> @@ -46,19 +41,19 @@ __timerfd_settime64 (int fd, int flags, const
> struct __itimerspec64 *value, return -1;
>      }
>  
> +  struct itimerspec its32, oits32;
>    its32.it_interval = valid_timespec64_to_timespec
> (value->it_interval); its32.it_value = valid_timespec64_to_timespec
> (value->it_value);
> -  int retval = INLINE_SYSCALL_CALL (timerfd_settime, fd, flags,
> -                                    &its32, ovalue ? &oits32 : NULL);
> -  if (retval == 0 && ovalue)
> +  ret = INLINE_SYSCALL_CALL (timerfd_settime, fd, flags,
> +     &its32, ovalue ? &oits32 : NULL);
> +  if (ret == 0 && ovalue != NULL)
>      {
>        ovalue->it_interval = valid_timespec_to_timespec64
> (oits32.it_interval); ovalue->it_value = valid_timespec_to_timespec64
> (oits32.it_value); }
> -
> -  return retval;
>  #endif
> +  return ret;
>  }
>  
>  #if __TIMESIZE != 64
Reviewed-by: Lukasz Majewski <[hidden email]>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 11/23] linux: Simplify utimensat

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
On Mon, 13 Jul 2020 14:10:13 -0300
Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:

> With arch-syscall.h it can now assumes the existance of either
> __NR_utimensat or __NR_utimensat_time64.  The 32-bit time_t
> support is now only build for !__ASSUME_TIME64_SYSCALLS.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).
> ---
>  sysdeps/unix/sysv/linux/utimensat.c | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/utimensat.c
> b/sysdeps/unix/sysv/linux/utimensat.c index eb16f0f3d5..ea23c2f051
> 100644 --- a/sysdeps/unix/sysv/linux/utimensat.c
> +++ b/sysdeps/unix/sysv/linux/utimensat.c
> @@ -28,18 +28,15 @@ int
>  __utimensat64_helper (int fd, const char *file,
>                        const struct __timespec64 tsp64[2], int flags)
>  {
> -#ifdef __ASSUME_TIME64_SYSCALLS
> -# ifndef __NR_utimensat_time64
> -#  define __NR_utimensat_time64 __NR_utimensat
> -# endif
> -  return INLINE_SYSCALL (utimensat_time64, 4, fd, file, &tsp64[0],
> flags); -#else
> -# ifdef __NR_utimensat_time64
> -  int ret = INLINE_SYSCALL (utimensat_time64, 4, fd, file,
> &tsp64[0], flags); +#ifndef __NR_utimensat_time64
> +# define __NR_utimensat_time64 __NR_utimensat
> +#endif
> +  int ret = INLINE_SYSCALL_CALL (utimensat_time64, fd, file,
> &tsp64[0], flags); +#ifndef __ASSUME_TIME64_SYSCALLS
>    if (ret == 0 || errno != ENOSYS)
>      return ret;
> -# endif
> -  if (tsp64
> +
> +  if (tsp64 != NULL
>        && (! in_time_t_range (tsp64[0].tv_sec)
>            || ! in_time_t_range (tsp64[1].tv_sec)))
>      {
> @@ -54,10 +51,10 @@ __utimensat64_helper (int fd, const char *file,
>        tsp32[1] = valid_timespec64_to_timespec (tsp64[1]);
>      }
>  
> -  return INLINE_SYSCALL (utimensat, 4, fd, file, tsp64 ? &tsp32[0] :
> NULL,
> -                         flags);
> +  ret = INLINE_SYSCALL_CALL (utimensat, fd, file, tsp64 ? &tsp32[0]
> : NULL,
> +     flags);
>  #endif
> -
> +  return ret;
>  }
>  libc_hidden_def (__utimensat64_helper)
>  
Reviewed-by: Lukasz Majewski <[hidden email]>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 12/23] linux: Add helper function to optimize 64-bit time_t fallback support

Lukasz Majewski
In reply to this post by Sourceware - libc-alpha mailing list
Hi Adhemerval,

> These helper functions are used to optimize the 64-bit time_t support
> on configurations that requires support for 32-bit time_t fallback
> (!__ASSUME_TIME64_SYSCALLS).  The idea is once the kernel advertises
> that it does not have 64-bit time_t support, glibc will stop to try
> issue the 64-bit time_t syscall altogether.
>
> For instance:
>
>   #ifndef __NR_symbol_time64
>   # define __NR_symbol_time64 __NR_symbol
>   #endif
>   int r;
>   if (supports_time64 ())
>     {
>       r = INLINE_SYSCALL_CALL (symbol, ...);
>       if (r == 0 || errno != ENOSYS)
>         return r;
>
>       mark_time64_unsupported ();
>     }
>   #ifndef __ASSUME_TIME64_SYSCALLS
>   <32-bit fallback syscall>
>   #endif
>   return r;
>
> On configuration with default 64-bit time_t these optimization should
> be optimized away by the compiler resulting in no overhead.
I think such approach was proposed in the very first Y2038 conversion
patch done by Albert [1].

(By using __y2038_linux_support variable).



I think that it is an overkill (or maybe I'm not aware of some
important use cases) as new ports with __WORDSIZE==32 have already
__TIMESIZE == 64, so they use 64 bit syscalls out of the box (RISC-V,
ARC).

Moreover, systems with __WORDSIZE==32 && __TIMESIZE !=64 (like ARM)
will benefit from it only when they use:

Old Linux headers (probably with oldest kernel supported - version
3.2) and Linux version < 5.1).

All new BSPs for them will probably use kernel > 5.1 (5.4 is the newest
LTS), which will support 64 bit calls.


Link:
[1] -
https://patchwork.ozlabs.org/project/glibc/patch/20180919073553.28153-1-albert.aribaud@.../


> ---
>  sysdeps/unix/sysv/linux/Makefile         |  3 +-
>  sysdeps/unix/sysv/linux/time64-support.c | 23 ++++++++
>  sysdeps/unix/sysv/linux/time64-support.h | 70
> ++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1
> deletion(-) create mode 100644
> sysdeps/unix/sysv/linux/time64-support.c create mode 100644
> sysdeps/unix/sysv/linux/time64-support.h
>
> diff --git a/sysdeps/unix/sysv/linux/Makefile
> b/sysdeps/unix/sysv/linux/Makefile index 1932ccf7df..75c60a58f3 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -60,7 +60,8 @@ sysdep_routines += adjtimex clone umount umount2
> readahead sysctl \ personality epoll_wait tee vmsplice splice \
>     open_by_handle_at mlock2 pkey_mprotect pkey_set
> pkey_get \ timerfd_gettime timerfd_settime prctl \
> -   process_vm_readv process_vm_writev clock_adjtime
> +   process_vm_readv process_vm_writev clock_adjtime \
> +   time64-support
>  
>  CFLAGS-gethostid.c = -fexceptions
>  CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
> diff --git a/sysdeps/unix/sysv/linux/time64-support.c
> b/sysdeps/unix/sysv/linux/time64-support.c new file mode 100644
> index 0000000000..9f03c9adda
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/time64-support.c
> @@ -0,0 +1,23 @@
> +/* Auxiliary definitions for 64-bit time_t support.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be
> useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <time64-support.h>
> +
> +#ifndef __ASSUME_TIME64_SYSCALLS
> +int __time64_support = 1;
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/time64-support.h
> b/sysdeps/unix/sysv/linux/time64-support.h new file mode 100644
> index 0000000000..a997042fea
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/time64-support.h
> @@ -0,0 +1,70 @@
> +/* Auxiliary definitions for 64-bit time_t support.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be
> useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <stdbool.h>
> +#include <atomic.h>
> +
> +/* These helper functions are used to optimize the 64-bit time_t
> support on
> +   configurations that requires support for 32-bit time_t fallback
> +   (!__ASSUME_TIME64_SYSCALLS).  The idea is once the kernel
> advertises that
> +   it does not have 64-bit time_t support, glibc will stop to try
> issue the
> +   64-bit time_t syscall altogether.
> +
> +   For instance:
> +
> +     #ifndef __NR_symbol_time64
> +     # define __NR_symbol_time64 __NR_symbol
> +     #endif
> +     int r;
> +     if (supports_time64 ())
> +       {
> +         r = INLINE_SYSCALL_CALL (symbol, ...);
> +         if (r == 0 || errno != ENOSYS)
> +   return r;
> +
> +         mark_time64_unsupported ();
> +       }
> +     #ifndef __ASSUME_TIME64_SYSCALLS
> +       <32-bit fallback syscall>
> +     #endif
> +     return r;
> +
> +   On configuration with default 64-bit time_t these optimization
> should be
> +   optimized away by the compiler resulting in no overhead.  */
> +
> +#ifndef __ASSUME_TIME64_SYSCALLS
> +extern int __time64_support attribute_hidden;
> +#endif
> +
> +static inline bool
> +supports_time64 (void)
> +{
> +#ifdef __ASSUME_TIME64_SYSCALLS
> +  return true;
> +#else
> +  return atomic_load_relaxed (&__time64_support) != 0;
> +#endif
> +}
> +
> +static inline void
> +mark_time64_unsupported (void)
> +{
> +#ifndef __ASSUME_TIME64_SYSCALLS
> +  atomic_store_relaxed (&__time64_support, 0);
> +#endif
> +}



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 07/23] linux: Simplify ppoll

Sourceware - libc-alpha mailing list
In reply to this post by Joseph Myers


On 13/07/2020 18:21, Joseph Myers wrote:

> On Mon, 13 Jul 2020, Adhemerval Zanella via Libc-alpha wrote:
>
>> With arch-syscall.h it can now assumes the existance of either
>> __NR_ppoll or __NR_ppoll_time64.  The 32-bit time_t support is now
>> only build for !__ASSUME_TIME64_SYSCALLS.
>
>> +#ifdef __ASSUME_TIME64_SYSCALLS
>>    if (ret >= 0 || errno != ENOSYS)
>>      return ret;
>
> Should this be #ifndef?  It looks like it's building the fallback code in
> exactly the case where it's not needed.
>

It should, I have change it on a subsequent patch in the same set I didn't
catch in in the end.  I changed it locally.
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 05/23] linux: Simplify mq_timedreceive

Sourceware - libc-alpha mailing list
In reply to this post by Lukasz Majewski


On 14/07/2020 05:06, Lukasz Majewski wrote:

> On Mon, 13 Jul 2020 14:10:07 -0300
> Adhemerval Zanella via Libc-alpha <[hidden email]> wrote:
>
>> With arch-syscall.h it can now assumes the existance of either
>> __NR_mq_timedreceive or __NR_mq_timedreceive_time64.  The 32-bit
>> time_t support is now only build for !__ASSUME_TIME64_SYSCALLS.
>>
>> The internal 64-bit time_t names is also adjusted to use the
>> other y2038 symbol names.
>>
>> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
>> kernel).
>> ---
>>  include/mqueue.h                          | 16 ++++++------
>>  sysdeps/unix/sysv/linux/mq_timedreceive.c | 32
>> +++++++++++------------ 2 files changed, 24 insertions(+), 24
>> deletions(-)
>>
>> diff --git a/include/mqueue.h b/include/mqueue.h
>> index 98e4596c22..b3ee8b7462 100644
>> --- a/include/mqueue.h
>> +++ b/include/mqueue.h
>> @@ -13,18 +13,18 @@ hidden_proto (mq_setattr)
>>  #include <struct___timespec64.h>
>>  #if __TIMESIZE == 64
>>  # define __mq_timedsend_time64 __mq_timedsend
>> -# define __mq_timedreceive_time64 __mq_timedreceive
>> +# define __mq_timedreceive64 __mq_timedreceive
>>  #else
>>  extern int __mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr,
>>                                    size_t msg_len, unsigned int
>> msg_prio, const struct __timespec64 *abs_timeout);
>>  librt_hidden_proto (__mq_timedsend_time64)
>> -extern ssize_t __mq_timedreceive_time64 (mqd_t mqdes,
>> -                                         char *__restrict msg_ptr,
>> -                                         size_t msg_len,
>> -                                         unsigned int *__restrict
>> msg_prio,
>> -                                         const struct __timespec64
>> *__restrict
>> -                                         abs_timeout);
>> -librt_hidden_proto (__mq_timedreceive_time64)
>> +extern ssize_t __mq_timedreceive64 (mqd_t mqdes,
>
> Just informative - the Linux kernel has following naming convention:
>
> clock_gettime -> clock_gettime64 (the 64 is appended only for syscalls
> which ends with "time").
>
> but
>
> futex -> futex_time64 (the "time64" is appended when there is no "time"
> in the last part of the syscall name).
>
> We can have the simpler convention - by appending "64" to syscalls in
> glibc.
Yeah, I don't have a strong preference in fact I think it will drop this
name change.  It is a bit annoying we are using different names to
define the time64 interface, but since it would handled transparently in
the public interface it should not matter much (the only case would be
for dlopen cases, but LFS support is already hitting this).

At least for stat functions we would require to use time64 suffix since
the '64' already is used to express LFS support.


>
> For the rest of the patch:
> Reviewed-by: Lukasz Majewski <[hidden email]>
>
>> +                                    char *__restrict msg_ptr,
>> +                                    size_t msg_len,
>> +                                    unsigned int *__restrict
>> msg_prio,
>> +                                    const struct __timespec64
>> *__restrict
>> +                                    abs_timeout);
>> +librt_hidden_proto (__mq_timedreceive64)
>>  #endif
>>  #endif
>> diff --git a/sysdeps/unix/sysv/linux/mq_timedreceive.c
>> b/sysdeps/unix/sysv/linux/mq_timedreceive.c index
>> 728a63d1ec..61c27fd8f7 100644 ---
>> a/sysdeps/unix/sysv/linux/mq_timedreceive.c +++
>> b/sysdeps/unix/sysv/linux/mq_timedreceive.c @@ -22,19 +22,17 @@
>>  /* Receive the oldest from highest priority messages in message queue
>>     MQDES, stop waiting if ABS_TIMEOUT expires.  */
>>  ssize_t
>> -__mq_timedreceive_time64 (mqd_t mqdes, char *__restrict msg_ptr,
>> size_t msg_len,
>> -                          unsigned int *__restrict msg_prio,
>> -                          const struct __timespec64 *__restrict
>> abs_timeout) +__mq_timedreceive64 (mqd_t mqdes, char *__restrict
>> msg_ptr, size_t msg_len,
>> +                     unsigned int *__restrict msg_prio,
>> +                     const struct __timespec64 *__restrict
>> abs_timeout) {
>> -#ifdef __ASSUME_TIME64_SYSCALLS
>> -# ifndef __NR_mq_timedreceive_time64
>> -#  define __NR_mq_timedreceive_time64 __NR_mq_timedreceive
>> -# endif
>> -  return SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr,
>> msg_len,
>> -                         msg_prio, abs_timeout);
>> -#else
>> +#ifndef __NR_mq_timedreceive_time64
>> +# define __NR_mq_timedreceive_time64 __NR_mq_timedreceive
>> +#endif
>>    int ret = SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr,
>> msg_len,
>> -                            msg_prio, abs_timeout);
>> +    msg_prio, abs_timeout);
>> +
>> +#ifndef __ASSUME_TIME64_SYSCALLS
>>    if (ret == 0 || errno != ENOSYS)
>>      return ret;
>>  
>> @@ -50,13 +48,15 @@ __mq_timedreceive_time64 (mqd_t mqdes, char
>> *__restrict msg_ptr, size_t msg_len, ts32 =
>> valid_timespec64_to_timespec (*abs_timeout); }
>>  
>> -  return SYSCALL_CANCEL (mq_timedreceive, mqdes, msg_ptr, msg_len,
>> msg_prio,
>> -                         abs_timeout != NULL ? &ts32 : NULL);
>> +  ret = SYSCALL_CANCEL (mq_timedreceive, mqdes, msg_ptr, msg_len,
>> msg_prio,
>> + abs_timeout != NULL ? &ts32 : NULL);
>>  #endif
>> +
>> +  return ret;
>>  }
>>  
>>  #if __TIMESIZE != 64
>> -librt_hidden_def (__mq_timedreceive_time64)
>> +librt_hidden_def (__mq_timedreceive64)
>>  
>>  ssize_t
>>  __mq_timedreceive (mqd_t mqdes, char *__restrict msg_ptr, size_t
>> msg_len, @@ -67,8 +67,8 @@ __mq_timedreceive (mqd_t mqdes, char
>> *__restrict msg_ptr, size_t msg_len, if (abs_timeout != NULL)
>>      ts64 = valid_timespec_to_timespec64 (*abs_timeout);
>>  
>> -  return __mq_timedreceive_time64 (mqdes, msg_ptr, msg_len, msg_prio,
>> -                                   abs_timeout != NULL ? &ts64 :
>> NULL);
>> +  return __mq_timedreceive64 (mqdes, msg_ptr, msg_len, msg_prio,
>> +      abs_timeout != NULL ? &ts64 : NULL);
>>  }
>>  #endif
>>  
>
>
>
>
> Best regards,
>
> Lukasz Majewski
>
> --
>
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]
>


signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 12/23] linux: Add helper function to optimize 64-bit time_t fallback support

Sourceware - libc-alpha mailing list
In reply to this post by Lukasz Majewski


On 14/07/2020 05:20, Lukasz Majewski wrote:

> Hi Adhemerval,
>
>> These helper functions are used to optimize the 64-bit time_t support
>> on configurations that requires support for 32-bit time_t fallback
>> (!__ASSUME_TIME64_SYSCALLS).  The idea is once the kernel advertises
>> that it does not have 64-bit time_t support, glibc will stop to try
>> issue the 64-bit time_t syscall altogether.
>>
>> For instance:
>>
>>   #ifndef __NR_symbol_time64
>>   # define __NR_symbol_time64 __NR_symbol
>>   #endif
>>   int r;
>>   if (supports_time64 ())
>>     {
>>       r = INLINE_SYSCALL_CALL (symbol, ...);
>>       if (r == 0 || errno != ENOSYS)
>>         return r;
>>
>>       mark_time64_unsupported ();
>>     }
>>   #ifndef __ASSUME_TIME64_SYSCALLS
>>   <32-bit fallback syscall>
>>   #endif
>>   return r;
>>
>> On configuration with default 64-bit time_t these optimization should
>> be optimized away by the compiler resulting in no overhead.
>
> I think such approach was proposed in the very first Y2038 conversion
> patch done by Albert [1].
>
> (By using __y2038_linux_support variable).
Thanks I didn't see this in fact.

>
>
>
> I think that it is an overkill (or maybe I'm not aware of some
> important use cases) as new ports with __WORDSIZE==32 have already
> __TIMESIZE == 64, so they use 64 bit syscalls out of the box (RISC-V,
> ARC).

It should be a noop on newer 32-bit ports with 64-bit time_t, so no
overhead (as for any other 64-bit time_t  only ABI).

>
> Moreover, systems with __WORDSIZE==32 && __TIMESIZE !=64 (like ARM)
> will benefit from it only when they use:
>
> Old Linux headers (probably with oldest kernel supported - version
> 3.2) and Linux version < 5.1).
>
> All new BSPs for them will probably use kernel > 5.1 (5.4 is the newest
> LTS), which will support 64 bit calls.

That's why I using this optimization only on specific symbols, I don't
foresee that it would be common for time64 binaries on old 32-bit abi
with 32-bit time_t support would be deployed on pre v5.1 kernels.

In any case, I still think that this should be quite simple optimization
(the exempla above only adds about a couple of extra lines).


signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 12/23] linux: Add helper function to optimize 64-bit time_t fallback support

Lukasz Majewski
Hi Adhemerval,

> On 14/07/2020 05:20, Lukasz Majewski wrote:
> > Hi Adhemerval,
> >  
> >> These helper functions are used to optimize the 64-bit time_t
> >> support on configurations that requires support for 32-bit time_t
> >> fallback (!__ASSUME_TIME64_SYSCALLS).  The idea is once the kernel
> >> advertises that it does not have 64-bit time_t support, glibc will
> >> stop to try issue the 64-bit time_t syscall altogether.
> >>
> >> For instance:
> >>
> >>   #ifndef __NR_symbol_time64
> >>   # define __NR_symbol_time64 __NR_symbol
> >>   #endif
> >>   int r;
> >>   if (supports_time64 ())
> >>     {
> >>       r = INLINE_SYSCALL_CALL (symbol, ...);
> >>       if (r == 0 || errno != ENOSYS)
> >>         return r;
> >>
> >>       mark_time64_unsupported ();
> >>     }
> >>   #ifndef __ASSUME_TIME64_SYSCALLS
> >>   <32-bit fallback syscall>
> >>   #endif
> >>   return r;
> >>
> >> On configuration with default 64-bit time_t these optimization
> >> should be optimized away by the compiler resulting in no overhead.
> >>  
> >
> > I think such approach was proposed in the very first Y2038
> > conversion patch done by Albert [1].
> >
> > (By using __y2038_linux_support variable).  
>
> Thanks I didn't see this in fact.
>
> >
> >
> >
> > I think that it is an overkill (or maybe I'm not aware of some
> > important use cases) as new ports with __WORDSIZE==32 have already
> > __TIMESIZE == 64, so they use 64 bit syscalls out of the box
> > (RISC-V, ARC).  
>
> It should be a noop on newer 32-bit ports with 64-bit time_t, so no
> overhead (as for any other 64-bit time_t  only ABI).
Ok.

>
> >
> > Moreover, systems with __WORDSIZE==32 && __TIMESIZE !=64 (like ARM)
> > will benefit from it only when they use:
> >
> > Old Linux headers (probably with oldest kernel supported - version
> > 3.2) and Linux version < 5.1).
> >
> > All new BSPs for them will probably use kernel > 5.1 (5.4 is the
> > newest LTS), which will support 64 bit calls.  
>
> That's why I using this optimization only on specific symbols, I don't
> foresee that it would be common for time64 binaries on old 32-bit abi
> with 32-bit time_t support would be deployed on pre v5.1 kernels.
>
> In any case, I still think that this should be quite simple
> optimization (the exempla above only adds about a couple of extra
> lines).
>
My _only_ concern is if the work done on this optimization will have
enough relevant use cases to pay off.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [hidden email]

attachment0 (499 bytes) Download Attachment
123