| @@ -1,30 +1,30 @@ | | | @@ -1,30 +1,30 @@ |
1 | $NetBSD: patch-tests_test__common.h,v 1.3 2018/05/12 14:04:00 maya Exp $ | | 1 | $NetBSD: patch-tests_test__common.h,v 1.4 2018/05/13 03:22:33 minskim Exp $ |
2 | | | 2 | |
3 | Use posix_memalign on SunOS with __EXTENSIONS__. | | 3 | Use posix_memalign on SunOS with __EXTENSIONS__. |
4 | Use a standard C11 test. | | 4 | Use a standard C11 test. |
5 | Prefer posix_memalign over C11 aligned_alloc because we are invoking undefined | | 5 | Prefer posix_memalign over C11 aligned_alloc because we are invoking undefined |
6 | behaviour (C11 7.22.3.1). | | 6 | behaviour (C11 7.22.3.1). |
7 | | | 7 | |
8 | --- tests/test_common.h.orig 2017-07-19 08:08:12.000000000 +0000 | | 8 | --- tests/test_common.h.orig 2017-07-19 08:08:12.000000000 +0000 |
9 | +++ tests/test_common.h | | 9 | +++ tests/test_common.h |
10 | @@ -61,16 +61,15 @@ static void* blosc_test_malloc(const siz | | 10 | @@ -61,16 +61,15 @@ static void* blosc_test_malloc(const siz |
11 | const int32_t clean_value = 0x99; | | 11 | const int32_t clean_value = 0x99; |
12 | void *block = NULL; | | 12 | void *block = NULL; |
13 | int32_t res = 0; | | 13 | int32_t res = 0; |
14 | - | | 14 | - |
15 | -#if defined(_ISOC11_SOURCE) || (defined(__FreeBSD__) && __STDC_VERSION__ >= 201112L) | | 15 | -#if defined(_ISOC11_SOURCE) || (defined(__FreeBSD__) && __STDC_VERSION__ >= 201112L) |
16 | +#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || defined(__EXTENSIONS__) | | 16 | +#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || defined(__EXTENSIONS__) |
17 | + /* Platform does have an implementation of posix_memalign */ | | 17 | + /* Platform does have an implementation of posix_memalign */ |
18 | + res = posix_memalign(&block, alignment, size); | | 18 | + res = posix_memalign(&block, alignment, size); |
19 | +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L | | 19 | +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__APPLE__) |
20 | /* C11 aligned allocation. 'size' must be a multiple of the alignment. */ | | 20 | /* C11 aligned allocation. 'size' must be a multiple of the alignment. */ |
21 | block = aligned_alloc(alignment, size); | | 21 | block = aligned_alloc(alignment, size); |
22 | #elif defined(_WIN32) | | 22 | #elif defined(_WIN32) |
23 | /* A (void *) cast needed for avoiding a warning with MINGW :-/ */ | | 23 | /* A (void *) cast needed for avoiding a warning with MINGW :-/ */ |
24 | block = (void *)_aligned_malloc(size, alignment); | | 24 | block = (void *)_aligned_malloc(size, alignment); |
25 | -#elif _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 | | 25 | -#elif _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 |
26 | - /* Platform does have an implementation of posix_memalign */ | | 26 | - /* Platform does have an implementation of posix_memalign */ |
27 | - res = posix_memalign(&block, alignment, size); | | 27 | - res = posix_memalign(&block, alignment, size); |
28 | #elif defined(__APPLE__) | | 28 | #elif defined(__APPLE__) |
29 | /* Mac OS X guarantees 16-byte alignment in small allocs */ | | 29 | /* Mac OS X guarantees 16-byte alignment in small allocs */ |
30 | block = malloc(size); | | 30 | block = malloc(size); |