mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +01:00
Merge branch 'wip/lantw/gthread-set-thread-name-on-bsd' into 'master'
gthread: Set thread name on *BSD Closes #1761 See merge request GNOME/glib!1072
This commit is contained in:
commit
b3b6830d9a
@ -57,6 +57,9 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD_SET_NAME_NP
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_SCHED_H
|
#ifdef HAVE_SCHED_H
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#endif
|
#endif
|
||||||
@ -1245,10 +1248,14 @@ g_system_thread_exit (void)
|
|||||||
void
|
void
|
||||||
g_system_thread_set_name (const gchar *name)
|
g_system_thread_set_name (const gchar *name)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
|
#if defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
|
||||||
pthread_setname_np (pthread_self(), name); /* on Linux and Solaris */
|
|
||||||
#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
|
|
||||||
pthread_setname_np (name); /* on OS X and iOS */
|
pthread_setname_np (name); /* on OS X and iOS */
|
||||||
|
#elif defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
|
||||||
|
pthread_setname_np (pthread_self (), name); /* on Linux and Solaris */
|
||||||
|
#elif defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG)
|
||||||
|
pthread_setname_np (pthread_self (), "%s", (gchar *) name); /* on NetBSD */
|
||||||
|
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
||||||
|
pthread_set_name_np (pthread_self (), name); /* on FreeBSD, DragonFlyBSD, OpenBSD */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
meson.build
19
meson.build
@ -1691,6 +1691,25 @@ else
|
|||||||
dependencies : thread_dep)
|
dependencies : thread_dep)
|
||||||
# Linux, Solaris, etc.
|
# Linux, Solaris, etc.
|
||||||
glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID', 1)
|
glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID', 1)
|
||||||
|
elif cc.links(pthread_prefix + '''
|
||||||
|
int main() {
|
||||||
|
pthread_setname_np(pthread_self(), "%s", "example");
|
||||||
|
return 0;
|
||||||
|
}''',
|
||||||
|
name : 'pthread_setname_np(pthread_t, const char*, void*)',
|
||||||
|
dependencies : thread_dep)
|
||||||
|
# NetBSD
|
||||||
|
glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG', 1)
|
||||||
|
elif cc.links(pthread_prefix + '''
|
||||||
|
#include <pthread_np.h>
|
||||||
|
int main() {
|
||||||
|
pthread_set_name_np(pthread_self(), "example");
|
||||||
|
return 0;
|
||||||
|
}''',
|
||||||
|
name : 'pthread_set_name_np(pthread_t, const char*)',
|
||||||
|
dependencies : thread_dep)
|
||||||
|
# FreeBSD, DragonFlyBSD, OpenBSD, etc.
|
||||||
|
glib_conf.set('HAVE_PTHREAD_SET_NAME_NP', 1)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user