[v2,10/25] y2038: Add __USE_TIME_BITS64 support for struct timespec

Message ID 20210518205613.1487824-11-adhemerval.zanella@linaro.org
State Superseded
Headers
Series Add 64 bit time support on legacy ABIs |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Adhemerval Zanella May 18, 2021, 8:55 p.m. UTC
  The __USE_TIME_BITS64 is not defined internally yet.
---
 time/bits/types/struct_timespec.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
  

Comments

Lukasz Majewski May 19, 2021, 9:03 a.m. UTC | #1
On Tue, 18 May 2021 17:55:58 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> The __USE_TIME_BITS64 is not defined internally yet.
> ---
>  time/bits/types/struct_timespec.h | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/time/bits/types/struct_timespec.h
> b/time/bits/types/struct_timespec.h index d11c69cfd3..4fe47a0d25
> 100644 --- a/time/bits/types/struct_timespec.h
> +++ b/time/bits/types/struct_timespec.h
> @@ -1,18 +1,22 @@
> -/* NB: Include guard matches what <linux/time.h> uses.  */
> -#ifndef _STRUCT_TIMESPEC
> -#define _STRUCT_TIMESPEC 1
> +#ifndef __struct_timespec_defined
> +#define __struct_timespec_defined 1
>  
>  #include <bits/types.h>
>  #include <bits/endian.h>
> +#include <bits/types/time_t.h>
>  
>  /* POSIX.1b structure for a time value.  This is like a `struct
> timeval' but has nanoseconds instead of microseconds.  */
>  struct timespec
>  {
> +#ifdef __USE_TIME_BITS64
> +  __time64_t tv_sec;		/* Seconds.  */
> +#else
>    __time_t tv_sec;		/* Seconds.  */
> +#endif
>  #if __WORDSIZE == 64 \
>    || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
> -  || __TIMESIZE == 32
> +  || (__TIMESIZE == 32 && !defined __USE_TIME_BITS64)
>    __syscall_slong_t tv_nsec;	/* Nanoseconds.  */
>  #else
>  # if __BYTE_ORDER == __BIG_ENDIAN

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
  
Carlos O'Donell June 4, 2021, 7:31 p.m. UTC | #2
On 5/18/21 4:55 PM, Adhemerval Zanella wrote:
> The __USE_TIME_BITS64 is not defined internally yet.

LGTM.

No regressions on x86_64, i686, ppc64le, aarch64, s390x.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  time/bits/types/struct_timespec.h | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h
> index d11c69cfd3..4fe47a0d25 100644
> --- a/time/bits/types/struct_timespec.h
> +++ b/time/bits/types/struct_timespec.h
> @@ -1,18 +1,22 @@
> -/* NB: Include guard matches what <linux/time.h> uses.  */
> -#ifndef _STRUCT_TIMESPEC
> -#define _STRUCT_TIMESPEC 1
> +#ifndef __struct_timespec_defined
> +#define __struct_timespec_defined 1
>  
>  #include <bits/types.h>
>  #include <bits/endian.h>
> +#include <bits/types/time_t.h>
>  
>  /* POSIX.1b structure for a time value.  This is like a `struct timeval' but
>     has nanoseconds instead of microseconds.  */
>  struct timespec
>  {
> +#ifdef __USE_TIME_BITS64
> +  __time64_t tv_sec;		/* Seconds.  */

OK. Use 64-bit seconds.

> +#else
>    __time_t tv_sec;		/* Seconds.  */
> +#endif
>  #if __WORDSIZE == 64 \
>    || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
> -  || __TIMESIZE == 32
> +  || (__TIMESIZE == 32 && !defined __USE_TIME_BITS64)
>    __syscall_slong_t tv_nsec;	/* Nanoseconds.  */

OK.

>  #else
>  # if __BYTE_ORDER == __BIG_ENDIAN
>
  

Patch

diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h
index d11c69cfd3..4fe47a0d25 100644
--- a/time/bits/types/struct_timespec.h
+++ b/time/bits/types/struct_timespec.h
@@ -1,18 +1,22 @@ 
-/* NB: Include guard matches what <linux/time.h> uses.  */
-#ifndef _STRUCT_TIMESPEC
-#define _STRUCT_TIMESPEC 1
+#ifndef __struct_timespec_defined
+#define __struct_timespec_defined 1
 
 #include <bits/types.h>
 #include <bits/endian.h>
+#include <bits/types/time_t.h>
 
 /* POSIX.1b structure for a time value.  This is like a `struct timeval' but
    has nanoseconds instead of microseconds.  */
 struct timespec
 {
+#ifdef __USE_TIME_BITS64
+  __time64_t tv_sec;		/* Seconds.  */
+#else
   __time_t tv_sec;		/* Seconds.  */
+#endif
 #if __WORDSIZE == 64 \
   || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
-  || __TIMESIZE == 32
+  || (__TIMESIZE == 32 && !defined __USE_TIME_BITS64)
   __syscall_slong_t tv_nsec;	/* Nanoseconds.  */
 #else
 # if __BYTE_ORDER == __BIG_ENDIAN