diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-05-28 08:30:47 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2022-05-28 08:30:47 +0200 |
commit | 42fd2cd932384288914174f4af7974a060972bff (patch) | |
tree | c75407921fbb7f736115c8f6e2ce4b32ddaeaa2f /libgomp/alloc.c | |
parent | 931249276acb4bdab778fe2bf4e81a1a31a78e6c (diff) | |
download | gcc-42fd2cd932384288914174f4af7974a060972bff.zip gcc-42fd2cd932384288914174f4af7974a060972bff.tar.gz gcc-42fd2cd932384288914174f4af7974a060972bff.tar.bz2 |
libgomp: Don't define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC for _aligned_malloc [PR105745]
since apparently _aligned_malloc requires freeing with _aligned_free and:
/* Defined if gomp_aligned_alloc doesn't use fallback version
and free can be used instead of gomp_aligned_free. */
#define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC 1
so the second condition isn't satisfied. For uses inside of the OpenMP
allocators we can still use _aligned_malloc but we need to call _aligned_free
in gomp_aligned_free.
2022-05-28 Jakub Jelinek <jakub@redhat.com>
PR libgomp/105745
* libgomp.h (GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC): Don't define for
defined(HAVE__ALIGNED_MALLOC) case.
* alloc.c (gomp_aligned_alloc): Move defined(HAVE__ALIGNED_MALLOC)
handling as last option before fallback instead of first.
(gomp_aligned_free): For defined(HAVE__ALIGNED_MALLOC) call
_aligned_free.
Diffstat (limited to 'libgomp/alloc.c')
-rw-r--r-- | libgomp/alloc.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libgomp/alloc.c b/libgomp/alloc.c index a2a25be..c1bd72d 100644 --- a/libgomp/alloc.c +++ b/libgomp/alloc.c @@ -65,9 +65,7 @@ gomp_aligned_alloc (size_t al, size_t size) void *ret; if (al < sizeof (void *)) al = sizeof (void *); -#ifdef HAVE__ALIGNED_MALLOC - ret = _aligned_malloc (size, al); -#elif defined(HAVE_MEMALIGN) +#ifdef HAVE_MEMALIGN { extern void *memalign (size_t, size_t); ret = memalign (al, size); @@ -83,6 +81,8 @@ gomp_aligned_alloc (size_t al, size_t size) else ret = NULL; } +#elif defined(HAVE__ALIGNED_MALLOC) + ret = _aligned_malloc (size, al); #else ret = NULL; if ((al & (al - 1)) == 0 && size) @@ -106,6 +106,8 @@ gomp_aligned_free (void *ptr) { #ifdef GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC free (ptr); +#elif defined(HAVE__ALIGNED_MALLOC) + _aligned_free (ptr); #else if (ptr) free (((void **) ptr)[-1]); |