]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Introduce macro ASSUME_ALIGNED and use it in vki-linux.h.
authorIvo Raisr <ivosh@ivosh.net>
Sun, 26 Feb 2017 21:37:04 +0000 (21:37 +0000)
committerIvo Raisr <ivosh@ivosh.net>
Sun, 26 Feb 2017 21:37:04 +0000 (21:37 +0000)
Reduces the number of compiler warnings on MIPS platforms.
Partial fix for BZ#370028.
Patch by: Aleksandar Rikalo <aleksandar.rikalo@imgtec.com>

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16256

NEWS
include/pub_tool_basics.h
include/vki/vki-linux.h

diff --git a/NEWS b/NEWS
index a1560931362777dacc50fb6cd08f0621d3960c1f..f34dc8f50b43cba9a129f71ad56399858b95d017 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -108,6 +108,7 @@ where XXXXXX is the bug number as listed below.
 368924  WARNING: unhandled arm64-linux syscall: 84 (sync_file_range)
 368925  WARNING: unhandled arm64-linux syscall: 130 (tkill)
 368926  WARNING: unhandled arm64-linux syscall: 97 (unshare)
+370028  Reduce the number of compiler warnings on MIPS platforms (partial fix)
 370635  arm64 missing syscall getcpu
 371225  Fix order of timer_{gettime,getoverrun,settime} syscalls on arm64
 371412  Rename wrap_sys_shmat to sys_shmat like other wrappers
index 6ef37c7bf5f3bb82d89517a6bf505dde014d37ff..4712c117cf951fff0934e59d45d034fe32b2e2c9 100644 (file)
@@ -468,6 +468,17 @@ static inline Bool sr_EQ ( UInt sysno, SysRes sr1, SysRes sr2 ) {
       } var = { .in = x }; var.out;  \
    })
 
+/* Some architectures (eg. mips, arm) do not support unaligned memory access
+   by hardware, so GCC warns about suspicious situations. This macro could
+   be used to avoid these warnings but only after careful examination. */
+#define ASSUME_ALIGNED(D, x)                 \
+   ({                                        \
+      union {                                \
+         void *in;                           \
+         D out;                              \
+      } var = {.in = (void *) (x)}; var.out; \
+   })
+
 // Poor man's static assert
 #define STATIC_ASSERT(x)  extern int VG_(VG_(VG_(unused)))[(x) ? 1 : -1] \
                                      __attribute__((unused))
index b64b52108aec7155deb98389d06a39c377e1d6f1..f70be844bf5d5748c62e297a200d8aa9c1287e6d 100644 (file)
@@ -674,7 +674,8 @@ __KINLINE struct vki_cmsghdr * __vki_cmsg_nxthdr(void *__ctl, __vki_kernel_size_
 {
        struct vki_cmsghdr * __ptr;
 
-       __ptr = (struct vki_cmsghdr*)(((unsigned char *) __cmsg) +  VKI_CMSG_ALIGN(__cmsg->cmsg_len));
+       __ptr = ASSUME_ALIGNED(struct vki_cmsghdr *,
+               ((unsigned char *) __cmsg) +  VKI_CMSG_ALIGN(__cmsg->cmsg_len));
        if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
                return (struct vki_cmsghdr *)0;