OSDN Git Service

2009-12-11 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / acinclude.m4
index 8ea21ce..1eaf4ba 100644 (file)
@@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
   # Keep these sync'd with the list in Makefile.am.  The first provides an
   # expandable list at autoconf time; the second provides an expandable list
   # (i.e., shell variable) at configure time.
-  m4_define([glibcxx_SUBDIRS],[include libmath libsupc++ src doc po testsuite])
+  m4_define([glibcxx_SUBDIRS],[include libsupc++ python src doc po testsuite])
   SUBDIRS='glibcxx_SUBDIRS'
 
   # These need to be absolute paths, yet at the same time need to
@@ -79,35 +79,6 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
     AC_HELP_STRING([--with-newlib],
                    [assume newlib as a system C library]))
 
-  # We're almost certainly being configured before anything else which uses
-  # C++, so all of our AC_PROG_* discoveries will be cached.  It's vital that
-  # we not cache the value of CXX that we "discover" here, because it's set
-  # to something unique for us and libjava.  Other target libraries need to
-  # find CXX for themselves.  We yank the rug out from under the normal AC_*
-  # process by sneakily renaming the cache variable.  This also lets us debug
-  # the value of "our" CXX in postmortems.
-  #
-  # We must also force CXX to /not/ be a precious variable, otherwise the
-  # wrong (non-multilib-adjusted) value will be used in multilibs.  This
-  # little trick also affects CPPFLAGS, CXXFLAGS, and LDFLAGS.  And as a side
-  # effect, CXXFLAGS is no longer automagically subst'd, so we have to do
-  # that ourselves.  Un-preciousing AC_PROG_CC also affects CC and CFLAGS.
-  #
-  # -fno-builtin must be present here so that a non-conflicting form of
-  # std::exit can be guessed by AC_PROG_CXX, and used in later tests.
-
-  m4_define([ac_cv_prog_CXX],[glibcxx_cv_prog_CXX])
-  m4_rename([_AC_ARG_VAR_PRECIOUS],[glibcxx_PRECIOUS])
-  m4_define([_AC_ARG_VAR_PRECIOUS],[])
-  save_CXXFLAGS="$CXXFLAGS"
-  CXXFLAGS="$CXXFLAGS -fno-builtin"
-  AC_PROG_CC
-  AC_PROG_CXX
-  CXXFLAGS="$save_CXXFLAGS"
-  m4_rename([glibcxx_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
-  AC_SUBST(CFLAGS)
-  AC_SUBST(CXXFLAGS)
-
   # Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't
   # available).  Uncomment the next line to force a particular method.
   AC_PROG_LN_S
@@ -123,7 +94,6 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
   # which are themselves conditionally expanded.
   ## (Right now, this only matters for enable_wchar_t, but nothing prevents
   ## other macros from doing the same.  This should be automated.)  -pme
-  need_libmath=no
 
   # Check for uClibc since Linux platforms use different configuration
   # directories depending on the C library in use.
@@ -239,8 +209,8 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
     if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
       glibcxx_ld_is_gold=yes
     fi
-    ldver=`$LD --version 2>/dev/null | head -1 | \
-           sed -e 's/GNU \(go\)\{0,1\}ld \(version \)\{0,1\}\(([^)]*) \)\{0,1\}\([0-9.][0-9.]*\).*/\4/'`
+    ldver=`$LD --version 2>/dev/null |
+          sed -e 's/GNU gold /GNU ld /;s/GNU ld version /GNU ld /;s/GNU ld ([^)]*) /GNU ld /;s/GNU ld \([0-9.][0-9.]*\).*/\1/; q'`
     changequote([,])
     glibcxx_gnu_ld_version=`echo $ldver | \
            $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
@@ -639,7 +609,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [
   fi
   
   # Export file names for ABI checking.
-  baseline_dir="$glibcxx_srcdir/config/abi/post/${abi_baseline_pair}\$(MULTISUBDIR)"
+  baseline_dir="$glibcxx_srcdir/config/abi/post/${abi_baseline_pair}"
   AC_SUBST(baseline_dir)
 ])
 
@@ -1074,26 +1044,28 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
 
 
 dnl
-dnl Check for clock_gettime clocks, used in the implementation of 20.8.5
-dnl [time.clock] in the current C++0x working draft.
+dnl Check for clock_gettime, nanosleep and sched_yield, used in the
+dnl implementation of 20.8.5 [time.clock], and 30.2.2 [thread.thread.this]
+dnl in the current C++0x working draft.
 dnl
-dnl --enable-clock-gettime
-dnl --enable-clock-gettime=yes
-dnl        checks for the availability of monotonic and realtime clocks
-dnl        in libc and libposix4 and in case links the latter
-dnl --enable-clock-gettime=rt
+dnl --enable-libstdcxx-time
+dnl --enable-libstdcxx-time=yes
+dnl        checks for the availability of monotonic and realtime clocks,
+dnl        nanosleep and sched_yield in libc and libposix4 and, in case, links
+dnl       the latter
+dnl --enable-libstdcxx-time=rt
 dnl        also searches (and, in case, links) librt.  Note that this is
 dnl        not always desirable because, in glibc, for example, in turn it
 dnl        triggers the linking of libpthread too, which activates locking,
 dnl        a large overhead for single-thread programs.
-dnl --enable-clock-gettime=no
-dnl --disable-clock-gettime
+dnl --enable-libstdcxx-time=no
+dnl --disable-libstdcxx-time
 dnl        disables the checks completely
 dnl
-AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
+AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
 
-  AC_MSG_CHECKING([for clock_gettime clocks])                                   
-  GLIBCXX_ENABLE(clock-gettime,$1,[=KIND],
+  AC_MSG_CHECKING([for clock_gettime, nanosleep and sched_yield])
+  GLIBCXX_ENABLE(libstdcxx-time,$1,[=KIND],
     [use KIND for check type],
     [permit yes|no|rt])
 
@@ -1103,19 +1075,47 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
   CXXFLAGS="$CXXFLAGS -fno-exceptions"
   ac_save_LIBS="$LIBS"
 
-  ac_has_clock_monotonic=no;  
+  ac_has_clock_monotonic=no;
   ac_has_clock_realtime=no;
 
-  if test x"$enable_clock_gettime" != x"no"; then
+  if test x"$enable_libstdcxx_time" != x"no"; then
 
-    if test x"$enable_clock_gettime" = x"rt"; then
+    if test x"$enable_libstdcxx_time" = x"rt"; then
       AC_SEARCH_LIBS(clock_gettime, [rt posix4])
+      AC_SEARCH_LIBS(nanosleep, [rt posix4])
     else
       AC_SEARCH_LIBS(clock_gettime, [posix4])
+      AC_SEARCH_LIBS(nanosleep, [posix4])
     fi
 
     case "$ac_cv_search_clock_gettime" in
       -l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime
+      ;;
+    esac
+    case "$ac_cv_search_nanosleep" in
+      -l*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_nanosleep"
+      ;;
+    esac
+
+    AC_SEARCH_LIBS(sched_yield, [rt posix4])
+
+    case "$ac_cv_search_sched_yield" in
+      -lposix4*)
+      GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
+      AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
+                [ Defined if sched_yield is available. ])
+      ;;
+      -lrt*)
+      if test x"$enable_libstdcxx_time" = x"rt"; then
+        GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
+       AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, 
+                 [ Defined if sched_yield is available. ])
+      fi
+      ;;
+      *)
+      AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
+                [ Defined if sched_yield is available. ])
+      ;;
     esac
 
     AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
@@ -1146,8 +1146,20 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
         ], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
 
       AC_MSG_RESULT($ac_has_clock_realtime)
-    fi
 
+      AC_MSG_CHECKING([for nanosleep])
+      AC_TRY_LINK(
+        [#include <unistd.h>
+         #include <time.h>
+        ],
+        [#if _POSIX_TIMERS > 0
+          timespec tp;
+         #endif
+          nanosleep(&tp, 0);
+        ], [ac_has_nanosleep=yes], [ac_has_nanosleep=no])
+
+      AC_MSG_RESULT($ac_has_nanosleep)
+    fi
   fi
 
   if test x"$ac_has_clock_monotonic" = x"yes"; then
@@ -1160,6 +1172,11 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
       [ Defined if clock_gettime has realtime clock support. ])
   fi
 
+  if test x"$ac_has_nanosleep" = x"yes"; then
+    AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
+      [ Defined if nanosleep is available. ])
+  fi
+
   AC_SUBST(GLIBCXX_LIBS)
 
   CXXFLAGS="$ac_save_CXXFLAGS"
@@ -1490,8 +1507,8 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
                  remainderf(0.0f, 0.0f);
                  remainderl(0.0l, 0.0l);
                  remquo(0.0, 0.0, 0);
-                 remquo(0.0f, 0.0f, 0);
-                 remquo(0.0l, 0.0l, 0);
+                 remquof(0.0f, 0.0f, 0);
+                 remquol(0.0l, 0.0l, 0);
                  rint(0.0);
                  rintf(0.0f);
                  rintl(0.0l);
@@ -1520,7 +1537,7 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
   fi
 
   # Check for the existence of <inttypes.h> functions (NB: doesn't make
-  # sense if the previous check fails, per C99, 7.8/1).
+  # sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
   ac_c99_inttypes_tr1=no;
   if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
     AC_MSG_CHECKING([for ISO C99 support to TR1 in <inttypes.h>])
@@ -1541,6 +1558,27 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
               <tr1/cinttypes> in namespace std::tr1.])
   fi
 
+  # Check for the existence of whcar_t <inttypes.h> functions (NB: doesn't
+  # make sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
+  ac_c99_inttypes_wchar_t_tr1=no;
+  if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
+    AC_MSG_CHECKING([for wchar_t ISO C99 support to TR1 in <inttypes.h>])
+    AC_TRY_COMPILE([#include <inttypes.h>],
+                  [intmax_t base;
+                   const wchar_t* s;
+                   wchar_t** endptr;
+                   intmax_t ret = wcstoimax(s, endptr, base);
+                   uintmax_t uret = wcstoumax(s, endptr, base);
+                  ],[ac_c99_inttypes_wchar_t_tr1=yes],
+                    [ac_c99_inttypes_wchar_t_tr1=no])
+  fi
+  AC_MSG_RESULT($ac_c99_inttypes_wchar_t_tr1)
+  if test x"$ac_c99_inttypes_wchar_t_tr1" = x"yes"; then
+    AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1, 1,
+              [Define if wchar_t C99 functions in <inttypes.h> should be
+             imported in <tr1/cinttypes> in namespace std::tr1.])
+  fi
+
   # Check for the existence of the <stdbool.h> header. 
   AC_CHECK_HEADERS(stdbool.h)
 
@@ -1623,46 +1661,6 @@ m4_popdef([n_syserr])dnl
 ])
 
 dnl
-dnl Check whether C++200x's standard layout types are supported. 
-dnl
-AC_DEFUN([GLIBCXX_CHECK_STANDARD_LAYOUT], [
-
-  AC_MSG_CHECKING([for ISO C++200x standard layout type support])
-  AC_CACHE_VAL(ac_standard_layout, [
-  AC_LANG_SAVE
-  AC_LANG_CPLUSPLUS
-  ac_test_CXXFLAGS="${CXXFLAGS+set}"
-  ac_save_CXXFLAGS="$CXXFLAGS"
-  CXXFLAGS='-std=gnu++0x'
-
-  AC_TRY_COMPILE([struct b
-                  {
-                   bool t;
-
-                   // Need standard layout relaxation from POD
-                   private:        
-                   b& operator=(const b&);
-                   b(const b&);
-                   };
-
-                   int main()
-                   {
-                     b tst1 = { false };
-                      return 0;
-                   }],,
-             [ac_standard_layout=yes], [ac_standard_layout=no])
-
-  CXXFLAGS="$ac_save_CXXFLAGS"
-  AC_LANG_RESTORE
-  ])
-  AC_MSG_RESULT($ac_standard_layout)
-  if test x"$ac_standard_layout" = x"yes"; then
-    AC_DEFINE(_GLIBCXX_USE_STANDARD_LAYOUT, 1,
-              [Define if standard layout types are supported in C++200x.])
-  fi
-])
-
-dnl
 dnl Check for what type of C headers to use.
 dnl
 dnl --enable-cheaders= [does stuff].
@@ -2224,6 +2222,44 @@ AC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [
 
 
 dnl
+dnl Check for decimal floating point.
+dnl See:
+dnl http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float
+dnl
+dnl This checks to see if the host supports decimal floating point types.
+dnl
+dnl Defines:
+dnl  _GLIBCXX_USE_DECIMAL_FLOAT
+dnl
+AC_DEFUN([GLIBCXX_ENABLE_DECIMAL_FLOAT], [
+
+  # Fake what AC_TRY_COMPILE does, without linking as this is
+  # unnecessary for this test.
+
+    cat > conftest.$ac_ext << EOF
+[#]line __oline__ "configure"
+int main()
+{
+  _Decimal32 d1;
+  _Decimal64 d2;
+  _Decimal128 d3;
+  return 0;
+}
+EOF
+
+    AC_MSG_CHECKING([for ISO/IEC TR 24733 ])
+    if AC_TRY_EVAL(ac_compile); then
+      AC_DEFINE(_GLIBCXX_USE_DECIMAL_FLOAT, 1,
+      [Define if ISO/IEC TR 24733 decimal floating point types are supported on this host.])
+      enable_dfp=yes
+    else
+      enable_dfp=no
+    fi
+    AC_MSG_RESULT($enable_dfp)
+    rm -f conftest*
+])
+
+dnl
 dnl Check for template specializations for the 'wchar_t' type.
 dnl
 dnl --enable-wchar_t defines _GLIBCXX_USE_WCHAR_T
@@ -2402,23 +2438,194 @@ dnl is intended to be an all-or-nothing switch, so all the atomic operations
 dnl that are used should be checked.
 dnl
 dnl Note:
-dnl libgomp and libgfortran do this with a link test, instead of an asm test.
-dnl see: CHECK_SYNC_FETCH_AND_ADD
+dnl libgomp and libgfortran use a link test, see CHECK_SYNC_FETCH_AND_ADD.
 dnl
 dnl Defines:
 dnl  _GLIBCXX_ATOMIC_BUILTINS_1 
+dnl  _GLIBCXX_ATOMIC_BUILTINS_2
 dnl  _GLIBCXX_ATOMIC_BUILTINS_4
+dnl  _GLIBCXX_ATOMIC_BUILTINS_8
 dnl
 AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
   AC_LANG_SAVE
   AC_LANG_CPLUSPLUS
   old_CXXFLAGS="$CXXFLAGS"
-  
+
+  # Do link tests if possible, instead asm tests, limited to some platforms
+  # see discussion in PR target/40134, PR libstdc++/40133 and the thread
+  # starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html
+  atomic_builtins_link_tests=no
+  if test x$gcc_no_link != xyes; then
+    # Can do link tests. Limit to some tested platforms
+    case "$host" in
+      *-*-linux* | *-*-uclinux* | *-*-kfreebsd*-gnu | *-*-gnu*)
+       atomic_builtins_link_tests=yes
+        ;;
+    esac
+  fi
+
+  if test x$atomic_builtins_link_tests = xyes; then
+
+  # Do link tests.
+
+  CXXFLAGS="$CXXFLAGS -fno-exceptions"
+
+  AC_MSG_CHECKING([for atomic builtins for bool])
+  AC_CACHE_VAL(glibcxx_cv_atomic_bool, [
+    AC_TRY_LINK(
+      [ ],
+      [typedef bool atomic_type;
+       atomic_type c1;
+       atomic_type c2;
+       const atomic_type c3(0);
+       __sync_fetch_and_add(&c1, c2);
+       __sync_val_compare_and_swap(&c1, c3, c2);
+       __sync_lock_test_and_set(&c1, c3);
+       __sync_lock_release(&c1);
+       __sync_synchronize();],
+      [glibcxx_cv_atomic_bool=yes],
+      [glibcxx_cv_atomic_bool=no])
+  ])    
+  if test $glibcxx_cv_atomic_bool = yes; then
+    AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
+      [Define if builtin atomic operations for bool are supported on this host.])
+  fi
+  AC_MSG_RESULT($glibcxx_cv_atomic_bool)
+
+  AC_MSG_CHECKING([for atomic builtins for short])
+  AC_CACHE_VAL(glibcxx_cv_atomic_short, [
+    AC_TRY_LINK(
+      [ ],
+      [typedef short atomic_type;
+       atomic_type c1;
+       atomic_type c2;
+       const atomic_type c3(0);
+       __sync_fetch_and_add(&c1, c2);
+       __sync_val_compare_and_swap(&c1, c3, c2);
+       __sync_lock_test_and_set(&c1, c3);
+       __sync_lock_release(&c1);
+       __sync_synchronize();],
+      [glibcxx_cv_atomic_short=yes],
+      [glibcxx_cv_atomic_short=no])
+  ])    
+  if test $glibcxx_cv_atomic_short = yes; then
+    AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
+      [Define if builtin atomic operations for short are supported on this host.])
+  fi
+  AC_MSG_RESULT($glibcxx_cv_atomic_short)
+
+  AC_MSG_CHECKING([for atomic builtins for int])
+  AC_CACHE_VAL(glibcxx_cv_atomic_int, [
+    AC_TRY_LINK(
+      [ ],
+      [typedef int atomic_type;
+       atomic_type c1;
+       atomic_type c2;
+       const atomic_type c3(0);
+       __sync_fetch_and_add(&c1, c2);
+       __sync_val_compare_and_swap(&c1, c3, c2);
+       __sync_lock_test_and_set(&c1, c3);
+       __sync_lock_release(&c1);
+       __sync_synchronize();],
+      [glibcxx_cv_atomic_int=yes],
+      [glibcxx_cv_atomic_int=no])
+  ])    
+  if test $glibcxx_cv_atomic_int = yes; then
+    AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1,
+      [Define if builtin atomic operations for int are supported on this host.])
+  fi
+  AC_MSG_RESULT($glibcxx_cv_atomic_int)
+
+  AC_MSG_CHECKING([for atomic builtins for long long])
+  AC_CACHE_VAL(glibcxx_cv_atomic_long_long, [
+    AC_TRY_LINK(
+      [ ],
+      [typedef long long atomic_type;
+       atomic_type c1;
+       atomic_type c2;
+       const atomic_type c3(0);
+       __sync_fetch_and_add(&c1, c2);
+       __sync_val_compare_and_swap(&c1, c3, c2);
+       __sync_lock_test_and_set(&c1, c3);
+       __sync_lock_release(&c1);
+       __sync_synchronize();],
+      [glibcxx_cv_atomic_long_long=yes],
+      [glibcxx_cv_atomic_long_long=no])
+  ])    
+  if test $glibcxx_cv_atomic_long_long = yes; then
+    AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
+      [Define if builtin atomic operations for long long are supported on this host.])
+  fi
+  AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
+
+  else
+
+  # Do asm tests.
+
   # Compile unoptimized.
   CXXFLAGS='-O0 -S'
 
-  # Fake what AC_TRY_COMPILE does, without linking as this is
-  # unnecessary for a builtins test.
+  # Fake what AC_TRY_COMPILE does.
+
+    cat > conftest.$ac_ext << EOF
+[#]line __oline__ "configure"
+int main()
+{
+  typedef bool atomic_type;
+  atomic_type c1;
+  atomic_type c2;
+  const atomic_type c3(0);
+  __sync_fetch_and_add(&c1, c2);
+  __sync_val_compare_and_swap(&c1, c3, c2);
+  __sync_lock_test_and_set(&c1, c3);
+  __sync_lock_release(&c1);
+  __sync_synchronize();
+  return 0;
+}
+EOF
+
+    AC_MSG_CHECKING([for atomic builtins for bool])
+    if AC_TRY_EVAL(ac_compile); then
+      if grep __sync_ conftest.s >/dev/null 2>&1 ; then
+        glibcxx_cv_atomic_bool=no
+      else
+      AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
+      [Define if builtin atomic operations for bool are supported on this host.])
+        glibcxx_cv_atomic_bool=yes
+      fi
+    fi
+    AC_MSG_RESULT($glibcxx_cv_atomic_bool)
+    rm -f conftest*
+
+    cat > conftest.$ac_ext << EOF
+[#]line __oline__ "configure"
+int main()
+{
+  typedef short atomic_type;
+  atomic_type c1;
+  atomic_type c2;
+  const atomic_type c3(0);
+  __sync_fetch_and_add(&c1, c2);
+  __sync_val_compare_and_swap(&c1, c3, c2);
+  __sync_lock_test_and_set(&c1, c3);
+  __sync_lock_release(&c1);
+  __sync_synchronize();
+  return 0;
+}
+EOF
+
+    AC_MSG_CHECKING([for atomic builtins for short])
+    if AC_TRY_EVAL(ac_compile); then
+      if grep __sync_ conftest.s >/dev/null 2>&1 ; then
+        glibcxx_cv_atomic_short=no
+      else
+      AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
+      [Define if builtin atomic operations for short are supported on this host.])
+        glibcxx_cv_atomic_short=yes
+      fi
+    fi
+    AC_MSG_RESULT($glibcxx_cv_atomic_short)
+    rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
 [#]line __oline__ "configure"
@@ -2441,21 +2648,21 @@ EOF
     AC_MSG_CHECKING([for atomic builtins for int])
     if AC_TRY_EVAL(ac_compile); then
       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
-        enable_atomic_builtinsi=no
+        glibcxx_cv_atomic_int=no
       else
       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1,
         [Define if builtin atomic operations for int are supported on this host.])
-        enable_atomic_builtinsi=yes
+        glibcxx_cv_atomic_int=yes
       fi
     fi
-    AC_MSG_RESULT($enable_atomic_builtinsi)
+    AC_MSG_RESULT($glibcxx_cv_atomic_int)
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
 [#]line __oline__ "configure"
 int main()
 {
-  typedef bool atomic_type;
+  typedef long long atomic_type;
   atomic_type c1;
   atomic_type c2;
   const atomic_type c3(0);
@@ -2468,24 +2675,26 @@ int main()
 }
 EOF
 
-    AC_MSG_CHECKING([for atomic builtins for bool])
+    AC_MSG_CHECKING([for atomic builtins for long long])
     if AC_TRY_EVAL(ac_compile); then
       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
-        enable_atomic_builtinsb=no
+        glibcxx_cv_atomic_long_long=no
       else
-      AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
-      [Define if builtin atomic operations for bool are supported on this host.])
-        enable_atomic_builtinsb=yes
+      AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
+      [Define if builtin atomic operations for long long are supported on this host.])
+        glibcxx_cv_atomic_long_long=yes
       fi
     fi
-    AC_MSG_RESULT($enable_atomic_builtinsb)
+    AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
     rm -f conftest*
 
+  fi
+
   CXXFLAGS="$old_CXXFLAGS"
   AC_LANG_RESTORE
 
   # Set atomicity_dir to builtins if either of above tests pass.
-  if test $enable_atomic_builtinsi = yes || test $enable_atomic_builtinsb = yes ; then
+  if test $glibcxx_cv_atomic_int = yes || test $glibcxx_cv_atomic_bool = yes ; then
     atomicity_dir=cpu/generic/atomicity_builtins
   fi
 
@@ -2493,7 +2702,7 @@ EOF
   if test $atomicity_dir = "cpu/generic" ; then
     atomicity_dir=cpu/generic/atomicity_mutex
     AC_MSG_WARN([No native atomic operations are provided for this platform.])
-      if test $target_thread_file = single; then
+      if test "x$target_thread_file" = xsingle; then
         AC_MSG_WARN([They cannot be faked when thread support is disabled.])
         AC_MSG_WARN([Thread-safety of certain classes is not guaranteed.])
       else
@@ -2637,7 +2846,12 @@ if test x$enable_symvers = xyes ; then
     enable_symvers=no
   else
     if test $with_gnu_ld = yes ; then
-      enable_symvers=gnu
+      case ${target_os} in
+        hpux*)
+          enable_symvers=no ;;
+        *)
+          enable_symvers=gnu ;;
+      esac
     else
       case ${target_os} in
         darwin*)
@@ -2737,6 +2951,16 @@ if test x$enable_symvers != xno ; then
         [Define to use symbol versioning in the shared library.])
 fi
 
+AC_CACHE_CHECK([whether the target supports .symver directive],
+              glibcxx_cv_have_as_symver_directive, [
+  AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");],
+                [], glibcxx_cv_have_as_symver_directive=yes,
+                glibcxx_cv_have_as_symver_directive=no)])
+if test $glibcxx_cv_have_as_symver_directive = yes; then
+  AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1,
+    [Define to 1 if the target assembler supports .symver directive.])
+fi
+
 AC_SUBST(SYMVER_FILE)
 AC_SUBST(port_specific_symbol_files)
 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS, test $enable_symvers != no)
@@ -2816,6 +3040,51 @@ AC_DEFUN([GLIBCXX_ENABLE_THREADS], [
 ])
 
 
+dnl
+dnl Check if gthread implementation defines the types and functions
+dnl required by the c++0x thread library.  Conforming gthread
+dnl implementations can define __GTHREADS_CXX0X to enable use with c++0x.
+dnl
+AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+
+  ac_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS -fno-exceptions -I${toplevel_srcdir}/gcc"
+
+  target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
+  case $target_thread_file in
+    posix)
+      CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS"
+  esac
+
+  AC_MSG_CHECKING([for gthreads library])
+
+  AC_TRY_COMPILE([#include "gthr.h"],
+    [
+      #ifndef __GTHREADS_CXX0X
+      #error
+      #endif
+
+      // In case of POSIX threads check _POSIX_TIMEOUTS too.
+      #if (defined(_PTHREADS) \
+           && (!defined(_POSIX_TIMEOUTS) || _POSIX_TIMEOUTS <= 0))
+      #error
+      #endif
+    ], [ac_has_gthreads=yes], [ac_has_gthreads=no])
+
+  AC_MSG_RESULT([$ac_has_gthreads])
+
+  if test x"$ac_has_gthreads" = x"yes"; then
+    AC_DEFINE(_GLIBCXX_HAS_GTHREADS, 1,
+              [Define if gthreads library is available.])
+  fi
+
+  CXXFLAGS="$ac_save_CXXFLAGS"
+  AC_LANG_RESTORE
+])
+
+
 # Check whether LC_MESSAGES is available in <locale.h>.
 # Ulrich Drepper <drepper@cygnus.com>, 1995.
 #