diff mbox

[RFC] AARCH64/ILP32: introduce kernel time types

Message ID 1467103498-24243-1-git-send-email-ynorov@caviumnetworks.com
State New
Headers show

Commit Message

Yury Norov June 28, 2016, 8:44 a.m. UTC
Structures utmp and utmpx are shared between ilp32 and native ABIs,
and so should have same layout. As now, architectures where this
compatibility is required enable __WORDSIZE_TIME64_COMPAT32 option,
and so make lp64 utmp{x} backward-compatible to ilp32 ones.

AARCH64 doesn't require such compatibility, and so we can do opposite
conversion.

This patch introduces new option  __KERNEL_TIME_T_MATCHES_TIME64_T,
and adds internal __ktime_t, __kusecond_t, __ksusecond_t types,
that are native-sized for normal case, and forced to 64-bit size if
__KERNEL_TIME_T_MATCHES_TIME64_T is enabled.

This is generic solution because we are facing y2038 problem, and
all new ABIs should follow this convention. This approach might also
be used for RISC-V as default.

If no objections, I'll incorporate it to v2 of AARCH64/ILP32 patchset.

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

---
 bits/types.h                                     | 17 +++++++++++++++--
 sysdeps/gnu/bits/utmp.h                          |  6 +++---
 sysdeps/gnu/bits/utmpx.h                         |  4 ++--
 sysdeps/unix/sysv/linux/aarch64/bits/typesizes.h |  7 ++++++-
 sysdeps/unix/sysv/linux/bits/time.h              |  6 ++++++
 5 files changed, 32 insertions(+), 8 deletions(-)

-- 
2.7.4
diff mbox

Patch

diff --git a/bits/types.h b/bits/types.h
index 01753bd..47535eb 100644
--- a/bits/types.h
+++ b/bits/types.h
@@ -137,8 +137,11 @@  __STD_TYPE __RLIM_T_TYPE __rlim_t;	/* Type for resource measurement.  */
 __STD_TYPE __RLIM64_T_TYPE __rlim64_t;	/* Type for resource measurement (LFS).  */
 __STD_TYPE __ID_T_TYPE __id_t;		/* General type for IDs.  */
 __STD_TYPE __TIME_T_TYPE __time_t;	/* Seconds since the Epoch.  */
-__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds.  */
-__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds.  */
+__STD_TYPE __TIME64_T_TYPE __time64_t;	/* Seconds since the Epoch.  */
+__STD_TYPE __USECONDS_T_TYPE __useconds_t;	/* Count of microseconds.  */
+__STD_TYPE __USECONDS64_T_TYPE __useconds64_t;	/* Count of microseconds.  */
+__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t;	/* Signed count of microseconds.  */
+__STD_TYPE __SUSECONDS64_T_TYPE __suseconds64_t;/* Signed count of microseconds.  */
 
 __STD_TYPE __DADDR_T_TYPE __daddr_t;	/* The type of a disk address.  */
 __STD_TYPE __KEY_T_TYPE __key_t;	/* Type of an IPC key.  */
@@ -188,6 +191,16 @@  __STD_TYPE __SWORD_TYPE __intptr_t;
 /* Duplicate info from sys/socket.h.  */
 __STD_TYPE __U32_TYPE __socklen_t;
 
+/* Kernel time types.  */
+#ifdef __KERNEL_TIME_T_MATCHES_TIME64_T
+typedef __time64_t	__ktime_t;
+typedef __suseconds64_t	__ksuseconds_t;
+typedef __useconds64_t	__kuseconds_t;
+#else
+typedef __time_t	__ktime_t;
+typedef __suseconds_t	__ksuseconds_t;
+typedef __useconds_t	__kuseconds_t;
+#endif
 
 #undef __STD_TYPE
 
