alignment fixing for USE_SIMD - all memory allocations are rounded

up to 16-byte boundaries.  This fixes crashes where the sub-buffers
for complex FFTs end up unaligned violating compiler expectations
This commit is contained in:
Ben Supnik
2020-04-18 20:43:26 -04:00
parent 33d9ad3bad
commit 58cf0c0fc1
5 changed files with 41 additions and 22 deletions

View File

@ -37,11 +37,15 @@ extern "C" {
# define kiss_fft_scalar __m128
# ifndef KISS_FFT_MALLOC
# define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16)
# define KISS_FFT_ALIGN_CHECK(ptr) assert((((uintptr_t) ptr) & 0xF) == 0);
# define KISS_FFT_ALIGN_SIZE_UP(size) ((size + 15UL) & ~0xFUL)
# endif
# ifndef KISS_FFT_FREE
# define KISS_FFT_FREE _mm_free
# endif
#else
# define KISS_FFT_ALIGN_CHECK(ptr)
# define KISS_FFT_ALIGN_SIZE_UP(size) (size)
# ifndef KISS_FFT_MALLOC
# define KISS_FFT_MALLOC malloc
# endif