mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] missing parts to time64 switchover
@ 2019-11-01 14:56 Rich Felker
  2019-11-01 20:04 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Felker @ 2019-11-01 14:56 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]

The time64 switchover I had been testing and hoped to push yesterday
turned out to be missing the ioctl and sockopt bits, which I
eventually remembered I'd omitted in the late-summer i386-only draft
because making a bunch more archs have arch variants for these did not
seem fun. So, I've worked out some changes to allow top-level socket.h
to do a lot more. The msghdr move is pretty much orthogonal, aside
from interaction with x32.

It's probably not perfect at this point, but I think it's an
improvement, and short of errors good enough to commit. It brings
things closer to a state of only needing arch-specific bits for archs
that actually do weird things, rather than repeating things that are
universal to all 32-bit archs or all 64-bit archs on a per-arch basis.

These patches should apply ok on the last time64 switchover draft
posted to the list. But I'm posting them more for the sake of a (very
brief) comment period about what they're doing, and to have a record
of them as individual patches -- some of them will be squashed since
they yield ABI-inconsistent revisions if left split.

Rich

[-- Attachment #2: 0001-fix-x32-msghdr-struct-by-removing-x32-bits-socket.h.patch --]
[-- Type: text/plain, Size: 1352 bytes --]

From d95f4ec080bafae7f154a475b90a7f0468aa3bf9 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Thu, 31 Oct 2019 22:55:39 -0400
Subject: [PATCH 1/6] fix x32 msghdr struct by removing x32 bits/socket.h

being that it contains pointers and (from the kernel perspective,
which is wrong) size_t members, x32 uses the 32-bit version of the
structure, not a half-32-bit, half-64-bit layout like we had here. the
x86_64 definition was inadvertently copied when x32 was first added.

unlike errors in the opposite direction (missing padding), this error
was not easily detected breakage, because the layout of the commonly
used initial subset of members still matched. breakage could only be
observed in the presence of control messages or flags.
---
 arch/x32/bits/socket.h | 16 ----------------
 1 file changed, 16 deletions(-)
 delete mode 100644 arch/x32/bits/socket.h

diff --git a/arch/x32/bits/socket.h b/arch/x32/bits/socket.h
deleted file mode 100644
index a4c89f3d..00000000
--- a/arch/x32/bits/socket.h
+++ /dev/null
@@ -1,16 +0,0 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-	int msg_iovlen, __pad1;
-	void *msg_control;
-	socklen_t msg_controllen, __pad2;
-	int msg_flags;
-};
-
-struct cmsghdr {
-	socklen_t cmsg_len;
-	int __pad1;
-	int cmsg_level;
-	int cmsg_type;
-};
-- 
2.21.0


