Skip to content

Commit 10f6b23

Browse files
committed
configure, meson: move pthread_setname_np checks to Meson
This makes the pthreads check dead in configure, so remove it as well. Reviewed-by: Marc-André Lureau <[email protected]> Message-Id: <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 96a63ae commit 10f6b23

File tree

3 files changed

+25
-81
lines changed

3 files changed

+25
-81
lines changed

configure

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,71 +3148,6 @@ if test "$modules" = yes; then
31483148
fi
31493149
fi
31503150

3151-
##########################################
3152-
# pthread probe
3153-
PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3154-
3155-
pthread=no
3156-
cat > $TMPC << EOF
3157-
#include <pthread.h>
3158-
static void *f(void *p) { return NULL; }
3159-
int main(void) {
3160-
pthread_t thread;
3161-
pthread_create(&thread, 0, f, 0);
3162-
return 0;
3163-
}
3164-
EOF
3165-
if compile_prog "" "" ; then
3166-
pthread=yes
3167-
else
3168-
for pthread_lib in $PTHREADLIBS_LIST; do
3169-
if compile_prog "" "$pthread_lib" ; then
3170-
pthread=yes
3171-
break
3172-
fi
3173-
done
3174-
fi
3175-
3176-
if test "$mingw32" != yes && test "$pthread" = no; then
3177-
error_exit "pthread check failed" \
3178-
"Make sure to have the pthread libs and headers installed."
3179-
fi
3180-
3181-
# check for pthread_setname_np with thread id
3182-
pthread_setname_np_w_tid=no
3183-
cat > $TMPC << EOF
3184-
#include <pthread.h>
3185-
3186-
static void *f(void *p) { return NULL; }
3187-
int main(void)
3188-
{
3189-
pthread_t thread;
3190-
pthread_create(&thread, 0, f, 0);
3191-
pthread_setname_np(thread, "QEMU");
3192-
return 0;
3193-
}
3194-
EOF
3195-
if compile_prog "" "$pthread_lib" ; then
3196-
pthread_setname_np_w_tid=yes
3197-
fi
3198-
3199-
# check for pthread_setname_np without thread id
3200-
pthread_setname_np_wo_tid=no
3201-
cat > $TMPC << EOF
3202-
#include <pthread.h>
3203-
3204-
static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
3205-
int main(void)
3206-
{
3207-
pthread_t thread;
3208-
pthread_create(&thread, 0, f, 0);
3209-
return 0;
3210-
}
3211-
EOF
3212-
if compile_prog "" "$pthread_lib" ; then
3213-
pthread_setname_np_wo_tid=yes
3214-
fi
3215-
32163151
##########################################
32173152
# libssh probe
32183153
if test "$libssh" != "no" ; then
@@ -4498,19 +4433,6 @@ if test "$debug_mutex" = "yes" ; then
44984433
echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
44994434
fi
45004435

4501-
# Hold two types of flag:
4502-
# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
4503-
# a thread we have a handle to
4504-
# CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
4505-
# platform
4506-
if test "$pthread_setname_np_w_tid" = "yes" ; then
4507-
echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
4508-
echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
4509-
elif test "$pthread_setname_np_wo_tid" = "yes" ; then
4510-
echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
4511-
echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
4512-
fi
4513-
45144436
if test "$bochs" = "yes" ; then
45154437
echo "CONFIG_BOCHS=y" >> $config_host_mak
45164438
fi

meson.build

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,29 @@ config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + '''
15841584
#include <sys/mman.h>
15851585
#include <stddef.h>
15861586
int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }'''))
1587+
1588+
config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links('''
1589+
#include <pthread.h>
1590+
1591+
static void *f(void *p) { return NULL; }
1592+
int main(void)
1593+
{
1594+
pthread_t thread;
1595+
pthread_create(&thread, 0, f, 0);
1596+
pthread_setname_np(thread, "QEMU");
1597+
return 0;
1598+
}''', dependencies: threads))
1599+
config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links('''
1600+
#include <pthread.h>
1601+
1602+
static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
1603+
int main(void)
1604+
{
1605+
pthread_t thread;
1606+
pthread_create(&thread, 0, f, 0);
1607+
return 0;
1608+
}''', dependencies: threads))
1609+
15871610
config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + '''
15881611
#include <sys/signalfd.h>
15891612
#include <stddef.h>

util/qemu-thread-posix.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ void qemu_thread_naming(bool enable)
2323
{
2424
name_threads = enable;
2525

26-
#ifndef CONFIG_THREAD_SETNAME_BYTHREAD
26+
#if !defined CONFIG_PTHREAD_SETNAME_NP_W_TID && \
27+
!defined CONFIG_PTHREAD_SETNAME_NP_WO_TID
2728
/* This is a debugging option, not fatal */
2829
if (enable) {
2930
fprintf(stderr, "qemu: thread naming not supported on this host\n");
@@ -522,7 +523,6 @@ static void *qemu_thread_start(void *args)
522523
void *arg = qemu_thread_args->arg;
523524
void *r;
524525

525-
#ifdef CONFIG_THREAD_SETNAME_BYTHREAD
526526
/* Attempt to set the threads name; note that this is for debug, so
527527
* we're not going to fail if we can't set it.
528528
*/
@@ -533,7 +533,6 @@ static void *qemu_thread_start(void *args)
533533
pthread_setname_np(qemu_thread_args->name);
534534
# endif
535535
}
536-
#endif
537536
QEMU_TSAN_ANNOTATE_THREAD_NAME(qemu_thread_args->name);
538537
g_free(qemu_thread_args->name);
539538
g_free(qemu_thread_args);

0 commit comments

Comments
 (0)