diff mbox series

[v3,16/24] y2038: Add __USE_TIME_BITS64 support for socket-constants.h

Message ID 20210607203613.282543-17-adhemerval.zanella@linaro.org
State New
Headers show
Series Add 64 bit time support on legacy ABIs | expand

Commit Message

Adhemerval Zanella June 7, 2021, 8:36 p.m. UTC
It is only used for !__USE_MISC, the default way uses the kernel
headers.  The patch also adds the SO_TIMESTAMP, SO_TIMESTAMPNS, and
SO_TIMESTAMPING which uses new values for 64-bit time_t kernel
interfaces.

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit stat implementations.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 .../unix/sysv/linux/bits/socket-constants.h   | 47 +++++++++++++++----
 .../sysv/linux/hppa/bits/socket-constants.h   | 36 +++++++++++++-
 .../sysv/linux/mips/bits/socket-constants.h   | 36 +++++++++++++-
 .../linux/powerpc/bits/socket-constants.h     | 36 +++++++++++++-
 .../sysv/linux/sparc/bits/socket-constants.h  | 36 +++++++++++++-
 5 files changed, 175 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/bits/socket-constants.h b/sysdeps/unix/sysv/linux/bits/socket-constants.h
index 84f7a333a2..c52e72bb73 100644
--- a/sysdeps/unix/sysv/linux/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/bits/socket-constants.h
@@ -32,19 +32,50 @@ 
 #define SO_OOBINLINE 10
 #define SO_RCVBUF 8
 #define SO_RCVLOWAT 18
-#if (__TIMESIZE == 64 && __WORDSIZE == 32 \
-     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
-# define SO_RCVTIMEO 66
-#else
-# define SO_RCVTIMEO 20
-#endif
 #define SO_REUSEADDR 2
 #define SO_SNDBUF 7
 #define SO_SNDLOWAT 19
+#define SO_TYPE 3
+
 #if (__TIMESIZE == 64 && __WORDSIZE == 32 \
      && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
+# define SO_RCVTIMEO 66
 # define SO_SNDTIMEO 67
+# define SO_TIMESTAMP 63
+# define SO_TIMESTAMPNS 64
+# define SO_TIMESTAMPING 65
 #else
-# define SO_SNDTIMEO 21
+# if __TIMESIZE == 64
+#  define SO_RCVTIMEO 20
+#  define SO_SNDTIMEO 21
+#  define SO_TIMESTAMP 29
+#  define SO_TIMESTAMPNS 35
+#  define SO_TIMESTAMPING 37
+# else
+#  define SO_RCVTIMEO_OLD 20
+#  define SO_SNDTIMEO_OLD 21
+#  define SO_RCVTIMEO_NEW 66
+#  define SO_SNDTIMEO_NEW 67
+
+#  define SO_TIMESTAMP_OLD 29
+#  define SO_TIMESTAMPNS_OLD 35
+#  define SO_TIMESTAMPING_OLD 37
+#  define SO_TIMESTAMP_NEW 63
+#  define SO_TIMESTAMPNS_NEW 64
+#  define SO_TIMESTAMPING_NEW 65
+
+#  ifdef __USE_TIME_BITS64
+#   define SO_RCVTIMEO SO_RCVTIMEO_NEW
+#   define SO_SNDTIMEO SO_SNDTIMEO_NEW
+#   define SO_TIMESTAMP SO_TIMESTAMP_NEW
+#   define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
+#   define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
+#  else
+#   define SO_RCVTIMEO SO_RCVTIMEO_OLD
+#   define SO_SNDTIMEO SO_SNDTIMEO_OLD
+#   define SO_TIMESTAMP SO_TIMESTAMP_OLD
+#   define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
+#   define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
+#  endif
+# endif
 #endif
