mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-31 21:34:12 +02:00
Fix build when pthread_getname_np is not available
On Android _setname_ is always available but _getname_ is available only with API level >= 26. https://bugzilla.gnome.org/show_bug.cgi?id=795406
This commit is contained in:
18
meson.build
18
meson.build
@@ -1477,6 +1477,11 @@ if host_system == 'windows'
|
||||
glibconfig_conf.set('g_threads_impl_def', 'WIN32')
|
||||
glib_conf.set('THREADS_WIN32', 1)
|
||||
else
|
||||
pthread_prefix = '''
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#include <pthread.h>'''
|
||||
glibconfig_conf.set('g_threads_impl_def', 'POSIX')
|
||||
glib_conf.set('THREADS_POSIX', 1)
|
||||
if cc.has_header_symbol('pthread.h', 'pthread_attr_setstacksize')
|
||||
@@ -1488,11 +1493,11 @@ else
|
||||
if cc.has_header_symbol('pthread.h', 'pthread_cond_timedwait_relative_np')
|
||||
glib_conf.set('HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP', 1)
|
||||
endif
|
||||
if cc.has_header_symbol('pthread.h', 'pthread_getname_np', prefix : pthread_prefix)
|
||||
glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1)
|
||||
endif
|
||||
# Assume that pthread_setname_np is available in some form; same as configure
|
||||
if cc.links('''#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
if cc.links(pthread_prefix + '''
|
||||
int main() {
|
||||
pthread_setname_np("example");
|
||||
}''',
|
||||
@@ -1500,10 +1505,7 @@ else
|
||||
dependencies : thread_dep)
|
||||
# macOS and iOS
|
||||
glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1)
|
||||
elif cc.links('''#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
elif cc.links(pthread_prefix + '''
|
||||
int main() {
|
||||
pthread_setname_np(pthread_self(), "example");
|
||||
}''',
|
||||
|
Reference in New Issue
Block a user