From 7bcdecbfadcb7c82e41f5d140a77a0bd6a370a94 Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Tue, 20 Jan 2015 21:37:06 +0000 Subject: [PATCH] Add an assert to check that we're getting the expected alignment. git-svn-id: svn://svn.valgrind.org/vex/trunk@3072 --- VEX/priv/main_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/VEX/priv/main_util.c b/VEX/priv/main_util.c index 07101ef4d0..611884dee4 100644 --- a/VEX/priv/main_util.c +++ b/VEX/priv/main_util.c @@ -51,9 +51,14 @@ MByte/sec. Once the size increases enough to fall out of the cache into memory, the rate falls by about a factor of 3. */ + +/* Allocated memory as returned by LibVEX_Alloc will be aligned on this + boundary. */ +#define REQ_ALIGN 8 + #define N_TEMPORARY_BYTES 5000000 -static HChar temporary[N_TEMPORARY_BYTES] __attribute__((aligned(8))); +static HChar temporary[N_TEMPORARY_BYTES] __attribute__((aligned(REQ_ALIGN))); static HChar* temporary_first = &temporary[0]; static HChar* temporary_curr = &temporary[0]; static HChar* temporary_last = &temporary[N_TEMPORARY_BYTES-1]; @@ -62,7 +67,7 @@ static ULong temporary_bytes_allocd_TOT = 0; #define N_PERMANENT_BYTES 10000 -static HChar permanent[N_PERMANENT_BYTES] __attribute__((aligned(8))); +static HChar permanent[N_PERMANENT_BYTES] __attribute__((aligned(REQ_ALIGN))); static HChar* permanent_first = &permanent[0]; static HChar* permanent_curr = &permanent[0]; static HChar* permanent_last = &permanent[N_PERMANENT_BYTES-1]; @@ -223,6 +228,9 @@ void* LibVEX_Alloc ( SizeT nbytes ) } x; }; + /* Make sure the compiler does no surprise us */ + vassert(offsetof(struct align,x) == REQ_ALIGN); + #if 0 /* Nasty debugging hack, do not use. */ return malloc(nbytes); -- 2.47.2