net.c: move fallback definition of struct mmsghdr to a separate file.
* msghdr.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* net.c: Include it. Move fallback definition of struct mmsghdr there.
* tests/mmsg.c: Include "msghdr.h". Remove fallback definition
of struct mmsghdr.
diff --git a/Makefile.am b/Makefile.am
index c506f16..1a57837 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -153,6 +153,7 @@
mount.c \
mpers_type.h \
mq.c \
+ msghdr.h \
mtd.c \
native_defs.h \
net.c \
diff --git a/msghdr.h b/msghdr.h
new file mode 100644
index 0000000..9cf9854
--- /dev/null
+++ b/msghdr.h
@@ -0,0 +1,14 @@
+#ifndef MSGHDR_H_
+# define MSGHDR_H_
+
+/* For definitions of struct msghdr and struct mmsghdr. */
+# include <sys/socket.h>
+
+# ifndef HAVE_STRUCT_MMSGHDR
+struct mmsghdr {
+ struct msghdr msg_hdr;
+ unsigned msg_len;
+};
+# endif
+
+#endif /* MSGHDR_H_ */
diff --git a/net.c b/net.c
index c5ecf12..3a7f940 100644
--- a/net.c
+++ b/net.c
@@ -29,6 +29,7 @@
*/
#include "defs.h"
+#include "msghdr.h"
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/uio.h>
@@ -440,13 +441,6 @@
uint32_t /* unsigned */ msg_len;
};
-#ifndef HAVE_STRUCT_MMSGHDR
-struct mmsghdr {
- struct msghdr msg_hdr;
- unsigned msg_len;
-};
-#endif
-
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
static void
copy_from_msghdr32(struct msghdr *to_msg, struct msghdr32 *from_msg32)
diff --git a/tests/mmsg.c b/tests/mmsg.c
index 85e61d5..00e1ef3 100644
--- a/tests/mmsg.c
+++ b/tests/mmsg.c
@@ -36,14 +36,8 @@
# include <errno.h>
# include <stdio.h>
# include <unistd.h>
-# include <sys/socket.h>
-# ifndef HAVE_STRUCT_MMSGHDR
-struct mmsghdr {
- struct msghdr msg_hdr;
- unsigned msg_len;
-};
-# endif
+# include "msghdr.h"
static int
send_mmsg(int fd, struct mmsghdr *vec, unsigned int vlen, unsigned int flags)