Check stpcpy() and posix_memalign() to *not* to be built-in

GCC has built-ins for these functions, which might give a compile-only
test an impression that the functions are actually present in the C runtime.
Use a linked test to be sure.

Specifically, both functions are missing on Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=794555
This commit is contained in:
Руслан Ижбулатов 2018-03-21 09:52:10 +00:00
parent ac42183c33
commit dcc452b5f9

View File

@ -298,7 +298,6 @@ endif
functions = [ functions = [
'alloca', 'alloca',
'mmap', 'mmap',
'posix_memalign',
'memalign', 'memalign',
'valloc', 'valloc',
'fsync', 'fsync',
@ -310,7 +309,6 @@ functions = [
'lstat', 'lstat',
'strsignal', 'strsignal',
'vsnprintf', 'vsnprintf',
'stpcpy',
'poll', 'poll',
'vasprintf', 'vasprintf',
'setenv', 'setenv',
@ -401,6 +399,24 @@ foreach f : functions
endif endif
endforeach endforeach
# 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;
}''', name : 'stpcpy() is not a builtin')
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);
}''', name : 'posix_memalign() is not a builtin')
glib_conf.set('HAVE_POSIX_MEMALIGN', 1)
endif
# Check whether strerror_r returns char * # Check whether strerror_r returns char *
if have_func_strerror_r if have_func_strerror_r
if cc.compiles('''#define _GNU_SOURCE if cc.compiles('''#define _GNU_SOURCE