about summary refs log tree commit diff
path: root/include/sys
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2019-10-31 23:09:48 -0400
committerRich Felker <dalias@aerifal.cx>2019-11-02 18:30:56 -0400
commita0252bc75b8546008c6b87e58344c4340683d5eb (patch)
treee885f4e0f8fa4f1974b1d3da91411c123f613d85 /include/sys
parent573a4d2d597ba15435ffdf0f2d8bea1058e7b795 (diff)
downloadmusl-a0252bc75b8546008c6b87e58344c4340683d5eb.tar.gz
musl-a0252bc75b8546008c6b87e58344c4340683d5eb.tar.xz
musl-a0252bc75b8546008c6b87e58344c4340683d5eb.zip
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.
Diffstat (limited to 'include/sys')
-rw-r--r--include/sys/socket.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/sys/socket.h b/include/sys/socket.h
index 6be699d9..4ea7be1e 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;