Skip to content

Commit

Permalink
Use only one aligned alloc func, work around msys2
Browse files Browse the repository at this point in the history
As recommended by @nirbheek, only search for a single aligned memory
allocation function: ebassi#86 (comment)

The cascade of tests means we can exclude the ones for which MSYS2's
native mingw-w64 builtins and headers conspire to provide meson with a
dud test. Although it is still not clear that meson is doing the right
thing in this case (mesonbuild/meson#1083), we can work around the
failed build in graphene by excluding certain POSIXy cases on Windows.

Closes ebassi#76, leaving ebassi#88 unsolved.
  • Loading branch information
achadwick committed Dec 5, 2016
1 parent 77a58ac commit c2e78bc
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions meson.build
Expand Up @@ -129,10 +129,20 @@ conf.set('HAVE_STDBOOL_H', cc.has_header('stdbool.h'))
conf.set('HAVE_MEMORY_H', cc.has_header('memory.h'))

# Functions
conf.set('HAVE_ALIGNED_ALLOC', cc.has_function('aligned_alloc', prefix: '#include <stdlib.h>'))
conf.set('HAVE__ALIGNED_MALLOC', cc.has_function('_aligned_malloc', prefix: '#include <malloc.h>'))
conf.set('HAVE_MEMALIGN', cc.has_function('memalign', prefix: '#include <stdlib.h>\n#include <malloc.h>'))
conf.set('HAVE_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include <stdlib.h>'))
if cc.has_function('memalign', prefix: '#include <stdlib.h>\n#include <malloc.h>')
conf.set('HAVE_MEMALIGN', 1)
elif cc.has_function('_aligned_malloc', prefix: '#include <malloc.h>')
conf.set('HAVE__ALIGNED_MALLOC', 1)
elif not (host_system == 'windows')
# These tests have proven unreliable on MSYS2 because meson falls
# back to testing compiler builtins instead of what we asked for.
if cc.has_function('aligned_alloc', prefix: '#include <stdlib.h>')
conf.set('HAVE_ALIGNED_ALLOC', 1)
elif cc.has_function('posix_memalign', prefix: '#include <stdlib.h>')
conf.set('HAVE_POSIX_MEMALIGN', 1)
endif
endif

conf.set('HAVE_SINCOSF', cc.has_function('sincosf', prefix: '#define _GNU_SOURCE\n#include <math.h>'))

# Debugging
Expand Down

0 comments on commit c2e78bc

Please sign in to comment.