[-- Attachment #3: 0002-move-msghdr-and-cmsghdr-out-of-bits-socket.h.patch --]
[-- Type: text/plain, Size: 8461 bytes --]

From 93ea221c619cc027c8b90626fc745ca1c9a09898 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Thu, 31 Oct 2019 23:09:48 -0400
Subject: [PATCH 2/6] move msghdr and cmsghdr out of bits/socket.h

these structures can now be defined generically in terms of endianness
and long size. previously, the 32-bit archs all shared a common
definition from the generic bits header, and each 64-bit arch had to
repeat the 64-bit version, with endian conditionals if the arch had
variants of each endianness.

I would prefer getting rid of the preprocessor conditionals for
padding and instead using unnamed bitfield members, like commit
9b2921bea1d5017832e1b45d1fd64220047a9802 did for struct timespec.
however, at present sendmsg, recvmsg, and recvmmsg need access to the
padding members by name to zero them. this could perhaps be cleaned up
in the future.
---
 arch/aarch64/bits/socket.h   | 31 -------------------------------
 arch/generic/bits/socket.h   | 15 ---------------
 arch/mips/bits/socket.h      | 16 ----------------
 arch/mips64/bits/socket.h    | 32 --------------------------------
 arch/mipsn32/bits/socket.h   | 16 ----------------
 arch/powerpc/bits/socket.h   | 16 ----------------
 arch/powerpc64/bits/socket.h | 32 --------------------------------
 arch/riscv64/bits/socket.h   | 17 -----------------
 arch/s390x/bits/socket.h     | 17 -----------------
 arch/x86_64/bits/socket.h    | 16 ----------------
 include/sys/socket.h         | 34 ++++++++++++++++++++++++++++++++++
 11 files changed, 34 insertions(+), 208 deletions(-)
 delete mode 100644 arch/aarch64/bits/socket.h
 delete mode 100644 arch/riscv64/bits/socket.h
 delete mode 100644 arch/s390x/bits/socket.h
 delete mode 100644 arch/x86_64/bits/socket.h

diff --git a/arch/aarch64/bits/socket.h b/arch/aarch64/bits/socket.h
deleted file mode 100644
index 55337c8b..00000000
--- a/arch/aarch64/bits/socket.h
+++ /dev/null
@@ -1,31 +0,0 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-#if __BYTE_ORDER == __BIG_ENDIAN
-	int __pad1, msg_iovlen;
-#else
-	int msg_iovlen, __pad1;
-#endif
-	void *msg_control;
-#if __BYTE_ORDER == __BIG_ENDIAN
-	int __pad2;
-	socklen_t msg_controllen;
-#else
-	socklen_t msg_controllen;
-	int __pad2;
-#endif
-	int msg_flags;
-};
-
-struct cmsghdr {
-#if __BYTE_ORDER == __BIG_ENDIAN
-	int __pad1;
-	socklen_t cmsg_len;
-#else
-	socklen_t cmsg_len;
-	int __pad1;
-#endif
-	int cmsg_level;
-	int cmsg_type;
-};
diff --git a/arch/generic/bits/socket.h b/arch/generic/bits/socket.h
index 1f73b995..e69de29b 100644
--- a/arch/generic/bits/socket.h
+++ b/arch/generic/bits/socket.h
@@ -1,15 +0,0 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-	int msg_iovlen;
-	void *msg_control;
-	socklen_t msg_controllen;
-	int msg_flags;
-};
-
-struct cmsghdr {
-	socklen_t cmsg_len;
-	int cmsg_level;
-	int cmsg_type;
-};
diff --git a/arch/mips/bits/socket.h b/arch/mips/bits/socket.h
index b82c7d34..92551b9f 100644
--- a/arch/mips/bits/socket.h
+++ b/arch/mips/bits/socket.h
@@ -1,19 +1,3 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-	int msg_iovlen;
-	void *msg_control;
-	socklen_t msg_controllen;
-	int msg_flags;
-};
-
-struct cmsghdr {
-	socklen_t cmsg_len;
-	int cmsg_level;
-	int cmsg_type;
-};
-
 #define SOCK_STREAM    2
 #define SOCK_DGRAM     1
 
diff --git a/arch/mips64/bits/socket.h b/arch/mips64/bits/socket.h
index aafb209c..519b9c8e 100644
--- a/arch/mips64/bits/socket.h
+++ b/arch/mips64/bits/socket.h
@@ -1,35 +1,3 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-#if __BYTE_ORDER == __BIG_ENDIAN
-	int __pad1, msg_iovlen;
-#else
-	int msg_iovlen, __pad1;
-#endif
-	void *msg_control;
-#if __BYTE_ORDER == __BIG_ENDIAN
-	int __pad2;
-	socklen_t msg_controllen;
-#else
-	socklen_t msg_controllen;
-	int __pad2;
-#endif
-	int msg_flags;
-};
-
-struct cmsghdr {
-#if __BYTE_ORDER == __BIG_ENDIAN
-	int __pad1;
-	socklen_t cmsg_len;
-#else
-	socklen_t cmsg_len;
-	int __pad1;
-#endif
-	int cmsg_level;
-	int cmsg_type;
-};
-
 #define SOCK_STREAM    2
 #define SOCK_DGRAM     1
 #define SOL_SOCKET     65535
