summaryrefslogtreecommitdiff
path: root/orc-test
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2013-02-19 20:02:03 -0800
committerDavid Schleef <ds@schleef.org>2013-02-19 20:02:03 -0800
commite9430261015d8f059ff1359f89c137895e50c81e (patch)
tree9f601474dfd037bbc9d06ac3de4f81c6157abb0a /orc-test
parent4da318b87936aafc4ec69c051ad2605e384a3265 (diff)
downloadorc-e9430261015d8f059ff1359f89c137895e50c81e.tar.gz
test: Fix recent commit
Separate allocated data and aligned data.
Diffstat (limited to 'orc-test')
-rw-r--r--orc-test/orcarray.c17
-rw-r--r--orc-test/orcarray.h1
2 files changed, 11 insertions, 7 deletions
diff --git a/orc-test/orcarray.c b/orc-test/orcarray.c
index c5ca362..dce48b3 100644
--- a/orc-test/orcarray.c
+++ b/orc-test/orcarray.c
@@ -66,21 +66,24 @@ orc_array_new (int n, int m, int element_size, int misalignment,
data = mmap ((void *)(idx<<32), ar->alloc_len, PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
idx++;
+ ar->alloc_data = data;
+ ar->aligned_data = data;
#else
#ifdef HAVE_POSIX_MEMALIGNx
ret = posix_memalign (&data, ALIGNMENT, ar->alloc_len);
ar->alloc_data = data;
+ ar->aligned_data = data;
#else
data = malloc (ar->alloc_len + ALIGNMENT);
ar->alloc_data = data;
- data = (void *)((((unsigned long)data) + (ALIGNMENT-1))&(~(ALIGNMENT-1)));
+ ar->aligned_data = (void *)((((unsigned long)data) + (ALIGNMENT-1))&(~(ALIGNMENT-1)));
#endif
#endif
if (alignment == 0) alignment = element_size;
offset = (alignment * misalignment) & (ALIGNMENT - 1);
- ar->data = ORC_PTR_OFFSET (data, ar->stride * EXTEND_ROWS + offset);
+ ar->data = ORC_PTR_OFFSET (ar->aligned_data, ar->stride * EXTEND_ROWS + offset);
return ar;
}
@@ -99,13 +102,13 @@ orc_array_free (OrcArray *array)
void
orc_array_set_pattern (OrcArray *array, int value)
{
- memset (array->alloc_data, value, array->alloc_len);
+ memset (array->aligned_data, value, array->alloc_len);
}
void
orc_array_set_random (OrcArray *array, OrcRandomContext *context)
{
- orc_random_bits (context, array->alloc_data, array->alloc_len);
+ orc_random_bits (context, array->aligned_data, array->alloc_len);
}
#define CREATE_FLOAT(sign,exp,mant) (((sign)<<31)|((exp)<<23)|((mant)<<0))
@@ -153,7 +156,7 @@ orc_array_set_pattern_2 (OrcArray *array, OrcRandomContext *context,
switch (type) {
case ORC_PATTERN_RANDOM:
- orc_random_bits (context, array->alloc_data, array->alloc_len);
+ orc_random_bits (context, array->aligned_data, array->alloc_len);
break;
case ORC_PATTERN_FLOAT_SMALL:
{
@@ -254,7 +257,7 @@ orc_array_compare (OrcArray *array1, OrcArray *array2, int flags)
return TRUE;
}
} else {
- if (memcmp (array1->alloc_data, array2->alloc_data,
+ if (memcmp (array1->aligned_data, array2->aligned_data,
array1->alloc_len) == 0) {
return TRUE;
}
@@ -270,7 +273,7 @@ orc_array_check_out_of_bounds (OrcArray *array)
int j;
unsigned char *data;
- data = array->alloc_data;
+ data = array->aligned_data;
for(i=0;i<array->stride * EXTEND_ROWS;i++){
if (data[i] != ORC_OOB_VALUE) {
printf("OOB check failed at start-%d\n", array->stride * EXTEND_ROWS - i);
diff --git a/orc-test/orcarray.h b/orc-test/orcarray.h
index 53c7770..3466f6c 100644
--- a/orc-test/orcarray.h
+++ b/orc-test/orcarray.h
@@ -18,6 +18,7 @@ struct _OrcArray {
void *alloc_data;
int alloc_len;
+ void *aligned_data;
};
enum {