]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add an assert to check that we're getting the expected alignment.
authorFlorian Krohm <florian@eich-krohm.de>
Tue, 20 Jan 2015 21:37:06 +0000 (21:37 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Tue, 20 Jan 2015 21:37:06 +0000 (21:37 +0000)
git-svn-id: svn://svn.valgrind.org/vex/trunk@3072

VEX/priv/main_util.c

index 07101ef4d057999e6b5c91585d763a9eb60fa942..611884dee481acf27dce3d0895e9bd19617ed533 100644 (file)
    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);