diff mbox series

[01/10] y2038: include: Move struct __timeval64 definition to a separate file

Message ID 20200426133110.5312-2-lukma@denx.de
State New
Headers show
Series y2038: Convert clock_adjtime related syscalls to support 64 bit time | expand

Commit Message

Lukasz Majewski April 26, 2020, 1:31 p.m. UTC
The struct __timeval64's definition has been moved from ./include/time.h to
./include/struct___timeval64.h.

This change would prevent from polluting other glibc namespaces (when
headers are modified to support 64 bit time on architectures with
__WORDSIZE==32).

Now it is possible to just include definition of this particular structure
when needed.
---
 include/struct___timeval64.h | 17 +++++++++++++++++
 include/time.h               | 15 +--------------
 2 files changed, 18 insertions(+), 14 deletions(-)
 create mode 100644 include/struct___timeval64.h

Comments

Alistair Francis April 27, 2020, 3:18 p.m. UTC | #1
On Sun, Apr 26, 2020 at 6:31 AM Lukasz Majewski <lukma@denx.de> wrote:
>
> The struct __timeval64's definition has been moved from ./include/time.h to
> ./include/struct___timeval64.h.
>
> This change would prevent from polluting other glibc namespaces (when
> headers are modified to support 64 bit time on architectures with
> __WORDSIZE==32).
>
> Now it is possible to just include definition of this particular structure
> when needed.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  include/struct___timeval64.h | 17 +++++++++++++++++
>  include/time.h               | 15 +--------------
>  2 files changed, 18 insertions(+), 14 deletions(-)
>  create mode 100644 include/struct___timeval64.h
>
> diff --git a/include/struct___timeval64.h b/include/struct___timeval64.h
> new file mode 100644
> index 0000000000..05cf2f26fc
> --- /dev/null
> +++ b/include/struct___timeval64.h
> @@ -0,0 +1,17 @@
> +#ifndef _STRUCT_TIMEVAL64_H
> +#define _STRUCT_TIMEVAL64_H
> +
> +#if __TIMESIZE == 64
> +# define __timeval64 timeval
> +#else
> +/* The glibc Y2038-proof struct __timeval64 structure for a time value.
> +   This structure is NOT supposed to be passed to the Linux kernel.
> +   Instead, it shall be converted to struct __timespec64 and time shall
> +   be [sg]et via clock_[sg]ettime (which are now Y2038 safe).  */
> +struct __timeval64
> +{
> +  __time64_t tv_sec;         /* Seconds */
> +  __suseconds64_t tv_usec;       /* Microseconds */
> +};
> +#endif
> +#endif /* _STRUCT_TIMEVAL64_H  */
> diff --git a/include/time.h b/include/time.h
> index 1c103a4cb2..fe4da9ca10 100644
> --- a/include/time.h
> +++ b/include/time.h
> @@ -4,6 +4,7 @@
>  #ifndef _ISOMAC
>  # include <bits/types/struct_timeval.h>
>  # include <struct___timespec64.h>
> +# include <struct___timeval64.h>
>  # include <bits/types/locale_t.h>
>  # include <stdbool.h>
>  # include <time/mktime-internal.h>
> @@ -73,20 +74,6 @@ struct __itimerspec64
>  };
>  #endif
>
> -#if __TIMESIZE == 64
> -# define __timeval64 timeval
> -#else
> -/* The glibc Y2038-proof struct __timeval64 structure for a time value.
> -   This structure is NOT supposed to be passed to the Linux kernel.
> -   Instead, it shall be converted to struct __timespec64 and time shall
> -   be [sg]et via clock_[sg]ettime (which are now Y2038 safe).  */
> -struct __timeval64
> -{
> -  __time64_t tv_sec;         /* Seconds */
> -  __suseconds64_t tv_usec;       /* Microseconds */
> -};
> -#endif
> -
>  #if __TIMESIZE == 64
>  # define __utimbuf64 utimbuf
>  # define __itimerval64 itimerval
> --
> 2.20.1
>
Adhemerval Zanella Netto April 28, 2020, 2:24 p.m. UTC | #2
On 26/04/2020 10:31, Lukasz Majewski wrote:
> The struct __timeval64's definition has been moved from ./include/time.h to
> ./include/struct___timeval64.h.
> 
> This change would prevent from polluting other glibc namespaces (when
> headers are modified to support 64 bit time on architectures with
> __WORDSIZE==32).
> 
> Now it is possible to just include definition of this particular structure
> when needed.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  include/struct___timeval64.h | 17 +++++++++++++++++
>  include/time.h               | 15 +--------------
>  2 files changed, 18 insertions(+), 14 deletions(-)
>  create mode 100644 include/struct___timeval64.h
> 
> diff --git a/include/struct___timeval64.h b/include/struct___timeval64.h
> new file mode 100644
> index 0000000000..05cf2f26fc
> --- /dev/null
> +++ b/include/struct___timeval64.h
> @@ -0,0 +1,17 @@
> +#ifndef _STRUCT_TIMEVAL64_H
> +#define _STRUCT_TIMEVAL64_H
> +
> +#if __TIMESIZE == 64
> +# define __timeval64 timeval
> +#else
> +/* The glibc Y2038-proof struct __timeval64 structure for a time value.
> +   This structure is NOT supposed to be passed to the Linux kernel.
> +   Instead, it shall be converted to struct __timespec64 and time shall
> +   be [sg]et via clock_[sg]ettime (which are now Y2038 safe).  */
> +struct __timeval64
> +{
> +  __time64_t tv_sec;         /* Seconds */
> +  __suseconds64_t tv_usec;       /* Microseconds */
> +};
> +#endif
> +#endif /* _STRUCT_TIMEVAL64_H  */

