diff mbox series

[11/23] linux: Simplify utimensat

Message ID 20200713171025.3661832-11-adhemerval.zanella@linaro.org
State New
Headers show
Series [01/23] linux: Simplify clock_adjtime | expand

Commit Message

Adhemerval Zanella July 13, 2020, 5:10 p.m. UTC
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(-)

Comments

Lukasz Majewski July 14, 2020, 8:09 a.m. UTC | #1
On Mon, 13 Jul 2020 14:10:13 -0300
Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> 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 <lukma@denx.de>


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: lukma@denx.de
diff mbox series

Patch

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)