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
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
} 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))
{
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;