[compiler-rt] r272008 - [sanitizer] Fix build for new GLIBC msghdr/cmsghdr definition

Adhemerval Zanella via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 7 06:19:39 PDT 2016


Author: azanella
Date: Tue Jun  7 08:19:38 2016
New Revision: 272008

URL: http://llvm.org/viewvc/llvm-project?rev=272008&view=rev
Log:
[sanitizer] Fix build for new GLIBC msghdr/cmsghdr definition

GLIBC now follows POSIX [1] for both msghdr and cmsghdr definitions,
which means that msg_iovlen, msg_controllen, and cmsg_len are no
longer size_t but sockelen_t for 64-bits architectures. The final struct
size does not change, since paddings were added.

This patch fixes the build issue against GLIBC 2.24 socket.h header by
using the same definition for internal __sanitizer_msghdr and
__sanitizer_cmsghdr.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h?rev=272008&r1=272007&r2=272008&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h Tue Jun  7 08:19:38 2016
@@ -415,6 +415,49 @@ namespace __sanitizer {
     int cmsg_type;
   };
 #else
+# ifndef __GLIBC_PREREQ
+# define __GLIBC_PREREQ(x, y) 0
+# endif
+// GLIBC 2.24 follows msghdr and cmsghdr POSIX definition for internal
+// member size and adds padding where required.
+# if __GLIBC_PREREQ(2, 24) && defined(_LP64)
+#  if __BYTE_ORDER == __BIG_ENDIAN
+  struct __sanitizer_msghdr {
+    void *msg_name;
+    unsigned msg_namelen;
+    struct __sanitizer_iovec *msg_iov;
+    int __padding1;
+    unsigned msg_iovlen;
+    void *msg_control;
+    int __padding2;
+    unsigned msg_controllen;
+    int msg_flags;
+  };
+  struct __sanitizer_cmsghdr {
+    uptr cmsg_len;
+    int cmsg_level;
+    int cmsg_type;
+  };
+#  else
+  struct __sanitizer_msghdr {
+    void *msg_name;
+    unsigned msg_namelen;
+    struct __sanitizer_iovec *msg_iov;
+    int msg_iovlen;
+    int __padding1;
+    void *msg_control;
+    int msg_controllen;
+    int __padding2;
+    int msg_flags;
+  };
+  struct __sanitizer_cmsghdr {
+    unsigned cmsg_len;
+    int __padding1;
+    int cmsg_level;
+    int cmsg_type;
+  };
+#  endif // __BYTE_ORDER == __BIG_ENDIAN
+# else
   struct __sanitizer_msghdr {
     void *msg_name;
     unsigned msg_namelen;
@@ -429,6 +472,7 @@ namespace __sanitizer {
     int cmsg_level;
     int cmsg_type;
   };
+# endif // __GLIBC_PREREQ (2, 24) && __WORDSIZE == 64
 #endif
 
 #if SANITIZER_MAC




More information about the llvm-commits mailing list