diff --git a/sysdeps/gnu/bits/utmp.h b/sysdeps/gnu/bits/utmp.h
index 2a1ffcb..fae9126 100644
--- a/sysdeps/gnu/bits/utmp.h
+++ b/sysdeps/gnu/bits/utmp.h
@@ -38,7 +38,7 @@  struct lastlog
 #ifdef __WORDSIZE_TIME64_COMPAT32
     int32_t ll_time;
 #else
-    __time_t ll_time;
+    __ktime_t ll_time;
 #endif
     char ll_line[UT_LINESIZE];
     char ll_host[UT_HOSTSIZE];
@@ -76,8 +76,8 @@  struct utmp
     int32_t tv_usec;		/* Microseconds.  */
   } ut_tv;			/* Time entry was made.  */
 #else
-  long int ut_session;		/* Session ID, used for windowing.  */
-  struct timeval ut_tv;		/* Time entry was made.  */
+  __ktime_t ut_session;		/* Session ID, used for windowing.  */
+  struct __kernel_timeval ut_tv;/* Time entry was made.  */
 #endif
 
   int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
diff --git a/sysdeps/gnu/bits/utmpx.h b/sysdeps/gnu/bits/utmpx.h
index b41548b..58eeef4 100644
--- a/sysdeps/gnu/bits/utmpx.h
+++ b/sysdeps/gnu/bits/utmpx.h
@@ -74,8 +74,8 @@  struct utmpx
     __int32_t tv_usec;		/* Microseconds.  */
   } ut_tv;			/* Time entry was made.  */
 #else
-  long int ut_session;		/* Session ID, used for windowing.  */
-  struct timeval ut_tv;		/* Time entry was made.  */
+  __ktime_t ut_session;		/* Session ID, used for windowing.  */
+  struct __kernel_timeval ut_tv;/* Time entry was made.  */
 #endif
   __int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
   char __glibc_reserved[20];		/* Reserved for future use.  */
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/typesizes.h b/sysdeps/unix/sysv/linux/aarch64/bits/typesizes.h
index 39c0c81..97ca37c 100644
--- a/sysdeps/unix/sysv/linux/aarch64/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/aarch64/bits/typesizes.h
@@ -48,8 +48,11 @@ 
 #define	__ID_T_TYPE		__U32_TYPE
 #define __CLOCK_T_TYPE		__SLONGWORD_TYPE
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
+#define __TIME64_T_TYPE		__SQUAD_TYPE
 #define __USECONDS_T_TYPE	__U32_TYPE
+#define __USECONDS64_T_TYPE	__UQUAD_TYPE
 #define __SUSECONDS_T_TYPE	__SLONGWORD_TYPE
+#define __SUSECONDS64_T_TYPE	__SQUAD_TYPE
 #define __DADDR_T_TYPE		__S32_TYPE
 #define __KEY_T_TYPE		__S32_TYPE
 #define __CLOCKID_T_TYPE	__S32_TYPE
@@ -79,8 +82,10 @@ 
 /* And for __fsbilcnt_t and __fsbilcnt64_t.  */
 # define __FSFILCNT_T_TYPE_MATCHES_FSFILCNT64_T_TYPE	1
 
+/* And for kernel time types.  */
+#define	__KERNEL_TIME_T_MATCHES_TIME64_T		1
+
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
 
-
 #endif /* bits/typesizes.h */
diff --git a/sysdeps/unix/sysv/linux/bits/time.h b/sysdeps/unix/sysv/linux/bits/time.h
index 87eb51f..d329ff4 100644
--- a/sysdeps/unix/sysv/linux/bits/time.h
+++ b/sysdeps/unix/sysv/linux/bits/time.h
@@ -32,6 +32,12 @@  struct timeval
     __time_t tv_sec;		/* Seconds.  */
     __suseconds_t tv_usec;	/* Microseconds.  */
   };
+
+struct __kernel_timeval
+  {
+    __ktime_t tv_sec;		/* Seconds.  */
+    __ksuseconds_t tv_usec;	/* Microseconds.  */
+  };
 # endif	/* struct timeval */
 #endif