summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 66dbfd5)
raw | patch | inline | side by side (parent: 66dbfd5)
author | Gary V. Vaughan <git@mlists.thewrittenword.com> | |
Fri, 14 May 2010 09:31:34 +0000 (09:31 +0000) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 31 May 2010 23:59:26 +0000 (16:59 -0700) |
Without this patch, systems that provide stubs for pthread functions
in libc, but which still require libpthread for full the pthread
implementation are not detected correctly.
Also, some systems require -pthread in CFLAGS for each compilation
unit for a successful link of an mt binary, which is also addressed by
this patch.
Signed-off-by: Gary V. Vaughan <gary@thewrittenword.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
in libc, but which still require libpthread for full the pthread
implementation are not detected correctly.
Also, some systems require -pthread in CFLAGS for each compilation
unit for a successful link of an mt binary, which is also addressed by
this patch.
Signed-off-by: Gary V. Vaughan <gary@thewrittenword.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile | patch | blob | history | |
config.mak.in | patch | blob | history | |
configure.ac | patch | blob | history |
diff --git a/Makefile b/Makefile
index da0cfda3e8a5b8b04012862e66b84da34af680a6..f6085a52400a2f440cc174cdd8ab980c3c7a644d 100644 (file)
--- a/Makefile
+++ b/Makefile
TCL_PATH = tclsh
TCLTK_PATH = wish
PTHREAD_LIBS = -lpthread
+PTHREAD_CFLAGS =
export TCL_PATH TCLTK_PATH
BASIC_CFLAGS += -D_LARGE_FILES
ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
NO_PTHREADS = YesPlease
+ else
+ PTHREAD_LIBS = -lpthread
endif
endif
ifeq ($(uname_S),GNU)
ifdef NO_PTHREADS
BASIC_CFLAGS += -DNO_PTHREADS
else
+ BASIC_CFLAGS += $(PTHREAD_CFLAGS)
EXTLIBS += $(PTHREAD_LIBS)
LIB_OBJS += thread-utils.o
endif
diff --git a/config.mak.in b/config.mak.in
index 7eb6f59eb1de2af9b59f9e596524f6ad751f82b8..d35f639d4c2d41c01efcef743795102c203763d1 100644 (file)
--- a/config.mak.in
+++ b/config.mak.in
FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
NO_PTHREADS=@NO_PTHREADS@
+PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
PTHREAD_LIBS=@PTHREAD_LIBS@
diff --git a/configure.ac b/configure.ac
index f4d7372ef8d7b45f9810d5f8bc191c71622a71f2..ad380b83d1921b9f9e1080a971a760ec4df96de3 100644 (file)
--- a/configure.ac
+++ b/configure.ac
int main(void)
{
pthread_mutex_t test_mutex;
- return (0);
+ int retcode = 0;
+ retcode |= pthread_mutex_init(&test_mutex,(void *)0);
+ retcode |= pthread_mutex_lock(&test_mutex);
+ retcode |= pthread_mutex_unlock(&test_mutex);
+ return retcode;
}
])
# handle these separately since PTHREAD_CFLAGS could be '-lpthreads
# -D_REENTRANT' or some such.
elif test -z "$PTHREAD_CFLAGS"; then
- for opt in -pthread -lpthread; do
+ threads_found=no
+ for opt in -mt -pthread -lpthread; do
old_CFLAGS="$CFLAGS"
CFLAGS="$opt $CFLAGS"
AC_MSG_CHECKING([Checking for POSIX Threads with '$opt'])
[AC_MSG_RESULT([yes])
NO_PTHREADS=
PTHREAD_LIBS="$opt"
+ PTHREAD_CFLAGS="$opt"
+ threads_found=yes
break
],
[AC_MSG_RESULT([no])])
CFLAGS="$old_CFLAGS"
done
+ if test $threads_found != yes; then
+ AC_CHECK_LIB([pthread], [pthread_create],
+ [PTHREAD_LIBS="-lpthread"],
+ [NO_PTHREADS=UnfortunatelyYes])
+ fi
else
old_CFLAGS="$CFLAGS"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
CFLAGS="$old_CFLAGS"
+AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(NO_PTHREADS)