-#define SO_TYPE 3
diff --git a/sysdeps/unix/sysv/linux/hppa/bits/socket-constants.h b/sysdeps/unix/sysv/linux/hppa/bits/socket-constants.h
index b4fb65b9f1..68b42d4606 100644
--- a/sysdeps/unix/sysv/linux/hppa/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/hppa/bits/socket-constants.h
@@ -30,9 +30,41 @@ 
 #define SO_OOBINLINE 256
 #define SO_RCVBUF 4098
 #define SO_RCVLOWAT 4100
-#define SO_RCVTIMEO 4102
 #define SO_REUSEADDR 4
 #define SO_SNDBUF 4097
 #define SO_SNDLOWAT 4099
-#define SO_SNDTIMEO 4101
 #define SO_TYPE 4104
+
+#if __TIMESIZE == 64
+# define SO_RCVTIMEO 4102
+# define SO_SNDTIMEO 4101
+# define SO_TIMESTAMP 16402
+# define SO_TIMESTAMPNS 16403
+# define SO_TIMESTAMPING 16416
+#else
+# define SO_RCVTIMEO_OLD 4102
+# define SO_SNDTIMEO_OLD 4101
+# define SO_RCVTIMEO_NEW 16448
+# define SO_SNDTIMEO_NEW 16449
+
+# define SO_TIMESTAMP_OLD 0x4012
+# define SO_TIMESTAMPNS_OLD 0x4013
+# define SO_TIMESTAMPING_OLD 0x4020
+# define SO_TIMESTAMP_NEW 0x4038
+# define SO_TIMESTAMPNS_NEW 0x4039
+# define SO_TIMESTAMPING_NEW 0x403A
+
+# ifdef __USE_TIME_BITS64
+#  define SO_RCVTIMEO SO_RCVTIMEO_NEW
+#  define SO_SNDTIMEO SO_SNDTIMEO_NEW
+#  define SO_TIMESTAMP SO_TIMESTAMP_NEW
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
+# else
+#  define SO_RCVTIMEO SO_RCVTIMEO_OLD
+#  define SO_SNDTIMEO SO_SNDTIMEO_OLD
+#  define SO_TIMESTAMP SO_TIMESTAMP_OLD
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/bits/socket-constants.h b/sysdeps/unix/sysv/linux/mips/bits/socket-constants.h
index a5264536e9..b18a854e99 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/socket-constants.h
@@ -30,9 +30,41 @@ 
 #define SO_OOBINLINE 256
 #define SO_RCVBUF 4098
 #define SO_RCVLOWAT 4100
-#define SO_RCVTIMEO 4102
 #define SO_REUSEADDR 4
 #define SO_SNDBUF 4097
 #define SO_SNDLOWAT 4099
-#define SO_SNDTIMEO 4101
 #define SO_TYPE 4104
+
+#if __TIMESIZE == 64
+# define SO_RCVTIMEO 4102
+# define SO_SNDTIMEO 4101
+# define SO_TIMESTAMP 29
+# define SO_TIMESTAMPNS 35
+# define SO_TIMESTAMPING 37
+#else
+# define SO_RCVTIMEO_OLD 4102
+# define SO_SNDTIMEO_OLD 4101
+# define SO_RCVTIMEO_NEW 66
+# define SO_SNDTIMEO_NEW 67
+
+# define SO_TIMESTAMP_OLD 29
+# define SO_TIMESTAMPNS_OLD 35
+# define SO_TIMESTAMPING_OLD 37
+# define SO_TIMESTAMP_NEW 63
+# define SO_TIMESTAMPNS_NEW 64
+# define SO_TIMESTAMPING_NEW 65
+
+# ifdef __USE_TIME_BITS64
+#  define SO_RCVTIMEO SO_RCVTIMEO_NEW
+#  define SO_SNDTIMEO SO_SNDTIMEO_NEW
+#  define SO_TIMESTAMP SO_TIMESTAMP_NEW
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
+# else
+#  define SO_RCVTIMEO SO_RCVTIMEO_OLD
+#  define SO_SNDTIMEO SO_SNDTIMEO_OLD
+#  define SO_TIMESTAMP SO_TIMESTAMP_OLD
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/socket-constants.h b/sysdeps/unix/sysv/linux/powerpc/bits/socket-constants.h
index f35488b375..c03141bb8c 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/socket-constants.h
@@ -30,9 +30,41 @@ 
 #define SO_OOBINLINE 10
 #define SO_RCVBUF 8
 #define SO_RCVLOWAT 16
