+2011-05-28 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * acinclude.m4: Define GLIBCXX_CHECK_GET_NPROCS and
+ GLIBCXX_CHECK_SC_NPROCESSORS_ONLN.
+ * configure.ac: Use them. Increase minor version.
+ * configure: Regenerate.
+ * config.h.in: Regenerate.
+ * include/std/thread (thread::hardware_concurrency): Remove inline
+ definition.
+ * src/thread.cc (thread::hardware_concurrency): Define.
+ * config/abi/pre/gnu.ver: Export new symbol @3.4.17
+ * testsuite/util/testsuite_abi.cc: Add new version.
+ * testsuite/lib/libstdc++.exp (check_v3_target_nprocs): Add.
+ * testsuite/lib/dg-options.exp (dg-require-nprocs): Add.
+ * testsuite/30_threads/thread/members/hardware_concurrency.cc: Use
+ dg-require-nprocs and verify hardware_concurrency returns non-zero.
+
2011-05-28 Jonathan Wakely <jwakely.gcc@gmail.com>
* testsuite/20_util/pointer_traits/pointer_to.cc: New.
])
])
+dnl
+dnl Check whether get_nprocs is available in <sys/sysinfo.h>, and define _GLIBCXX_USE_GET_NPROCS.
+dnl
+AC_DEFUN([GLIBCXX_CHECK_GET_NPROCS], [
+
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
+
+ AC_MSG_CHECKING([for get_nprocs])
+ AC_CACHE_VAL(glibcxx_cv_GET_NPROCS, [
+ GCC_TRY_COMPILE_OR_LINK(
+ [#include <sys/sysinfo.h>],
+ [int n = get_nprocs();],
+ [glibcxx_cv_GET_NPROCS=yes],
+ [glibcxx_cv_GET_NPROCS=no])
+ ])
+ if test $glibcxx_cv_GET_NPROCS = yes; then
+ AC_DEFINE(_GLIBCXX_USE_GET_NPROCS, 1, [Define if get_nprocs is available in <sys/sysinfo.h>.])
+ fi
+ AC_MSG_RESULT($glibcxx_cv_GET_NPROCS)
+
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ AC_LANG_RESTORE
+])
+
+dnl
+dnl Check whether sysconf(_SC_NPROCESSORS_ONLN) is available in <unistd.h>, and define _GLIBCXX_USE_SC_NPROCESSORS_ONLN.
+dnl
+AC_DEFUN([GLIBCXX_CHECK_SC_NPROCESSORS_ONLN], [
+
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
+
+ AC_MSG_CHECKING([for _SC_NPROCESSORS_ONLN])
+ AC_CACHE_VAL(glibcxx_cv_SC_NPROCESSORS_ONLN, [
+ GCC_TRY_COMPILE_OR_LINK(
+ [#include <unistd.h>],
+ [int n = sysconf(_SC_NPROCESSORS_ONLN);],
+ [glibcxx_cv_SC_NPROCESSORS_ONLN=yes],
+ [glibcxx_cv_SC_NPROCESSORS_ONLN=no])
+ ])
+ if test $glibcxx_cv_SC_NPROCESSORS_ONLN = yes; then
+ AC_DEFINE(_GLIBCXX_USE_SC_NPROCESSORS_ONLN, 1, [Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>.])
+ fi
+ AC_MSG_RESULT($glibcxx_cv_SC_NPROCESSORS_ONLN)
+
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ AC_LANG_RESTORE
+])
+
+
# Macros from the top-level gcc directory.
m4_include([../config/gc++filt.m4])
m4_include([../config/tls.m4])
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
+/* Define to 1 if you have the <sys/sysinfo.h> header file. */
+#undef HAVE_SYS_SYSINFO_H
+
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Defined if gettimeofday is available. */
#undef _GLIBCXX_USE_GETTIMEOFDAY
+/* Define if get_nprocs is available in <sys/sysinfo.h>. */
+#undef _GLIBCXX_USE_GET_NPROCS
+
/* Define if LFS support is available. */
#undef _GLIBCXX_USE_LFS
/* Defined if sched_yield is available. */
#undef _GLIBCXX_USE_SCHED_YIELD
+/* Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>. */
+#undef _GLIBCXX_USE_SC_NPROCESSORS_ONLN
+
/* Define if code specialized for wchar_t should be used. */
#undef _GLIBCXX_USE_WCHAR_T
} GLIBCXX_3.4.15;
+GLIBCXX_3.4.17 {
+
+ # std::thread::hardware_concurrency
+ _ZNSt6thread20hardware_concurrencyEv;
+
+} GLIBCXX_3.4.16;
+
# Symbols in the support library (libsupc++) have their own tag.
CXXABI_1.3 {
### am handles this now? ORIGINAL_LD_FOR_MULTILIBS=$LD
# For libtool versioning info, format is CURRENT:REVISION:AGE
-libtool_VERSION=6:16:0
+libtool_VERSION=6:17:0
# Find the rest of the source tree framework.
+# For hardware_concurrency
+for ac_header in sys/sysinfo.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "sys/sysinfo.h" "ac_cv_header_sys_sysinfo_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_sysinfo_h" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_SYSINFO_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for get_nprocs" >&5
+$as_echo_n "checking for get_nprocs... " >&6; }
+ if test "${glibcxx_cv_GET_NPROCS+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ if test x$gcc_no_link = xyes; then
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/sysinfo.h>
+int
+main ()
+{
+int n = get_nprocs();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ glibcxx_cv_GET_NPROCS=yes
+else
+ glibcxx_cv_GET_NPROCS=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ if test x$gcc_no_link = xyes; then
+ as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/sysinfo.h>
+int
+main ()
+{
+int n = get_nprocs();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ glibcxx_cv_GET_NPROCS=yes
+else
+ glibcxx_cv_GET_NPROCS=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+
+fi
+
+ if test $glibcxx_cv_GET_NPROCS = yes; then
+
+$as_echo "#define _GLIBCXX_USE_GET_NPROCS 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_GET_NPROCS" >&5
+$as_echo "$glibcxx_cv_GET_NPROCS" >&6; }
+
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+for ac_header in unistd.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default"
+if test "x$ac_cv_header_unistd_h" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_UNISTD_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _SC_NPROCESSORS_ONLN" >&5
+$as_echo_n "checking for _SC_NPROCESSORS_ONLN... " >&6; }
+ if test "${glibcxx_cv_SC_NPROCESSORS_ONLN+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ if test x$gcc_no_link = xyes; then
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <unistd.h>
+int
+main ()
+{
+int n = sysconf(_SC_NPROCESSORS_ONLN);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ glibcxx_cv_SC_NPROCESSORS_ONLN=yes
+else
+ glibcxx_cv_SC_NPROCESSORS_ONLN=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ if test x$gcc_no_link = xyes; then
+ as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <unistd.h>
+int
+main ()
+{
+int n = sysconf(_SC_NPROCESSORS_ONLN);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ glibcxx_cv_SC_NPROCESSORS_ONLN=yes
+else
+ glibcxx_cv_SC_NPROCESSORS_ONLN=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+
+fi
+
+ if test $glibcxx_cv_SC_NPROCESSORS_ONLN = yes; then
+
+$as_echo "#define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_SC_NPROCESSORS_ONLN" >&5
+$as_echo "$glibcxx_cv_SC_NPROCESSORS_ONLN" >&6; }
+
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
# Check for available headers.
for ac_header in endian.h execinfo.h float.h fp.h ieeefp.h inttypes.h \
locale.h machine/endian.h machine/param.h nan.h stdint.h stdlib.h string.h \
### am handles this now? ORIGINAL_LD_FOR_MULTILIBS=$LD
# For libtool versioning info, format is CURRENT:REVISION:AGE
-libtool_VERSION=6:16:0
+libtool_VERSION=6:17:0
AC_SUBST(libtool_VERSION)
# Find the rest of the source tree framework.
AC_LC_MESSAGES
+# For hardware_concurrency
+AC_CHECK_HEADERS(sys/sysinfo.h)
+GLIBCXX_CHECK_GET_NPROCS
+AC_CHECK_HEADERS(unistd.h)
+GLIBCXX_CHECK_SC_NPROCESSORS_ONLN
+
# Check for available headers.
AC_CHECK_HEADERS([endian.h execinfo.h float.h fp.h ieeefp.h inttypes.h \
locale.h machine/endian.h machine/param.h nan.h stdint.h stdlib.h string.h \
// Returns a value that hints at the number of hardware thread contexts.
static unsigned int
- hardware_concurrency() noexcept
- { return 0; }
+ hardware_concurrency() noexcept;
private:
void
#include <thread>
#include <cerrno>
+#if defined(_GLIBCXX_USE_GET_NPROCS)
+# include <sys/sysinfo.h>
+# define _GLIBCXX_NPROCS get_nprocs()
+#elif defined(_GLIBCXX_USE_SC_NPROCESSORS_ONLN)
+# include <unistd.h>
+# define _GLIBCXX_NPROCS sysconf(_SC_NPROCESSORS_ONLN)
+#else
+# define _GLIBCXX_NPROCS 0
+#endif
+
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
namespace std _GLIBCXX_VISIBILITY(default)
}
}
+ unsigned int
+ thread::hardware_concurrency() noexcept
+ {
+ int __n = _GLIBCXX_NPROCS;
+ if (__n < 0)
+ __n = 0;
+ return __n;
+ }
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
+// { dg-require-nprocs "" }
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
{
bool test __attribute__((unused)) = true;
- // Current implementation punts on this.
- VERIFY( std::thread::hardware_concurrency() == 0 );
+ VERIFY( std::thread::hardware_concurrency() >= 1 );
return 0;
}
return
}
+proc dg-require-nprocs { args } {
+ if { ![ check_v3_target_nprocs ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
+ }
+ return
+}
+
proc add_options_for_no_pch { flags } {
# This forces any generated and possibly included PCH to be invalid.
return "-D__GLIBCXX__=99999999"
return $et_binary_io
}
+proc check_v3_target_nprocs { } {
+ global cxxflags
+ global DEFAULT_CXXFLAGS
+ global et_nprocs
+
+ global tool
+
+ if { ![info exists et_nprocs_target_name] } {
+ set et_nprocs_target_name ""
+ }
+
+ # If the target has changed since we set the cached value, clear it.
+ set current_target [current_target_name]
+ if { $current_target != $et_nprocs_target_name } {
+ verbose "check_v3_target_nprocs: `$et_nprocs_target_name'" 2
+ set et_nprocs_target_name $current_target
+ if [info exists et_nprocs] {
+ verbose "check_v3_target_nprocs: removing cached result" 2
+ unset et_nprocs
+ }
+ }
+
+ if [info exists et_nprocs] {
+ verbose "check_v3_target_nprocs: using cached result" 2
+ } else {
+ set et_nprocs 0
+
+ # Set up and preprocess a C++0x test program that depends
+ # on either get_nprocs or sysconf to be available.
+ set src nprocs[pid].cc
+
+ set f [open $src "w"]
+ puts $f "#include <bits/c++config.h>"
+ puts $f "#if defined(_GLIBCXX_USE_GET_NPROCS)"
+ puts $f "#elif defined(_GLIBCXX_USE_SYSCONF)"
+ puts $f "# include <unistd.h>"
+ puts $f "# if !defined(_SC_NPROCESSORS_ONLN)"
+ puts $f "# error No sysconf option"
+ puts $f "# endif"
+ puts $f "#else"
+ puts $f "# error No get_nprocs or sysconf"
+ puts $f "#endif"
+ close $f
+
+ set cxxflags_saved $cxxflags
+ set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
+
+ set lines [v3_target_compile $src /dev/null preprocess ""]
+ set cxxflags $cxxflags_saved
+ file delete $src
+
+ if [string match "" $lines] {
+ # No error message, preprocess succeeded.
+ set et_nprocs 1
+ } else {
+ verbose "check_v3_target_nprocs: compilation failed" 2
+ }
+ }
+ verbose "check_v3_target_nprocs: $et_nprocs" 2
+ return $et_nprocs
+}
+
+
set additional_prunes ""
known_versions.push_back("GLIBCXX_3.4.14");
known_versions.push_back("GLIBCXX_3.4.15");
known_versions.push_back("GLIBCXX_3.4.16");
+ known_versions.push_back("GLIBCXX_3.4.17");
known_versions.push_back("GLIBCXX_LDBL_3.4");
known_versions.push_back("GLIBCXX_LDBL_3.4.7");
known_versions.push_back("GLIBCXX_LDBL_3.4.10");