diff mbox series

[v7,1/5] sysv: Define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64

Message ID 20200331154656.687841-2-alistair.francis@wdc.com
State New
Headers show
Series Always use 32-bit time_t for certain syscalls | expand

Commit Message

Alistair Francis March 31, 2020, 3:46 p.m. UTC
On y2038 safe 32-bit systems the Linux kernel expects itimerval
and rusage to use a 32-bit time_t, even though the other time_t's
are 64-bit. There are currently no plans to make 64-bit time_t versions
of these structs.

There are also other occurrences where the time passed to the kernel via
timeval doesn't match the wordsize.

To handle these cases let's define a new macro
__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64. This macro specifies if the
kernel's old_timeval matches the new timeval64. This should be true for
64-bit architectures except for Alpha's old osf syscalls and x32.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
---
 bits/typesizes.h                                 | 6 ++++++
 sysdeps/unix/sysv/linux/alpha/bits/typesizes.h   | 3 +++
 sysdeps/unix/sysv/linux/generic/bits/typesizes.h | 6 ++++++
 sysdeps/unix/sysv/linux/s390/bits/typesizes.h    | 6 ++++++
 sysdeps/unix/sysv/linux/sparc/bits/typesizes.h   | 6 ++++++
 sysdeps/unix/sysv/linux/x86/bits/typesizes.h     | 5 +++++
 6 files changed, 32 insertions(+)

Comments

Adhemerval Zanella April 1, 2020, 4:38 p.m. UTC | #1
On 31/03/2020 12:46, Alistair Francis via Libc-alpha wrote:
> On y2038 safe 32-bit systems the Linux kernel expects itimerval
> and rusage to use a 32-bit time_t, even though the other time_t's
> are 64-bit. There are currently no plans to make 64-bit time_t versions
> of these structs.
> 
> There are also other occurrences where the time passed to the kernel via
> timeval doesn't match the wordsize.
> 
> To handle these cases let's define a new macro
> __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64. This macro specifies if the
> kernel's old_timeval matches the new timeval64. This should be true for
> 64-bit architectures except for Alpha's old osf syscalls and x32.

On x32 time_t is 64-bit, so the define is 0 for 32 bits architectures
and alpha osf syscalls.

> 
> Reviewed-by: Lukasz Majewski <lukma@denx.de>

LGTM, thanks.

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

> ---
>  bits/typesizes.h                                 | 6 ++++++
>  sysdeps/unix/sysv/linux/alpha/bits/typesizes.h   | 3 +++
>  sysdeps/unix/sysv/linux/generic/bits/typesizes.h | 6 ++++++
>  sysdeps/unix/sysv/linux/s390/bits/typesizes.h    | 6 ++++++
>  sysdeps/unix/sysv/linux/sparc/bits/typesizes.h   | 6 ++++++
>  sysdeps/unix/sysv/linux/x86/bits/typesizes.h     | 5 +++++
>  6 files changed, 32 insertions(+)
> 
> diff --git a/bits/typesizes.h b/bits/typesizes.h
> index 599408973e..8f16903a21 100644
> --- a/bits/typesizes.h
> +++ b/bits/typesizes.h
> @@ -76,10 +76,16 @@
>  
>  /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
>  # define __STATFS_MATCHES_STATFS64  1
> +
> +/* And for getitimer, setitimer and rusage  */
> +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
>  #else
>  # define __RLIM_T_MATCHES_RLIM64_T	0
>  
>  # define __STATFS_MATCHES_STATFS64  0
> +
> +/* And for getitimer, setitimer and rusage  */
> +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
>  #endif
>  

Ok.

>  /* Number of descriptors that can fit in an `fd_set'.  */
> diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
> index 28ee3e5920..1d1fd242dc 100644
> --- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
> +++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
> @@ -73,6 +73,9 @@
>  /* Not for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
>  # define __STATFS_MATCHES_STATFS64  0
>  
> +/* And for getitimer, setitimer and rusage  */
> +#define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
> +
>  /* Number of descriptors that can fit in an `fd_set'.  */
>  #define	__FD_SETSIZE		1024
>  

Ok.

> diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
> index 7c963e523e..4fb246ac74 100644
> --- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
> +++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
> @@ -77,11 +77,17 @@
>  
>  /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
>  # define __STATFS_MATCHES_STATFS64  1
> +
> +/* And for getitimer, setitimer and rusage  */
> +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
>  #else
>  # define __RLIM_T_MATCHES_RLIM64_T	0
>  
>  # define __STATFS_MATCHES_STATFS64  0
> +
> +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
>  #endif
> +
>  /* Number of descriptors that can fit in an `fd_set'.  */
>  #define	__FD_SETSIZE		1024
>  

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
> index e775e460bb..2bc87c1079 100644
> --- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
> +++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
> @@ -82,10 +82,16 @@
>  
>  /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
>  # define __STATFS_MATCHES_STATFS64  1
> +
> +/* And for getitimer, setitimer and rusage  */
> +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
>  #else
>  # define __RLIM_T_MATCHES_RLIM64_T	0
>  
>  # define __STATFS_MATCHES_STATFS64  0
> +
> +/* And for getitimer, setitimer and rusage  */
> +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
>  #endif
>  
>  /* Number of descriptors that can fit in an `fd_set'.  */

Ok.

> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
> index ac48c23e37..288a902b5f 100644
> --- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
> +++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
> @@ -76,10 +76,16 @@
>  
>  /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
>  # define __STATFS_MATCHES_STATFS64  1
> +
> +/* And for getitimer, setitimer and rusage  */
> +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
>  #else
>  # define __RLIM_T_MATCHES_RLIM64_T	0
>  
>  # define __STATFS_MATCHES_STATFS64  0
> +
> +/* And for getitimer, setitimer and rusage  */
> +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
>  #endif
>  
>  /* Number of descriptors that can fit in an `fd_set'.  */

Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
> index 87c50a4f32..1bb4a1620c 100644
> --- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
> +++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
> @@ -88,10 +88,15 @@
>  
>  /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
>  # define __STATFS_MATCHES_STATFS64  1
> +
> +/* And for getitimer, setitimer and rusage  */
> +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
>  #else
>  # define __RLIM_T_MATCHES_RLIM64_T	0
>  
>  # define __STATFS_MATCHES_STATFS64  0
> +
> +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
>  #endif
>  
>  /* Number of descriptors that can fit in an `fd_set'.  */
> 

Ok.
diff mbox series

Patch

diff --git a/bits/typesizes.h b/bits/typesizes.h
index 599408973e..8f16903a21 100644
--- a/bits/typesizes.h
+++ b/bits/typesizes.h
@@ -76,10 +76,16 @@ 
 
 /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
 # define __STATFS_MATCHES_STATFS64  1
+
+/* And for getitimer, setitimer and rusage  */
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
 #else
 # define __RLIM_T_MATCHES_RLIM64_T	0
 
 # define __STATFS_MATCHES_STATFS64  0
+
+/* And for getitimer, setitimer and rusage  */
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
 #endif
 
 /* Number of descriptors that can fit in an `fd_set'.  */
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
index 28ee3e5920..1d1fd242dc 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
@@ -73,6 +73,9 @@ 
 /* Not for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
 # define __STATFS_MATCHES_STATFS64  0
 
+/* And for getitimer, setitimer and rusage  */
+#define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
+
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
 
diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
index 7c963e523e..4fb246ac74 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
@@ -77,11 +77,17 @@ 
 
 /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
 # define __STATFS_MATCHES_STATFS64  1
+
+/* And for getitimer, setitimer and rusage  */
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
 #else
 # define __RLIM_T_MATCHES_RLIM64_T	0
 
 # define __STATFS_MATCHES_STATFS64  0
+
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
 #endif
+
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
 
diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
index e775e460bb..2bc87c1079 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
@@ -82,10 +82,16 @@ 
 
 /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
 # define __STATFS_MATCHES_STATFS64  1
+
+/* And for getitimer, setitimer and rusage  */
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
 #else
 # define __RLIM_T_MATCHES_RLIM64_T	0
 
 # define __STATFS_MATCHES_STATFS64  0
+
+/* And for getitimer, setitimer and rusage  */
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
 #endif
 
 /* Number of descriptors that can fit in an `fd_set'.  */
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
index ac48c23e37..288a902b5f 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
@@ -76,10 +76,16 @@ 
 
 /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
 # define __STATFS_MATCHES_STATFS64  1
+
+/* And for getitimer, setitimer and rusage  */
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
 #else
 # define __RLIM_T_MATCHES_RLIM64_T	0
 
 # define __STATFS_MATCHES_STATFS64  0
+
+/* And for getitimer, setitimer and rusage  */
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
 #endif
 
 /* Number of descriptors that can fit in an `fd_set'.  */
diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
index 87c50a4f32..1bb4a1620c 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
@@ -88,10 +88,15 @@ 
 
 /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
 # define __STATFS_MATCHES_STATFS64  1
+
+/* And for getitimer, setitimer and rusage  */
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
 #else
 # define __RLIM_T_MATCHES_RLIM64_T	0
 
 # define __STATFS_MATCHES_STATFS64  0
+
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
 #endif
 
 /* Number of descriptors that can fit in an `fd_set'.  */