[OE-core] [PATCH 2/2] glibc-2.0: Detect pthread_getname_np() before use

Khem Raj raj.khem at gmail.com
Mon Nov 7 07:25:27 UTC 2016


Fixes build with musl

Signed-off-by: Khem Raj <raj.khem at gmail.com>
---
 ...st-for-pthread_getname_np-before-using-it.patch | 70 ++++++++++++++++++++++
 meta/recipes-core/glib-2.0/glib-2.0_2.50.1.bb      |  1 +
 2 files changed, 71 insertions(+)
 create mode 100644 meta/recipes-core/glib-2.0/glib-2.0/0001-Test-for-pthread_getname_np-before-using-it.patch

diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0001-Test-for-pthread_getname_np-before-using-it.patch b/meta/recipes-core/glib-2.0/glib-2.0/0001-Test-for-pthread_getname_np-before-using-it.patch
new file mode 100644
index 0000000..c6e4966
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0001-Test-for-pthread_getname_np-before-using-it.patch
@@ -0,0 +1,70 @@
+From f627fe16099a2b08d8b4e9023ae6b4f352451967 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem at gmail.com>
+Date: Sun, 6 Nov 2016 08:59:08 -0800
+Subject: [PATCH] Test for pthread_getname_np before using it
+
+Its a GNU extention and not all libc implement it
+musl e.g. implements the setname API but not getname
+in any case, it seems to be safer to check for the
+function before using it.
+
+Signed-off-by: Khem Raj <raj.khem at gmail.com>
+---
+Upstream-Status: Submitted
+
+ config.h.in         |  3 +++
+ configure.ac        | 10 ++++++++++
+ glib/tests/thread.c |  2 +-
+ 3 files changed, 14 insertions(+), 1 deletion(-)
+
+diff --git a/config.h.in b/config.h.in
+index 2c35ff1..da7ac30 100644
+--- a/config.h.in
++++ b/config.h.in
+@@ -326,6 +326,9 @@
+ #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
+ 
+ /* Have function pthread_setname_np(const char*) */
++#undef HAVE_PTHREAD_GETNAME_NP
++
++/* Have function pthread_setname_np(const char*) */
+ #undef HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID
+ 
+ /* Have function pthread_setname_np(pthread_t, const char*) */
+diff --git a/configure.ac b/configure.ac
+index 4309671..209770a 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -2121,6 +2121,16 @@ AS_IF([ test x"$have_threads" = xposix], [
+              AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP,1,
+                 [Have function pthread_cond_timedwait_relative_np])],
+             [AC_MSG_RESULT(no)])
++        dnl gets thread names
++        AC_MSG_CHECKING(for pthread_getname_np(pthread_t, char*, size_t))
++        AC_LINK_IFELSE(
++            [AC_LANG_PROGRAM(
++                [#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)])
+         dnl Sets thread names on OS X 10.6, iOS 3.2 (and higher)
+         AC_MSG_CHECKING(for pthread_setname_np(const char*))
+         AC_LINK_IFELSE(
+diff --git a/glib/tests/thread.c b/glib/tests/thread.c
+index 5447836..2f248a6 100644
+--- a/glib/tests/thread.c
++++ b/glib/tests/thread.c
+@@ -174,7 +174,7 @@ test_thread5 (void)
+ static gpointer
+ thread6_func (gpointer data)
+ {
+-#ifdef HAVE_PTHREAD_SETNAME_NP_WITH_TID
++#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID) && defined(HAVE_PTHREAD_GETNAME_NP)
+   char name[16];
+ 
+   pthread_getname_np (pthread_self(), name, 16);
+-- 
+2.10.2
+
diff --git a/meta/recipes-core/glib-2.0/glib-2.0_2.50.1.bb b/meta/recipes-core/glib-2.0/glib-2.0_2.50.1.bb
index 00ae7ef..17016c8 100644
--- a/meta/recipes-core/glib-2.0/glib-2.0_2.50.1.bb
+++ b/meta/recipes-core/glib-2.0/glib-2.0_2.50.1.bb
@@ -16,6 +16,7 @@ SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \
            file://gi-exclude.patch \
            file://0001-Install-gio-querymodules-as-libexec_PROGRAM.patch \
            file://0001-Do-not-ignore-return-value-of-write.patch \
+           file://0001-Test-for-pthread_getname_np-before-using-it.patch \
            "
 
 SRC_URI_append_class-native = " file://glib-gettextize-dir.patch \
-- 
2.10.2




More information about the Openembedded-core mailing list