[ccan] [PATCH] tap: fix pthread uses

Kirill A. Shutemov kirill at shutemov.name
Mon Jul 4 03:36:48 EST 2011


From: "Kirill A. Shutemov" <kirill at shutemov.name>

tap expects that HAVE_LIBPTHREAD will be defined, but configurator
doesn't provide it:

ccan/tap/tap.c:49:5: warning: "HAVE_LIBPTHREAD" is not defined [-Wundef]

Lets check for <pthread.h> in configurator and provide HAVE_PTHREAD_H
based on the results.

Signed-off-by: Kirill A. Shutemov <kirill at shutemov.name>
---
 ccan/tap/tap.c                    |    4 ++--
 tools/configurator/configurator.c |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/ccan/tap/tap.c b/ccan/tap/tap.c
index b7a84ac..59fc447 100644
--- a/ccan/tap/tap.c
+++ b/ccan/tap/tap.c
@@ -45,8 +45,8 @@ static int test_died = 0;
 static int test_pid;
 
 /* Encapsulate the pthread code in a conditional.  In the absence of
-   libpthread the code does nothing */
-#if HAVE_LIBPTHREAD
+   pthread.h the code does nothing */
+#if HAVE_PTHREAD_H
 #include <pthread.h>
 static pthread_mutex_t M = PTHREAD_MUTEX_INITIALIZER;
 # define LOCK pthread_mutex_lock(&M)
diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c
index d46a147..81d735f 100644
--- a/tools/configurator/configurator.c
+++ b/tools/configurator/configurator.c
@@ -155,6 +155,8 @@ static struct test tests[] = {
 	  "static void *func(int fd) {\n"
 	  "	return mmap(0, 65536, PROT_READ, MAP_SHARED, fd, 0);\n"
 	  "}" },
+	{ "HAVE_PTHREAD_H", OUTSIDE_MAIN, NULL,
+	  "#include <pthread.h>\n" },
 	{ "HAVE_QSORT_R_PRIVATE_LAST",
 	  DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE, NULL,
 	  "#define _GNU_SOURCE 1\n"
-- 
1.7.5.4



More information about the ccan mailing list