2011-06-01 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Wed, 1 Jun 2011 07:51:37 +0000 (07:51 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 25 Jul 2011 12:03:26 +0000 (16:03 +0400)
* configure.ac (_PTHREADS): New template (used for NetBSD).
* configure.ac (THREADDLLIBS): New macro.
* tests/Makefile.am (test_atomic_LDADD, test_stack_LDADD,
test_atomic_pthreads_LDADD, test_malloc_LDADD): Use THREADDLLIBS
instead of "-lpthread".
* configure: Regenerate.
* Makefile.in: Ditto.
* doc/Makefile.in: Ditto.
* src/Makefile.in: Ditto.
* src/atomic_ops/Makefile.in: Ditto.
* src/atomic_ops/sysdeps/Makefile.in: Ditto.
* src/config.h.in: Ditto.
* tests/Makefile.in: Ditto.

ChangeLog
Makefile.in
configure
configure.ac
doc/Makefile.in
src/Makefile.in
src/atomic_ops/Makefile.in
src/atomic_ops/sysdeps/Makefile.in
src/config.h.in
tests/Makefile.am
tests/Makefile.in

index e876913..027c09e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2011-06-01  Ivan Maidanski  <ivmai@mail.ru>
+
+       * configure.ac (_PTHREADS): New template (used for NetBSD).
+       * configure.ac (THREADDLLIBS): New macro.
+       * tests/Makefile.am (test_atomic_LDADD, test_stack_LDADD,
+       test_atomic_pthreads_LDADD, test_malloc_LDADD): Use THREADDLLIBS
+       instead of "-lpthread".
+       * configure: Regenerate.
+       * Makefile.in: Ditto.
+       * doc/Makefile.in: Ditto.
+       * src/Makefile.in: Ditto.
+       * src/atomic_ops/Makefile.in: Ditto.
+       * src/atomic_ops/sysdeps/Makefile.in: Ditto.
+       * src/config.h.in: Ditto.
+       * tests/Makefile.in: Ditto.
+
 2011-05-30  Ivan Maidanski  <ivmai@mail.ru>
 
        * configure.ac (PIC): Add workaround for GCC v3.4.6 which does not
index 0c5b27b..3ed9815 100644 (file)
@@ -150,6 +150,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
index 56e2d35..c80d83f 100755 (executable)
--- a/configure
+++ b/configure
@@ -606,6 +606,7 @@ LTLIBOBJS
 LIBOBJS
 NEED_ASM_FALSE
 NEED_ASM_TRUE
+THREADDLLIBS
 PICFLAG
 EGREP
 GREP
@@ -4768,6 +4769,66 @@ CFLAGS="$CFLAGS -DNDEBUG"
 
 
 
+
+THREADDLLIBS=
+## Libraries needed to support threads.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5
+$as_echo_n "checking for pthread_self in -lpthread... " >&6; }
+if ${ac_cv_lib_pthread_pthread_self+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_self ();
+int
+main ()
+{
+return pthread_self ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_pthread_pthread_self=yes
+else
+  ac_cv_lib_pthread_pthread_self=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_self" >&5
+$as_echo "$ac_cv_lib_pthread_pthread_self" >&6; }
+if test "x$ac_cv_lib_pthread_pthread_self" = xyes; then :
+  THREADDLLIBS="-lpthread"
+fi
+
+
+$as_echo "#define _REENTRANT 1" >>confdefs.h
+
+case "$host" in
+    *-*-netbsd*)
+      $as_echo "#define _PTHREADS 1" >>confdefs.h
+
+      ;;
+    *-*-openbsd* | *-*-kfreebsd*-gnu | *-*-dgux*)
+      THREADDLLIBS=-pthread
+      ;;
+    *-*-cygwin* | *-*-darwin*)
+      THREADDLLIBS=
+      ;;
+esac
+
+
  if test x$need_asm = xtrue; then
   NEED_ASM_TRUE=
   NEED_ASM_FALSE='#'
index e913b96..9883384 100644 (file)
@@ -55,13 +55,32 @@ else
   esac
 fi
 CFLAGS="$CFLAGS -DNDEBUG"
-
 AC_SUBST(PICFLAG)
 AC_SUBST(DEFS)
 
+AH_TEMPLATE([_PTHREADS], [Indicates the use of pthreads (NetBSD).])
+
+THREADDLLIBS=
+## Libraries needed to support threads.
+AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
+AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads.])
+case "$host" in
+    *-*-netbsd*)
+      AC_DEFINE(_PTHREADS)
+      ;;
+    *-*-openbsd* | *-*-kfreebsd*-gnu | *-*-dgux*)
+      THREADDLLIBS=-pthread
+      ;;
+    *-*-cygwin* | *-*-darwin*)
+      THREADDLLIBS=
+      ;;
+esac
+AC_SUBST(THREADDLLIBS)
+
 AM_CONDITIONAL(NEED_ASM, test x$need_asm = xtrue)
 