diff --git a/arch/mipsn32/bits/socket.h b/arch/mipsn32/bits/socket.h
index b82c7d34..92551b9f 100644
--- a/arch/mipsn32/bits/socket.h
+++ b/arch/mipsn32/bits/socket.h
@@ -1,19 +1,3 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-	int msg_iovlen;
-	void *msg_control;
-	socklen_t msg_controllen;
-	int msg_flags;
-};
-
-struct cmsghdr {
-	socklen_t cmsg_len;
-	int cmsg_level;
-	int cmsg_type;
-};
-
 #define SOCK_STREAM    2
 #define SOCK_DGRAM     1
 
diff --git a/arch/powerpc/bits/socket.h b/arch/powerpc/bits/socket.h
index a94b8bdb..557e324f 100644
--- a/arch/powerpc/bits/socket.h
+++ b/arch/powerpc/bits/socket.h
@@ -1,19 +1,3 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-	int msg_iovlen;
-	void *msg_control;
-	socklen_t msg_controllen;
-	int msg_flags;
-};
-
-struct cmsghdr {
-	socklen_t cmsg_len;
-	int cmsg_level;
-	int cmsg_type;
-};
-
 #define SO_DEBUG        1
 #define SO_REUSEADDR    2
 #define SO_TYPE         3
diff --git a/arch/powerpc64/bits/socket.h b/arch/powerpc64/bits/socket.h
index dae47302..557e324f 100644
--- a/arch/powerpc64/bits/socket.h
+++ b/arch/powerpc64/bits/socket.h
@@ -1,35 +1,3 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-#if __BYTE_ORDER == __BIG_ENDIAN
-	int __pad1, msg_iovlen;
-#else
-	int msg_iovlen, __pad1;
-#endif
-	void *msg_control;
-#if __BYTE_ORDER == __BIG_ENDIAN
-	int __pad2;
-	socklen_t msg_controllen;
-#else
-	socklen_t msg_controllen;
-	int __pad2;
-#endif
-	int msg_flags;
-};
-
-struct cmsghdr {
-#if __BYTE_ORDER == __BIG_ENDIAN
-	int __pad1;
-	socklen_t cmsg_len;
-#else
-	socklen_t cmsg_len;
-	int __pad1;
-#endif
-	int cmsg_level;
-	int cmsg_type;
-};
-
 #define SO_DEBUG        1
 #define SO_REUSEADDR    2
 #define SO_TYPE         3
