test: allocate aligned memory on windows
authorDavid Schleef <ds@schleef.org>
Sun, 1 Apr 2012 22:31:05 +0000 (15:31 -0700)
committerDavid Schleef <ds@schleef.org>
Sun, 1 Apr 2012 23:01:47 +0000 (16:01 -0700)
orc-test/orcarray.c

index 729593b..992e888 100644 (file)
@@ -67,13 +67,15 @@ orc_array_new (int n, int m, int element_size, int misalignment,
       MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
   idx++;
 #else
-#ifdef HAVE_POSIX_MEMALIGN
+#ifdef HAVE_POSIX_MEMALIGNx
   ret = posix_memalign (&data, ALIGNMENT, ar->alloc_len);
+  ar->alloc_data = data;
 #else
-  data = malloc (ar->alloc_len);
+  data = malloc (ar->alloc_len + ALIGNMENT);
+  ar->alloc_data = data;
+  data = (void *)((((unsigned long)data) + (ALIGNMENT-1))&(~(ALIGNMENT-1)));
 #endif
 #endif
-  ar->alloc_data = data;
 
   if (alignment == 0) alignment = element_size;
   offset = (alignment * misalignment) & (ALIGNMENT - 1);