mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-09 02:34:05 +02:00
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:
28
meson.build
28
meson.build
@@ -468,33 +468,13 @@ foreach f : functions
|
|||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
|
# Check that stpcpy() is usable; must use header
|
||||||
no_builtin_args = cc.get_supported_arguments(['-fno-builtin'])
|
if cc.has_function('stpcpy', prefix : '#include <string.h>')
|
||||||
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')
|
|
||||||
glib_conf.set('HAVE_STPCPY', 1)
|
glib_conf.set('HAVE_STPCPY', 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Check that posix_memalign() is not a builtin
|
# Check that posix_memalign() is usable; must use header
|
||||||
if cc.links('''#include <stdlib.h>
|
if cc.has_function('posix_memalign', prefix : '#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')
|
|
||||||
glib_conf.set('HAVE_POSIX_MEMALIGN', 1)
|
glib_conf.set('HAVE_POSIX_MEMALIGN', 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user