]> granicus.if.org Git - strace/commitdiff
Use the definition of struct mmsghdr if it is defined in build environment
authorMasatake YAMATO <yamato@redhat.com>
Thu, 6 Nov 2014 16:23:25 +0000 (01:23 +0900)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 11 Nov 2014 15:42:07 +0000 (15:42 +0000)
mmsghrd structure type is defined locally in printmmsghdr function.

However, more functions will refer the definition in modifications for
supporting "-e write=set" and "-e read=set" option for sendmmsg and
recvmmsg system calls.

After this change, the system definition of struct mmsghdr will be used
if configure reports it is available, falling back to the old local
definition.

* configure.ac (AC_CHECK_TYPES): Add struct mmsghdr.
* net.c [!HAVE_STRUCT_MMSGHDR] (struct mmsghdr): Define.
(printmmsghdr): Use previously defined struct mmsghdr.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
configure.ac
net.c

index 98669fa34bba6a9f977712c5135f1492e46d6b7a..7862f65dbb9d392d8e4c99aa71c6eefd644fb39d 100644 (file)
@@ -260,6 +260,7 @@ AC_CHECK_HEADERS([asm/sigcontext.h], [], [], [#include <signal.h>])
 AC_CHECK_TYPES([struct sigcontext],,, [#include <signal.h>])
 AC_CHECK_HEADERS([netinet/tcp.h netinet/udp.h],,, [#include <netinet/in.h>])
 
+AC_CHECK_TYPES([struct mmsghdr],,, [#include <sys/socket.h>])
 AC_CHECK_MEMBERS([struct msghdr.msg_control],,, [#include <sys/socket.h>])
 
 AC_CHECK_TYPES([struct __old_kernel_stat],,, [#include <asm/stat.h>])
diff --git a/net.c b/net.c
index 41c55c667fad34cf1b8c820161f81aadb3f7e095..9e9e1591b38b32b33ea20049117c5d8864f76d2d 100644 (file)
--- a/net.c
+++ b/net.c
@@ -429,6 +429,13 @@ 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)
@@ -483,10 +490,7 @@ dumpiov_in_msghdr(struct tcb *tcp, long addr)
 static void
 printmmsghdr(struct tcb *tcp, long addr, unsigned int idx, unsigned long msg_len)
 {
-       struct mmsghdr {
-               struct msghdr msg_hdr;
-               unsigned msg_len;
-       } mmsg;
+       struct mmsghdr mmsg;
 
 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
        if (current_wordsize == 4) {