mirror of https://gerrit.osmocom.org/libosmocore
vty: Support platforms that don't support pthread_getname_np()
pthread_getname_np() is a non-portable extension of pthreads. While it exists in glibc, for example musl didn't have it until rather recently (April 2021) and there still hasn't yet been a musl release with this change, resulting even current OpenWRT not yet supporting pthread_getname_np. So let's check if pthread_getname_np is supported, and only use it in that case. Change-Id: Ibd01485af24e2fe574006f8d049bf37226dda966
This commit is contained in:
parent
c80a004f0b
commit
c17546faff
18
configure.ac
18
configure.ac
|
@ -78,6 +78,24 @@ AC_SUBST(BACKTRACE_LIB)
|
||||||
# check for pthread (PTHREAD_CFLAGS, PTHREAD_LIBS)
|
# check for pthread (PTHREAD_CFLAGS, PTHREAD_LIBS)
|
||||||
AX_PTHREAD
|
AX_PTHREAD
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for pthread_getname_np(pthread_t, char*, size_t))
|
||||||
|
saved_CFLAGS="$CFLAGS"
|
||||||
|
saved_LIBS="$LIBS"
|
||||||
|
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
|
LIBS="$LIBS $PTHREAD_LIBS"
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM(
|
||||||
|
[#define _GNU_SOURCE
|
||||||
|
#include <pthread.h>],
|
||||||
|
[pthread_getname_np(pthread_self(),"example",0)])],
|
||||||
|
[AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_PTHREAD_GETNAME_NP,1,
|
||||||
|
[Have function pthread_setname_np(const char*)])],
|
||||||
|
[AC_MSG_RESULT(no)])
|
||||||
|
CFLAGS="$saved_CFLAGS"
|
||||||
|
LIBS="$saved_LIBS"
|
||||||
|
|
||||||
|
|
||||||
# check for old glibc < 2.17 to get clock_gettime
|
# check for old glibc < 2.17 to get clock_gettime
|
||||||
AC_SEARCH_LIBS([clock_gettime], [rt posix4],
|
AC_SEARCH_LIBS([clock_gettime], [rt posix4],
|
||||||
[AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if clock_gettime is available])
|
[AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if clock_gettime is available])
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include "../../config.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -637,8 +639,10 @@ int osmo_cpu_sched_vty_apply_localthread(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD_GETNAME_NP
|
||||||
if (pthread_getname_np(pthread_self(), name, sizeof(name)) == 0)
|
if (pthread_getname_np(pthread_self(), name, sizeof(name)) == 0)
|
||||||
has_name = true;
|
has_name = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get latest matching mask for the thread */
|
/* Get latest matching mask for the thread */
|
||||||
pthread_mutex_lock(&sched_vty_opts->cpu_affinity_li_mutex);
|
pthread_mutex_lock(&sched_vty_opts->cpu_affinity_li_mutex);
|
||||||
|
|
Loading…
Reference in New Issue