]> granicus.if.org Git - strace/commitdiff
net.c: move fallback definition of struct mmsghdr to a separate file.
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 27 Jun 2016 00:02:41 +0000 (00:02 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 27 Jun 2016 00:10:08 +0000 (00:10 +0000)
* 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.

Makefile.am
msghdr.h [new file with mode: 0644]
net.c
tests/mmsg.c

index c506f165b7e220f60a813d2be1374a6a6eeb46c8..1a578376b0a5d76d6a867c204109c7801cb41111 100644 (file)
@@ -153,6 +153,7 @@ strace_SOURCES =    \
        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 (file)
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 c5ecf123ab9bde37c00fdb69881f4b065181cd5b..3a7f94036bb2f74379c0e1c3890fe0015a66f917 100644 (file)
--- 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 @@ struct mmsghdr32 {
        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)
index 85e61d5c2ab864c0325119b2bdafc58598134f1a..00e1ef33ac4de2a85ce6027332b9070297cd63ae 100644 (file)
 # 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)