-#define SO_RCVTIMEO 18
 #define SO_REUSEADDR 2
 #define SO_SNDBUF 7
 #define SO_SNDLOWAT 17
-#define SO_SNDTIMEO 19
 #define SO_TYPE 3
+
+#if __TIMESIZE == 64
+# define SO_RCVTIMEO 18
+# define SO_SNDTIMEO 19
+# define SO_TIMESTAMP 29
+# define SO_TIMESTAMPNS 35
+# define SO_TIMESTAMPING 37
+#else
+# define SO_RCVTIMEO_OLD 18
+# define SO_SNDTIMEO_OLD 19
+# define SO_RCVTIMEO_NEW 66
+# define SO_SNDTIMEO_NEW 67
+
+# define SO_TIMESTAMP_OLD 29
+# define SO_TIMESTAMPNS_OLD 35
+# define SO_TIMESTAMPING_OLD 37
+# define SO_TIMESTAMP_NEW 63
+# define SO_TIMESTAMPNS_NEW 64
+# define SO_TIMESTAMPING_NEW 65
+
+# ifdef __USE_TIME_BITS64
+#  define SO_RCVTIMEO SO_RCVTIMEO_NEW
+#  define SO_SNDTIMEO SO_SNDTIMEO_NEW
+#  define SO_TIMESTAMP SO_TIMESTAMP_NEW
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
+# else
+#  define SO_RCVTIMEO SO_RCVTIMEO_OLD
+#  define SO_SNDTIMEO SO_SNDTIMEO_OLD
+#  define SO_TIMESTAMP SO_TIMESTAMP_OLD
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/socket-constants.h b/sysdeps/unix/sysv/linux/sparc/bits/socket-constants.h
index a58d0b5f96..5c4ed76c8c 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/socket-constants.h
@@ -30,9 +30,41 @@ 
 #define SO_OOBINLINE 256
 #define SO_RCVBUF 4098
 #define SO_RCVLOWAT 2048
-#define SO_RCVTIMEO 8192
 #define SO_REUSEADDR 4
 #define SO_SNDBUF 4097
 #define SO_SNDLOWAT 4096
-#define SO_SNDTIMEO 16384
 #define SO_TYPE 4104
+
+#if __TIMESIZE == 64
+# define SO_RCVTIMEO 8192
+# define SO_SNDTIMEO 16384
+# define SO_TIMESTAMP 29
+# define SO_TIMESTAMPNS 33
+# define SO_TIMESTAMPING 35
+#else
+# define SO_RCVTIMEO_OLD 8192
+# define SO_SNDTIMEO_OLD 16384
+# define SO_RCVTIMEO_NEW 68
+# define SO_SNDTIMEO_NEW 69
+
+# define SO_TIMESTAMP_OLD 0x001d
+# define SO_TIMESTAMPNS_OLD 0x0021
+# define SO_TIMESTAMPING_OLD 0x0023
+# define SO_TIMESTAMP_NEW 0x0046
+# define SO_TIMESTAMPNS_NEW 0x0042
+# define SO_TIMESTAMPING_NEW 0x0043
+
+# ifdef __USE_TIME_BITS64
+#  define SO_RCVTIMEO SO_RCVTIMEO_NEW
+#  define SO_SNDTIMEO SO_SNDTIMEO_NEW
+#  define SO_TIMESTAMP SO_TIMESTAMP_NEW
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
+# else
+#  define SO_RCVTIMEO SO_RCVTIMEO_OLD
+#  define SO_SNDTIMEO SO_SNDTIMEO_OLD
+#  define SO_TIMESTAMP SO_TIMESTAMP_OLD
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
+# endif
+#endif