Valgrind: r16256 - in /trunk: NEWS include/pub_tool_basics.h include/vki/vki-linux.h

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Valgrind: r16256 - in /trunk: NEWS include/pub_tool_basics.h include/vki/vki-linux.h

svn-2
Author: iraisr
Date: Sun Feb 26 21:37:04 2017
New Revision: 16256

Log:
Introduce macro ASSUME_ALIGNED and use it in vki-linux.h.
Reduces the number of compiler warnings on MIPS platforms.
Partial fix for BZ#370028.
Patch by: Aleksandar Rikalo <[hidden email]>

Modified:
    trunk/NEWS
    trunk/include/pub_tool_basics.h
    trunk/include/vki/vki-linux.h

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sun Feb 26 21:37:04 2017
@@ -108,6 +108,7 @@
 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

Modified: trunk/include/pub_tool_basics.h
==============================================================================
--- trunk/include/pub_tool_basics.h (original)
+++ trunk/include/pub_tool_basics.h Sun Feb 26 21:37:04 2017
@@ -468,6 +468,17 @@
       } 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))

Modified: trunk/include/vki/vki-linux.h
==============================================================================
--- trunk/include/vki/vki-linux.h (original)
+++ trunk/include/vki/vki-linux.h Sun Feb 26 21:37:04 2017
@@ -674,7 +674,8 @@
 {
  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;
 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers
Loading...