meson: Update the pthread feature checks

For GNU extensions, we need to define _GNU_SOURCE; but, more
importantly, we need to tell Meson to use the threadlib dependency when
compiling and linking the feature check.

This currently exposes a bug in Meson; see:

https://github.com/mesonbuild/meson/issues/2165

But once that's fixed, the check will work as intended.

https://bugzilla.gnome.org/show_bug.cgi?id=785955
This commit is contained in:
Emmanuele Bassi 2017-08-09 21:31:59 +01:00
parent 1a755a63e1
commit 50eeb24415

View File

@ -1273,14 +1273,21 @@ else
glib_conf.set('HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP', 1) glib_conf.set('HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP', 1)
endif endif
if cc.links('''#include <pthread.h> if cc.links('''#include <pthread.h>
int main() { int main() {
pthread_setname_np("example"); pthread_setname_np("example");
}''', name : 'pthread_setname_np(const char*)') }''',
name : 'pthread_setname_np(const char*)',
dependencies : thread_dep)
glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1) glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1)
elif cc.links('''#include <pthread.h> elif cc.links('''#ifndef _GNU_SOURCE
int main() { # define _GNU_SOURCE
pthread_setname_np(pthread_self(), "example"); #endif
}''', name : 'pthread_setname_np(pthread_t, const char*)') #include <pthread.h>
int main() {
pthread_setname_np(pthread_self(), "example");
}''',
name : 'pthread_setname_np(pthread_t, const char*)',
dependencies : thread_dep)
glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID', 1) glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID', 1)
endif endif
endif endif