From fb5e8c5d30a06b149b22d7b33f398b826a47e7f0 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sun, 1 Apr 2012 15:31:05 -0700 Subject: [PATCH] test: allocate aligned memory on windows --- orc-test/orcarray.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/orc-test/orcarray.c b/orc-test/orcarray.c index 729593b..992e888 100644 --- a/orc-test/orcarray.c +++ b/orc-test/orcarray.c @@ -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); -- 2.7.4