meson: Fix checks for posix_memalign and stpcpy

The 'no-builtin' checks were just plain wrong. For accurate detection of
functions, use has_function with a header in the prefix. This fixes
posix_memalign detection on Android and on MinGW32, MSYS-MinGW-w64, and
old versions of MSYS2-MinGW-w64.

Using the header in the `prefix:` is generally a good idea because of
how macOS does targetting of specific macOS releases at compile time.

This also allows cross-files to override the result by setting
`has_function_stpcpy = false`, etc in [extra properties]

https://bugzilla.gnome.org/show_bug.cgi?id=795876
This commit is contained in:
Nirbheek Chauhan 2018-05-07 15:19:36 +05:30
parent e2c154d9d8
commit 7551267f19

View File

@ -468,33 +468,13 @@ foreach f : functions
endif
endforeach
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
no_builtin_args = cc.get_supported_arguments(['-fno-builtin'])
else
no_builtin_args = []
endif
# Check that stpcpy() is not a builtin
if cc.links('''#include <string.h>
int main (int argc, char ** argv) {
char p[10];
return stpcpy (p, argv[0]) != NULL;
}
''',
args : no_builtin_args,
name : 'stpcpy() is not a builtin')
# Check that stpcpy() is usable; must use header
if cc.has_function('stpcpy', prefix : '#include <string.h>')
glib_conf.set('HAVE_STPCPY', 1)
endif
# Check that posix_memalign() is not a builtin
if cc.links('''#include <stdlib.h>
int main (int argc, char ** argv) {
void *p;
return posix_memalign (&p, 16, argc);
}
''',
args : no_builtin_args,
name : 'posix_memalign() is not a builtin')
# Check that posix_memalign() is usable; must use header
if cc.has_function('posix_memalign', prefix : '#include <stdlib.h>')
glib_conf.set('HAVE_POSIX_MEMALIGN', 1)
endif