diff --git a/arch/riscv64/bits/socket.h b/arch/riscv64/bits/socket.h
deleted file mode 100644
index e2fd64cf..00000000
--- a/arch/riscv64/bits/socket.h
+++ /dev/null
@@ -1,17 +0,0 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-	int msg_iovlen, __pad1;
-	void *msg_control;
-	socklen_t msg_controllen;
-	int __pad2;
-	int msg_flags;
-};
-
-struct cmsghdr {
-	socklen_t cmsg_len;
-	int __pad1;
-	int cmsg_level;
-	int cmsg_type;
-};
diff --git a/arch/s390x/bits/socket.h b/arch/s390x/bits/socket.h
deleted file mode 100644
index bd4b20c4..00000000
--- a/arch/s390x/bits/socket.h
+++ /dev/null
@@ -1,17 +0,0 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-	int __pad1, msg_iovlen;
-	void *msg_control;
-	int __pad2;
-	socklen_t msg_controllen;
-	int msg_flags;
-};
-
-struct cmsghdr {
-	int __pad1;
-	socklen_t cmsg_len;
-	int cmsg_level;
-	int cmsg_type;
-};
diff --git a/arch/x86_64/bits/socket.h b/arch/x86_64/bits/socket.h
deleted file mode 100644
index a4c89f3d..00000000
--- a/arch/x86_64/bits/socket.h
+++ /dev/null
@@ -1,16 +0,0 @@
-struct msghdr {
-	void *msg_name;
-	socklen_t msg_namelen;
-	struct iovec *msg_iov;
-	int msg_iovlen, __pad1;
-	void *msg_control;
-	socklen_t msg_controllen, __pad2;
-	int msg_flags;
-};
-
-struct cmsghdr {
-	socklen_t cmsg_len;
-	int __pad1;
-	int cmsg_level;
-	int cmsg_type;
-};
diff --git a/include/sys/socket.h b/include/sys/socket.h
index 04077654..b1dfeace 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -19,6 +19,40 @@ extern "C" {
 
 #include <bits/socket.h>
 
+struct msghdr {
+	void *msg_name;
+	socklen_t msg_namelen;
+	struct iovec *msg_iov;
+#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN
+	int __pad1;
+#endif
+	int msg_iovlen;
+#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN
+	int __pad1;
+#endif
+	void *msg_control;
+#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN
+	int __pad2;
+#endif
+	socklen_t msg_controllen;
+#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN
+	int __pad2;
+#endif
+	int msg_flags;
+};
+
+struct cmsghdr {
+#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN
+	int __pad1;
+#endif
+	socklen_t cmsg_len;
+#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN
+	int __pad1;
+#endif
+	int cmsg_level;
+	int cmsg_type;
+};
+
 #ifdef _GNU_SOURCE
 struct ucred {
 	pid_t pid;
-- 
2.21.0


[-- Attachment #4: 0003-add-back-x32-bits-socket.h-defining-time-related-soc.patch --]
[-- Type: text/plain, Size: 979 bytes --]

From bdef372be16617ff1318896773041fdc1a3a0280 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Thu, 31 Oct 2019 23:21:35 -0400
Subject: [PATCH 3/6] add back x32 bits/socket.h defining time-related socket
 options

these definitions are merely copied from the top-level sys/socket.h,
so there is no functional change at this time. however, the top-level
definitions will change to use the time64 "_NEW" versions on 32-bit
archs when time_t is switched over to 64-bit. this commit ensures that
change will be suppressed on x32.
---
 arch/x32/bits/socket.h | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 arch/x32/bits/socket.h

diff --git a/arch/x32/bits/socket.h b/arch/x32/bits/socket.h
new file mode 100644
index 00000000..8d830010
--- /dev/null
+++ b/arch/x32/bits/socket.h
@@ -0,0 +1,5 @@
+#define SO_RCVTIMEO     20
+#define SO_SNDTIMEO     21
+#define SO_TIMESTAMP    29
+#define SO_TIMESTAMPNS  35
+#define SO_TIMESTAMPING 37
-- 
2.21.0


[-- Attachment #5: 0004-add-x32-bits-ioctl_fix.h-defining-time-related-socki.patch --]
[-- Type: text/plain, Size: 814 bytes --]

From a1054a6b898bba88e21a329f25709b1dccad1bff Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Thu, 31 Oct 2019 23:40:10 -0400
Subject: [PATCH 4/6] add x32 bits/ioctl_fix.h defining time-related sockios
 macros

these definitions are copied from generic bits/ioctl.h, so that x32
keeps the "_OLD" versions (which are already time64 on x32) when
32-bit archs switch to 64-bit time_t.
---
 arch/x32/bits/ioctl_fix.h | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 arch/x32/bits/ioctl_fix.h

diff --git a/arch/x32/bits/ioctl_fix.h b/arch/x32/bits/ioctl_fix.h
new file mode 100644
index 00000000..79f5c281
--- /dev/null
+++ b/arch/x32/bits/ioctl_fix.h
@@ -0,0 +1,4 @@
+#undef SIOCGSTAMP
+#under SIOCGSTAMPNS
+#define SIOCGSTAMP      0x8906
+#define SIOCGSTAMPNS    0x8907
-- 
2.21.0


[-- Attachment #6: 0005-convert-ioctl-sockios-macro-definitions-for-time64.patch --]
[-- Type: text/plain, Size: 2830 bytes --]

From 244e72f613ac69a79f4531a82cc36c6d26c50860 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Fri, 1 Nov 2019 10:34:03 -0400
Subject: [PATCH 5/6] convert ioctl sockios macro definitions for time64

this should be squashed as a fixup to the time64 switchover.
---
 arch/generic/bits/ioctl.h | 5 +++++
 arch/mips/bits/ioctl.h    | 4 ++--
 arch/mipsn32/bits/ioctl.h | 2 ++
 arch/powerpc/bits/ioctl.h | 4 ++--
 arch/sh/bits/ioctl.h      | 4 ++--
 5 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/arch/generic/bits/ioctl.h b/arch/generic/bits/ioctl.h
index d1a6c035..60ae8b85 100644
--- a/arch/generic/bits/ioctl.h
+++ b/arch/generic/bits/ioctl.h
@@ -104,7 +104,12 @@
 #define FIOGETOWN       0x8903
 #define SIOCGPGRP       0x8904
 #define SIOCATMARK      0x8905
+#if __LONG_MAX == 0x7fffffff
+#define SIOCGSTAMP      _IOR(0x89, 6, char[16])
+#define SIOCGSTAMPNS    _IOR(0x89, 7, char[16])
+#else
 #define SIOCGSTAMP      0x8906
 #define SIOCGSTAMPNS    0x8907
+#endif
 
 #include <bits/ioctl_fix.h>
diff --git a/arch/mips/bits/ioctl.h b/arch/mips/bits/ioctl.h
index e277c3f0..e20bf19e 100644
--- a/arch/mips/bits/ioctl.h
+++ b/arch/mips/bits/ioctl.h
@@ -110,5 +110,5 @@
 #define SIOCATMARK      _IOR('s', 7, int)
 #define SIOCSPGRP       _IOW('s', 8, pid_t)
 #define SIOCGPGRP       _IOR('s', 9, pid_t)
-#define SIOCGSTAMP      0x8906
-#define SIOCGSTAMPNS    0x8907
+#define SIOCGSTAMP      _IOR(0x89, 6, char[16])
+#define SIOCGSTAMPNS    _IOR(0x89, 7, char[16])
diff --git a/arch/mipsn32/bits/ioctl.h b/arch/mipsn32/bits/ioctl.h
index e277c3f0..f0e39563 100644
--- a/arch/mipsn32/bits/ioctl.h
+++ b/arch/mipsn32/bits/ioctl.h
@@ -112,3 +112,5 @@
 #define SIOCGPGRP       _IOR('s', 9, pid_t)
 #define SIOCGSTAMP      0x8906
 #define SIOCGSTAMPNS    0x8907
+#define SIOCGSTAMP      _IOR(0x89, 6, char[16])
+#define SIOCGSTAMPNS    _IOR(0x89, 7, char[16])
diff --git a/arch/powerpc/bits/ioctl.h b/arch/powerpc/bits/ioctl.h
index b6cbb18f..ac9bfd20 100644
--- a/arch/powerpc/bits/ioctl.h
+++ b/arch/powerpc/bits/ioctl.h
@@ -116,5 +116,5 @@
 #define FIOGETOWN       0x8903
 #define SIOCGPGRP       0x8904
 #define SIOCATMARK      0x8905
-#define SIOCGSTAMP      0x8906
-#define SIOCGSTAMPNS    0x8907
+#define SIOCGSTAMP      _IOR(0x89, 6, char[16])
+#define SIOCGSTAMPNS    _IOR(0x89, 7, char[16])
diff --git a/arch/sh/bits/ioctl.h b/arch/sh/bits/ioctl.h
index c4305655..370b6901 100644
--- a/arch/sh/bits/ioctl.h
+++ b/arch/sh/bits/ioctl.h
@@ -108,5 +108,5 @@
 #define SIOCATMARK      _IOR('s', 7, int)
 #define SIOCSPGRP       _IOW('s', 8, int)
 #define SIOCGPGRP       _IOW('s', 9, int)
-#define SIOCGSTAMP      _IOR('s', 100, char[8])
-#define SIOCGSTAMPNS    _IOR('s', 101, char[8])
+#define SIOCGSTAMP      _IOR(0x89, 6, char[16])
+#define SIOCGSTAMPNS    _IOR(0x89, 7, char[16])
-- 
2.21.0


[-- Attachment #7: 0006-convert-socket-option-macro-definitions-for-time64.patch --]
[-- Type: text/plain, Size: 3029 bytes --]

From d51f6dee3644111813c54efeccad2fe26b953883 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Fri, 1 Nov 2019 10:41:02 -0400
Subject: [PATCH 6/6] convert socket option macro definitions for time64

this should be squashed as a fixup to the time64 switchover.
---
 arch/mips/bits/socket.h    | 7 +++++--
 arch/mipsn32/bits/socket.h | 7 +++++--
 arch/powerpc/bits/socket.h | 7 +++++--
 include/sys/socket.h       | 7 +++++++
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/arch/mips/bits/socket.h b/arch/mips/bits/socket.h
index 92551b9f..4ffc4d4a 100644
--- a/arch/mips/bits/socket.h
+++ b/arch/mips/bits/socket.h
@@ -16,13 +16,16 @@
 #define SO_RCVBUF       0x1002
 #define SO_SNDLOWAT     0x1003
 #define SO_RCVLOWAT     0x1004
-#define SO_RCVTIMEO     0x1006
-#define SO_SNDTIMEO     0x1005
 #define SO_ERROR        0x1007
 #define SO_TYPE         0x1008
 #define SO_ACCEPTCONN   0x1009
 #define SO_PROTOCOL     0x1028
 #define SO_DOMAIN       0x1029
+#define SO_TIMESTAMP    63
+#define SO_TIMESTAMPNS  64
+#define SO_TIMESTAMPING 65
+#define SO_RCVTIMEO     66
+#define SO_SNDTIMEO     67
 
 #define SO_NO_CHECK     11
 #define SO_PRIORITY     12
diff --git a/arch/mipsn32/bits/socket.h b/arch/mipsn32/bits/socket.h
index 92551b9f..4ffc4d4a 100644
--- a/arch/mipsn32/bits/socket.h
+++ b/arch/mipsn32/bits/socket.h
@@ -16,13 +16,16 @@
 #define SO_RCVBUF       0x1002
 #define SO_SNDLOWAT     0x1003
 #define SO_RCVLOWAT     0x1004
-#define SO_RCVTIMEO     0x1006
-#define SO_SNDTIMEO     0x1005
 #define SO_ERROR        0x1007
 #define SO_TYPE         0x1008
 #define SO_ACCEPTCONN   0x1009
 #define SO_PROTOCOL     0x1028
 #define SO_DOMAIN       0x1029
+#define SO_TIMESTAMP    63
+#define SO_TIMESTAMPNS  64
+#define SO_TIMESTAMPING 65
+#define SO_RCVTIMEO     66
+#define SO_SNDTIMEO     67
 
 #define SO_NO_CHECK     11
 #define SO_PRIORITY     12
diff --git a/arch/powerpc/bits/socket.h b/arch/powerpc/bits/socket.h
index 557e324f..e5fa0f7a 100644
--- a/arch/powerpc/bits/socket.h
+++ b/arch/powerpc/bits/socket.h
@@ -15,8 +15,6 @@
 #define SO_REUSEPORT    15
 #define SO_RCVLOWAT     16
 #define SO_SNDLOWAT     17
-#define SO_RCVTIMEO     18
-#define SO_SNDTIMEO     19
 #define SO_PASSCRED     20
 #define SO_PEERCRED     21
 #define SO_ACCEPTCONN   30
@@ -25,3 +23,8 @@
 #define SO_RCVBUFFORCE  33
 #define SO_PROTOCOL     38
 #define SO_DOMAIN       39
+#define SO_TIMESTAMP    63
+#define SO_TIMESTAMPNS  64
+#define SO_TIMESTAMPING 65
+#define SO_RCVTIMEO     66
+#define SO_SNDTIMEO     67
diff --git a/include/sys/socket.h b/include/sys/socket.h
index b1dfeace..a17898ce 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -225,6 +225,13 @@ struct linger {
 #endif
 
 #ifndef SO_RCVTIMEO
+#if __LONG_MAX == 0x7fffffff
+#define SO_TIMESTAMP    63
+#define SO_TIMESTAMPNS  64
+#define SO_TIMESTAMPING 65
+#define SO_RCVTIMEO     66
+#define SO_SNDTIMEO     67
+#else
 #define SO_RCVTIMEO     20
 #define SO_SNDTIMEO     21
 #define SO_TIMESTAMP    29
-- 
2.21.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] missing parts to time64 switchover
  2019-11-01 14:56 [PATCH] missing parts to time64 switchover Rich Felker
@ 2019-11-01 20:04 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2019-11-01 20:04 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1520 bytes --]

On Fri, Nov 01, 2019 at 10:56:17AM -0400, Rich Felker wrote:
> The time64 switchover I had been testing and hoped to push yesterday
> turned out to be missing the ioctl and sockopt bits, which I
> eventually remembered I'd omitted in the late-summer i386-only draft
> because making a bunch more archs have arch variants for these did not
> seem fun. So, I've worked out some changes to allow top-level socket.h
> to do a lot more. The msghdr move is pretty much orthogonal, aside
> from interaction with x32.
> 
> It's probably not perfect at this point, but I think it's an
> improvement, and short of errors good enough to commit. It brings
> things closer to a state of only needing arch-specific bits for archs
> that actually do weird things, rather than repeating things that are
> universal to all 32-bit archs or all 64-bit archs on a per-arch basis.
> 
> These patches should apply ok on the last time64 switchover draft
> posted to the list. But I'm posting them more for the sake of a (very
> brief) comment period about what they're doing, and to have a record
> of them as individual patches -- some of them will be squashed since
> they yield ABI-inconsistent revisions if left split.

I left out the first patch of this series, attached. Unfortunately it
had a bug: without changes to the bits headers, it caused
SO_TIMESTAMP* definitions to disappear from archs that define their
own SO_RCVTIMEO (powerpc* and mips*).

It will be fixed by separating these out into 2 groups with separate
#ifdefs.

Rich

[-- Attachment #2: 0000-make-time-related-socket-options-overridable-by-arch.patch --]
[-- Type: text/plain, Size: 1666 bytes --]

From 057a15f272f28c97b44a266227b1c834db566777 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Thu, 31 Oct 2019 16:48:30 -0400
Subject: [PATCH] make time-related socket options overridable by arch bits
 files

---
 include/sys/socket.h | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/sys/socket.h b/include/sys/socket.h
index 318a98ef..04077654 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -182,8 +182,6 @@ struct linger {
 #define SO_PEERCRED     17
 #define SO_RCVLOWAT     18
 #define SO_SNDLOWAT     19
-#define SO_RCVTIMEO     20
-#define SO_SNDTIMEO     21
 #define SO_ACCEPTCONN   30
 #define SO_PEERSEC      31
 #define SO_SNDBUFFORCE  32
@@ -192,6 +190,14 @@ struct linger {
 #define SO_DOMAIN       39
 #endif
 
+#ifndef SO_RCVTIMEO
+#define SO_RCVTIMEO     20
+#define SO_SNDTIMEO     21
+#define SO_TIMESTAMP    29
+#define SO_TIMESTAMPNS  35
+#define SO_TIMESTAMPING 37
+#endif
+
 #define SO_SECURITY_AUTHENTICATION              22
 #define SO_SECURITY_ENCRYPTION_TRANSPORT        23
 #define SO_SECURITY_ENCRYPTION_NETWORK          24
@@ -203,14 +209,10 @@ struct linger {
 #define SO_GET_FILTER           SO_ATTACH_FILTER
 
 #define SO_PEERNAME             28
-#define SO_TIMESTAMP            29
 #define SCM_TIMESTAMP           SO_TIMESTAMP
-
 #define SO_PASSSEC              34
-#define SO_TIMESTAMPNS          35
 #define SCM_TIMESTAMPNS         SO_TIMESTAMPNS
 #define SO_MARK                 36
-#define SO_TIMESTAMPING         37
 #define SCM_TIMESTAMPING        SO_TIMESTAMPING
 #define SO_RXQ_OVFL             40
 #define SO_WIFI_STATUS          41
-- 
2.21.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-01 20:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01 14:56 [PATCH] missing parts to time64 switchover Rich Felker
2019-11-01 20:04 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).