-AC_CONFIG_FILES([Makefile src/Makefile src/atomic_ops/Makefile src/atomic_ops/sysdeps/Makefile doc/Makefile tests/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile src/atomic_ops/Makefile \
+    src/atomic_ops/sysdeps/Makefile doc/Makefile tests/Makefile])
 AC_CONFIG_COMMANDS([default],[[]],[[
 PICFLAG="${PICFLAG}"
 CC="${CC}"
index f2977a4..0773e3f 100644 (file)
@@ -120,6 +120,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
index dace062..ff309fe 100644 (file)
@@ -187,6 +187,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
index 258126e..baa6ca2 100644 (file)
@@ -160,6 +160,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
index 3d7f0c8..3f7a679 100644 (file)
@@ -122,6 +122,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
index 2967be7..89bc6df 100644 (file)
@@ -65,3 +65,9 @@
 
 /* Version number of package */
 #undef VERSION
+
+/* Indicates the use of pthreads (NetBSD). */
+#undef _PTHREADS
+
+/* Required define if using POSIX threads. */
+#undef _REENTRANT
index 6d4ecfc..e5afb35 100644 (file)
@@ -14,17 +14,19 @@ TESTS=test_atomic test_atomic_pthreads test_stack test_malloc
 check_PROGRAMS=test_atomic test_atomic_pthreads test_stack test_malloc
 
 test_atomic_SOURCES=test_atomic.c
-test_atomic_LDADD=-lpthread ../src/libatomic_ops.a
+test_atomic_LDADD=$(THREADDLLIBS) ../src/libatomic_ops.a
 
 test_atomic_pthreads_SOURCES=test_atomic.c
 test_atomic_pthreads_CPPFLAGS=-DAO_USE_PTHREAD_DEFS $(AM_CPPFLAGS)
-test_atomic_pthreads_LDADD=-lpthread ../src/libatomic_ops.a
+test_atomic_pthreads_LDADD=$(THREADDLLIBS) ../src/libatomic_ops.a
 
 test_stack_SOURCES=test_stack.c
-test_stack_LDADD=-lpthread ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
+test_stack_LDADD=$(THREADDLLIBS) ../src/libatomic_ops_gpl.a \
+       ../src/libatomic_ops.a
 
 test_malloc_SOURCES=test_malloc.c
-test_malloc_LDADD=-lpthread ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
+test_malloc_LDADD=$(THREADDLLIBS) ../src/libatomic_ops_gpl.a \
+       ../src/libatomic_ops.a
 
 test_atomic_include.h: test_atomic.template
        sed -e s/XX// $? > $@
index 0e6de31..590e64a 100644 (file)
@@ -50,19 +50,22 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am_test_atomic_OBJECTS = test_atomic.$(OBJEXT)
 test_atomic_OBJECTS = $(am_test_atomic_OBJECTS)
-test_atomic_DEPENDENCIES = ../src/libatomic_ops.a
+am__DEPENDENCIES_1 =
+test_atomic_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+       ../src/libatomic_ops.a
 am_test_atomic_pthreads_OBJECTS =  \
        test_atomic_pthreads-test_atomic.$(OBJEXT)
 test_atomic_pthreads_OBJECTS = $(am_test_atomic_pthreads_OBJECTS)
-test_atomic_pthreads_DEPENDENCIES = ../src/libatomic_ops.a
+test_atomic_pthreads_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+       ../src/libatomic_ops.a
 am_test_malloc_OBJECTS = test_malloc.$(OBJEXT)
 test_malloc_OBJECTS = $(am_test_malloc_OBJECTS)
-test_malloc_DEPENDENCIES = ../src/libatomic_ops_gpl.a \
-       ../src/libatomic_ops.a
+test_malloc_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+       ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
 am_test_stack_OBJECTS = test_stack.$(OBJEXT)
 test_stack_OBJECTS = $(am_test_stack_OBJECTS)
-test_stack_DEPENDENCIES = ../src/libatomic_ops_gpl.a \
-       ../src/libatomic_ops.a
+test_stack_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+       ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
@@ -128,6 +131,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -192,14 +196,18 @@ BUILT_SOURCES = test_atomic_include.h list_atomic.i
 CLEANFILES = list_atomic.i
 AM_CPPFLAGS = -I$(srcdir)/../src
 test_atomic_SOURCES = test_atomic.c
-test_atomic_LDADD = -lpthread ../src/libatomic_ops.a
+test_atomic_LDADD = $(THREADDLLIBS) ../src/libatomic_ops.a
 test_atomic_pthreads_SOURCES = test_atomic.c
 test_atomic_pthreads_CPPFLAGS = -DAO_USE_PTHREAD_DEFS $(AM_CPPFLAGS)
-test_atomic_pthreads_LDADD = -lpthread ../src/libatomic_ops.a
+test_atomic_pthreads_LDADD = $(THREADDLLIBS) ../src/libatomic_ops.a
 test_stack_SOURCES = test_stack.c
-test_stack_LDADD = -lpthread ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
+test_stack_LDADD = $(THREADDLLIBS) ../src/libatomic_ops_gpl.a \
+       ../src/libatomic_ops.a
+
 test_malloc_SOURCES = test_malloc.c
-test_malloc_LDADD = -lpthread ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
+test_malloc_LDADD = $(THREADDLLIBS) ../src/libatomic_ops_gpl.a \
+       ../src/libatomic_ops.a
+
 all: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) all-am