summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Jacke <bj@sernet.de>2010-01-26 00:17:10 +0100
committerBjörn Jacke <bj@sernet.de>2010-01-26 00:19:10 +0100
commit5439e1a03f66ff9722987f908babfd71ebd698f1 (patch)
treefed6e991abd9bcd0fb9ca73040b33953d1d57320
parent60a3086d78d9cf445034172f594325cb7b929d24 (diff)
downloadsamba-5439e1a03f66ff9722987f908babfd71ebd698f1.tar.gz
samba-5439e1a03f66ff9722987f908babfd71ebd698f1.tar.bz2
samba-5439e1a03f66ff9722987f908babfd71ebd698f1.zip
s3: fix detection and flags for using pthread
I hope this fixes the build on Tru64, IRIX and maybe bug #6983
-rw-r--r--source3/Makefile.in4
-rw-r--r--source3/configure.in64
-rw-r--r--source3/libsmb/libsmb_thread_posix.c4
3 files changed, 59 insertions, 13 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 9d67b449d0..d75420ec39 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -72,7 +72,7 @@ NSCD_LIBS=@NSCD_LIBS@
UUID_LIBS=@UUID_LIBS@
LIBWBCLIENT=@LIBWBCLIENT_STATIC@ @LIBWBCLIENT_SHARED@
LIBWBCLIENT_LIBS=@LIBWBCLIENT_LIBS@
-WINBIND_NSS_PTHREAD=@WINBIND_NSS_PTHREAD@
+WINBIND_NSS_PTHREAD_LDFLAGS=@PTHREAD_LDFLAGS@
DNSSD_LIBS=@DNSSD_LIBS@
AVAHI_LIBS=@AVAHI_LIBS@
POPT_LIBS=@POPTLIBS@
@@ -2527,7 +2527,7 @@ bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) $(LIBTDB)
@WINBIND_NSS@: $(BINARY_PREREQS) $(WINBIND_NSS_OBJ)
@echo "Linking $@"
@$(SHLD) $(WINBIND_NSS_LDSHFLAGS) -o $@ $(WINBIND_NSS_OBJ) \
- $(LIBREPLACE_LIBS) $(WINBIND_NSS_PTHREAD) \
+ $(LIBREPLACE_LIBS) $(WINBIND_NSS_PTHREAD_LDFLAGS) \
@SONAMEFLAG@`basename $@`@NSSSONAMEVERSIONSUFFIX@
@WINBIND_WINS_NSS@: $(BINARY_PREREQS) $(WINBIND_WINS_NSS_OBJ) $(LIBTALLOC) $(LIBTDB)
diff --git a/source3/configure.in b/source3/configure.in
index 82664d6c4a..a5d0b0669b 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -709,7 +709,7 @@ AUTH_LIBS="${AUTH_LIBS} ${CRYPT_LIBS}"
AC_CHECK_HEADERS(aio.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
AC_CHECK_HEADERS(unistd.h grp.h sys/id.h memory.h alloca.h)
-AC_CHECK_HEADERS(limits.h float.h pthread.h libintl.h)
+AC_CHECK_HEADERS(limits.h float.h libintl.h)
AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h sys/sysctl.h)
AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h)
@@ -6032,7 +6032,6 @@ WINBIND_NSS="../nsswitch/libnss_winbind.$SHLIBEXT"
WINBIND_WINS_NSS="../nsswitch/libnss_wins.$SHLIBEXT"
WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
NSSSONAMEVERSIONSUFFIX=""
-WINBIND_NSS_PTHREAD=""
case "$host_os" in
*linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
@@ -6174,12 +6173,6 @@ else
AC_MSG_RESULT(no$winbind_no_reason)
fi
-AC_CHECK_LIB(pthread, pthread_mutex_lock, [WINBIND_NSS_PTHREAD="-lpthread"
- AC_DEFINE(HAVE_PTHREAD, 1, [whether pthread exists])
- samba_cv_HAVE_PTHREAD=yes],
- samba_cv_HAVE_PTHREAD=no)
-
-AC_SUBST(WINBIND_NSS_PTHREAD)
AC_SUBST(WINBIND_NSS)
AC_SUBST(WINBIND_WINS_NSS)
AC_SUBST(WINBIND_NSS_LDSHFLAGS)
@@ -6335,16 +6328,65 @@ if test x"$enable_avahi" != x"no"; then
fi
fi
+
+#################################################
+# Set pthread stuff
+
+PTHREAD_CFLAGS=error
+PTHREAD_LDFLAGS=error
+
+# If it's error, then the user didn't
+# define it.
+if test "x$PTHREAD_LDFLAGS" = xerror; then
+ AC_CHECK_LIB(pthread, pthread_attr_init, [
+ PTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
+ PTHREAD_LDFLAGS="-lpthread" ])
+fi
+
+if test "x$PTHREAD_LDFLAGS" = xerror; then
+ AC_CHECK_LIB(pthreads, pthread_attr_init, [
+ PTHREAD_CFLAGS="-D_THREAD_SAFE"
+ PTHREAD_LDFLAGS="-lpthreads" ])
+fi
+
+if test "x$PTHREAD_LDFLAGS" = xerror; then
+ AC_CHECK_LIB(c_r, pthread_attr_init, [
+ PTHREAD_CFLAGS="-D_THREAD_SAFE -pthread"
+ PTHREAD_LDFLAGS="-pthread" ])
+fi
+
+if test "x$PTHREAD_LDFLAGS" = xerror; then
+ AC_CHECK_FUNC(pthread_attr_init, [
+ PTHREAD_CFLAGS="-D_REENTRANT"
+ PTHREAD_LDFLAGS="-lpthread" ])
+fi
+
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_LDFLAGS)
+
+samba_cv_HAVE_PTHREAD=no
+if test x"$PTHREAD_CFLAGS" != xerror -a x"$PTHREAD_LDFLAGS" != xerror; then
+ samba_cv_HAVE_PTHREAD=yes
+ # now check for pthread.h with pthread-correct CFLAGS:
+ ac_save_CFLAGS=$CFLAGS
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ AC_CHECK_HEADERS(pthread.h)
+ CFLAGS=$ac_save_CFLAGS
+fi
+
#################################################
# Check if user wants pthreadpool support
+if test x"$enable_pthreadpool" = xyes -a x"$samba_cv_HAVE_PTHREAD" != x"yes"; then
+ AC_MSG_ERROR([pthread support cannot be enabled when pthread header file not found])
+fi
+
AC_ARG_ENABLE(pthreadpool,
[AS_HELP_STRING([--enable-pthreadpool], [Enable pthreads pool helper support (default=auto)])])
if test x"$enable_pthreadpool" != x"no" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; then
- AC_TRY_LINK([#include "pthread.h"],
- [pthread_create(NULL, NULL, NULL, NULL)],
- ,LIBS="$LIBS -lpthread")
+ LIBS="$LIBS $PTHREAD_LDFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
AC_DEFINE(WITH_PTHREADPOOL, 1, [Whether to include pthreadpool helpers])
AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool.o")
fi
diff --git a/source3/libsmb/libsmb_thread_posix.c b/source3/libsmb/libsmb_thread_posix.c
index 6519659c25..8c8299dd7f 100644
--- a/source3/libsmb/libsmb_thread_posix.c
+++ b/source3/libsmb/libsmb_thread_posix.c
@@ -17,8 +17,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include "includes.h"
+#ifdef HAVE_PTHREAD_H
#include <pthread.h>
+#endif
#include "libsmbclient.h"
#include "libsmb_internal.h"
@@ -47,3 +50,4 @@ smbc_thread_posix(void)
{
smb_thread_set_functions(&tf);
}
+