Ok.

> diff --git a/include/time.h b/include/time.h
> index 1c103a4cb2..fe4da9ca10 100644
> --- a/include/time.h
> +++ b/include/time.h
> @@ -4,6 +4,7 @@
>  #ifndef _ISOMAC
>  # include <bits/types/struct_timeval.h>
>  # include <struct___timespec64.h>
> +# include <struct___timeval64.h>
>  # include <bits/types/locale_t.h>
>  # include <stdbool.h>
>  # include <time/mktime-internal.h>
> @@ -73,20 +74,6 @@ struct __itimerspec64
>  };
>  #endif
>  
> -#if __TIMESIZE == 64
> -# define __timeval64 timeval
> -#else
> -/* The glibc Y2038-proof struct __timeval64 structure for a time value.
> -   This structure is NOT supposed to be passed to the Linux kernel.
> -   Instead, it shall be converted to struct __timespec64 and time shall
> -   be [sg]et via clock_[sg]ettime (which are now Y2038 safe).  */
> -struct __timeval64
> -{
> -  __time64_t tv_sec;         /* Seconds */
> -  __suseconds64_t tv_usec;       /* Microseconds */
> -};
> -#endif
> -
>  #if __TIMESIZE == 64
>  # define __utimbuf64 utimbuf
>  # define __itimerval64 itimerval
> 

Ok.
diff mbox series

Patch

diff --git a/include/struct___timeval64.h b/include/struct___timeval64.h
new file mode 100644
index 0000000000..05cf2f26fc
--- /dev/null
+++ b/include/struct___timeval64.h
@@ -0,0 +1,17 @@ 
+#ifndef _STRUCT_TIMEVAL64_H
+#define _STRUCT_TIMEVAL64_H
+
+#if __TIMESIZE == 64
+# define __timeval64 timeval
+#else
+/* The glibc Y2038-proof struct __timeval64 structure for a time value.
+   This structure is NOT supposed to be passed to the Linux kernel.
+   Instead, it shall be converted to struct __timespec64 and time shall
+   be [sg]et via clock_[sg]ettime (which are now Y2038 safe).  */
+struct __timeval64
+{
+  __time64_t tv_sec;         /* Seconds */
+  __suseconds64_t tv_usec;       /* Microseconds */
+};
+#endif
+#endif /* _STRUCT_TIMEVAL64_H  */
diff --git a/include/time.h b/include/time.h
index 1c103a4cb2..fe4da9ca10 100644
--- a/include/time.h
+++ b/include/time.h
@@ -4,6 +4,7 @@ 
 #ifndef _ISOMAC
 # include <bits/types/struct_timeval.h>
 # include <struct___timespec64.h>
+# include <struct___timeval64.h>
 # include <bits/types/locale_t.h>
 # include <stdbool.h>
 # include <time/mktime-internal.h>
@@ -73,20 +74,6 @@  struct __itimerspec64
 };
 #endif
 
-#if __TIMESIZE == 64
-# define __timeval64 timeval
-#else
-/* The glibc Y2038-proof struct __timeval64 structure for a time value.
-   This structure is NOT supposed to be passed to the Linux kernel.
-   Instead, it shall be converted to struct __timespec64 and time shall
-   be [sg]et via clock_[sg]ettime (which are now Y2038 safe).  */
-struct __timeval64
-{
-  __time64_t tv_sec;         /* Seconds */
-  __suseconds64_t tv_usec;       /* Microseconds */
-};
-#endif
-
 #if __TIMESIZE == 64
 # define __utimbuf64 utimbuf
 # define __itimerval64 itimerval