Skip to contentSkip to conversation

Check for pthread in Libc

PATCH New Charles Briere 2 participants 2 messages Dec 2, 2013 2 messages not in the archive Kbuild

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/2 Check for pthread in Libc

Some libc like Googles's Bionic for
Android include pThread. Instead of checking
for Android as in commit 58a052effb2305655ff1b7233c78ab24fc25257e this patch checks for pthread in libc as proposed
by Thomas Petazzoni <[email protected]>

---
 Makefile.am                  | 2 +-
 configure.ac                 | 9 +++++++++
 tests/benchmark/Makefile.am  | 2 +-
 tests/regression/Makefile.am | 2 +-
 tests/unit/Makefile.am       | 2 +-
 5 files changed, 13 insertions(+), 4 deletions(-)
Makefile.am +1 -1
index 938027c..2f81bce 100644
@@ -5,7 +5,7 @@ INCLUDES = -I$(top_builddir)/urcu
 #Add the -version-info directly here since we are only building
 # library that use the version-info
 AM_LDFLAGS=-version-info $(URCU_LIBRARY_VERSION)
-if !TARGET_IS_ANDROID
+if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS+=-lpthread
 endif
 AM_CFLAGS=-Wall
configure.ac +9 -0
index 38e39e1..774094e 100644
@@ -165,6 +165,15 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 	compat_futex_test=1
 ])
 
+# Check for pthread
+AC_CHECK_LIB([pthread], [pthread_create],
+	[AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, false)],
+	[AC_CHECK_LIB([c], [pthread_create],
+		[AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, true)],
+		[AC_MSG_ERROR([Cannot find libpthread. Use [LDFLAGS]=-Ldir to specify its location.])]
+	)]
+)
+
 AM_CONDITIONAL([COMPAT_FUTEX], [test "x$compat_futex_test" = "x1"])
 AM_CONDITIONAL([COMPAT_ARCH], [test "x$SUBARCHTYPE" = "xx86compat"])
 AM_CONDITIONAL([NO_SHARED], [test "x$enable_shared" = "xno"])
tests/benchmark/Makefile.am +1 -1
index bf02189..e889f88 100644
@@ -1,4 +1,4 @@
-if !TARGET_IS_ANDROID
+if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS=-lpthread
 endif
 AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
tests/regression/Makefile.am +1 -1
index eb15699..80cb1bc 100644
@@ -1,4 +1,4 @@
-if !TARGET_IS_ANDROID
+if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS=-lpthread
 endif
 AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
tests/unit/Makefile.am +1 -1
index 2c89ca6..9efd74e 100644
@@ -1,4 +1,4 @@
-if !TARGET_IS_ANDROID
+if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS=-lpthread
 endif
 AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
Signature · 1 line
1.8.4.2

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Both patches merged, thanks!

Mathieu

----- Original Message -----

Quoted 89 lines

From: "Charles Briere" <[email protected]>
To: "mathieu desnoyers" <[email protected]>
Cc: [email protected], "Charles Briere" <[email protected]>
Sent: Monday, December 2, 2013 3:00:50 AM
Subject: [PATCH liburcu 2/2] Check for pthread in Libc

Some libc like Googles's Bionic for
Android include pThread. Instead of checking
for Android as in commit 58a052effb2305655ff1b7233c78ab24fc25257e this patch checks for pthread in libc as proposed
by Thomas Petazzoni <[email protected]>

---
 Makefile.am                  | 2 +-
 configure.ac                 | 9 +++++++++
 tests/benchmark/Makefile.am  | 2 +-
 tests/regression/Makefile.am | 2 +-
 tests/unit/Makefile.am       | 2 +-
 5 files changed, 13 insertions(+), 4 deletions(-)
Makefile.am +1 -1
index 938027c..2f81bce 100644
@@ -5,7 +5,7 @@ INCLUDES = -I$(top_builddir)/urcu
 #Add the -version-info directly here since we are only building
 # library that use the version-info
 AM_LDFLAGS=-version-info $(URCU_LIBRARY_VERSION)
-if !TARGET_IS_ANDROID
+if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS+=-lpthread
 endif
 AM_CFLAGS=-Wall
configure.ac +6 -0
index 38e39e1..774094e 100644
@@ -165,6 +165,15 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 	compat_futex_test=1
 ])
 
+# Check for pthread
+AC_CHECK_LIB([pthread], [pthread_create],
+	[AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, false)],
+	[AC_CHECK_LIB([c], [pthread_create],
+		[AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, true)],
+		[AC_MSG_ERROR([Cannot find libpthread. Use [LDFLAGS]=-Ldir to specify its

location.])]

configure.ac +3 -0
+	)]
+)
+
 AM_CONDITIONAL([COMPAT_FUTEX], [test "x$compat_futex_test" = "x1"])
 AM_CONDITIONAL([COMPAT_ARCH], [test "x$SUBARCHTYPE" = "xx86compat"])
 AM_CONDITIONAL([NO_SHARED], [test "x$enable_shared" = "xno"])
tests/benchmark/Makefile.am +1 -1
index bf02189..e889f88 100644
@@ -1,4 +1,4 @@
-if !TARGET_IS_ANDROID
+if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS=-lpthread
 endif
 AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
tests/regression/Makefile.am +1 -1
index eb15699..80cb1bc 100644
@@ -1,4 +1,4 @@
-if !TARGET_IS_ANDROID
+if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS=-lpthread
 endif
 AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
tests/unit/Makefile.am +1 -2
index 2c89ca6..9efd74e 100644
@@ -1,4 +1,4 @@
-if !TARGET_IS_ANDROID
+if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS=-lpthread
 endif
 AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
--

1.8.4.2

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com