meson: check pthread_setname_np like autotools

FreeBSD < 12.2 and OpenBSD only have pthread_set_name_np.
As libpthread isn't in scope use -Werror to trip the check.

Header <pthread.h> has symbol "PTHREAD_MUTEX_RECURSIVE" : YES
Checking if "pthread_setname_np(tid, name)" compiles: YES

os/inputthread.c:326:5: error: implicit declaration of function 'pthread_setname_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pthread_setname_np (pthread_self(), "InputThread");
    ^
os/inputthread.c:447:5: error: implicit declaration of function 'pthread_setname_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pthread_setname_np (pthread_self(), "MainThread");
    ^

Fixes: c20e7b5e22 ("meson: Automatically detect HAVE_PTHREAD_SETNAME_NP")
This commit is contained in:
Jan Beich 2021-04-09 15:22:22 +00:00
parent 38e875904b
commit 9f8421af63
1 changed files with 2 additions and 0 deletions

View File

@ -67,6 +67,7 @@ if cc.compiles('''
#include <pthread.h>
void foo(int bar) { pthread_setname_np(pthread_self(), "example"); }
''',
args: '-Werror-implicit-function-declaration',
name: 'pthread_setname_np(tid, name)')
conf_data.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID', 1)
elif cc.compiles('''
@ -74,6 +75,7 @@ elif cc.compiles('''
#include <pthread.h>
void foo(int bar) { pthread_setname_np("example"); }
''',
args: '-Werror-implicit-function-declaration',
name: 'pthread_setname_np(name)')
conf_data.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1)
endif