From 11511605c963bfd64f04d16f37f0d76a2c05fcd0 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sun, 2 Oct 2011 19:45:32 -0700 Subject: [PATCH] test: Add (disabled) ability to test 64-bit pointers --- orc-test/orcarray.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/orc-test/orcarray.c b/orc-test/orcarray.c index aeab06e..6e9c70f 100644 --- a/orc-test/orcarray.c +++ b/orc-test/orcarray.c @@ -1,4 +1,8 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -11,6 +15,15 @@ #include #include +#ifdef HAVE_MMAP +#include +#endif + +#ifdef HAVE_MMAP +/* This can be used to test non-zero high-32-bits of pointers. */ +//#define USE_MMAP +#endif + #define EXTEND_ROWS 16 #define EXTEND_STRIDE 256 @@ -27,10 +40,15 @@ orc_array_new (int n, int m, int element_size, int misalignment, { OrcArray *ar; void *data; +#ifndef USE_MMAP #ifdef HAVE_POSIX_MEMALIGN int ret; #endif +#endif int offset; +#ifdef USE_MMAP + static unsigned long idx = 1; +#endif ar = malloc (sizeof(OrcArray)); memset (ar, 0, sizeof(OrcArray)); @@ -42,12 +60,19 @@ orc_array_new (int n, int m, int element_size, int misalignment, ar->stride = (n*element_size + EXTEND_STRIDE); ar->stride = (ar->stride + (ALIGNMENT-1)) & (~(ALIGNMENT-1)); ar->alloc_len = ar->stride * (m+2*EXTEND_ROWS) + (ALIGNMENT * element_size); + ar->alloc_len = (ar->alloc_len + 4095) & (~4095); +#ifdef USE_MMAP + data = mmap ((void *)(idx<<32), ar->alloc_len, PROT_READ|PROT_WRITE, + MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + idx++; +#else #ifdef HAVE_POSIX_MEMALIGN ret = posix_memalign (&data, ALIGNMENT, ar->alloc_len); #else data = malloc (ar->alloc_len); #endif +#endif ar->alloc_data = data; if (alignment == 0) alignment = element_size; @@ -55,14 +80,18 @@ orc_array_new (int n, int m, int element_size, int misalignment, ar->data = ORC_PTR_OFFSET (ar->alloc_data, ar->stride * EXTEND_ROWS + offset); - + return ar; } void orc_array_free (OrcArray *array) { +#ifdef USE_MMAP + munmap (array->alloc_data, array->alloc_len); +#else free (array->alloc_data); +#endif free (array); } -- 2.7.4