diff options
Diffstat (limited to 'tools/gf_time.c')
-rw-r--r-- | tools/gf_time.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/tools/gf_time.c b/tools/gf_time.c index d17a7c2..7402ab5 100644 --- a/tools/gf_time.c +++ b/tools/gf_time.c @@ -8,6 +8,14 @@ * Performs timing for gf arithmetic */ +#include "config.h" + +#ifdef HAVE_POSIX_MEMALIGN +#ifndef _XOPEN_SOURCE +#define _XOPEN_SOURCE 600 +#endif +#endif + #include <stdio.h> #include <getopt.h> #include <stdint.h> @@ -95,6 +103,9 @@ int main(int argc, char **argv) time_t t0; uint8_t *ra, *rb; gf_general_t a; +#ifndef HAVE_POSIX_MEMALIGN + uint8_t *malloc_ra, *malloc_rb; +#endif if (argc < 6) usage(NULL); @@ -155,8 +166,17 @@ int main(int argc, char **argv) printf("Seed: %ld\n", t0); - ra = (uint8_t *) malloc(size); - rb = (uint8_t *) malloc(size); +#ifdef HAVE_POSIX_MEMALIGN + if (posix_memalign((void **) &ra, 16, size)) + ra = NULL; + if (posix_memalign((void **) &rb, 16, size)) + rb = NULL; +#else + malloc_ra = (uint8_t *) malloc(size + 15); + malloc_rb = (uint8_t *) malloc(size + 15); + ra = (uint8_t *) (((uintptr_t) malloc_ra + 15) & ~((uintptr_t) 0xf)); + rb = (uint8_t *) (((uintptr_t) malloc_rb + 15) & ~((uintptr_t) 0xf)); +#endif if (ra == NULL || rb == NULL) { perror("malloc"); exit(1); } |