Discussion:
Valgrind: r16256 - in /trunk: NEWS include/pub_tool_basics.h include/vki/vki-linux.h
(too old to reply)
s***@valgrind.org
2017-02-26 21:37:05 UTC
Permalink
Raw Message
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 <***@imgtec.com>

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;

Loading...