]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
thread: New.
authorChris Fairles <chris.fairles@gmail.com>
Sat, 13 Sep 2008 00:32:37 +0000 (00:32 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 13 Sep 2008 00:32:37 +0000 (00:32 +0000)
2008-09-12  Chris Fairles <chris.fairles@gmail.com>
    Benjamin Kosnik  <bkoz@redhat.com>

* include/std/thread: New.
* include/Makefile.am: Update.
* include/Makefile.in: Regenerate.
* src/thread.cc: New.
* src/Makefile.am: Update.
* src/Makefile.in: Regenerate.
* acinclude.m4: Add check for nanosleep.
* configure.ac: Call it.
* configure: Regenerate.
* config.h.in: Likewise.
* config/abi/pre/gnu.ver: Add exports.
* doc/doxygen/user.cfg.in: Add thread header.
* testsuite/lib/libstdc++.exp (check_v3_target_nanosleep): Add.
* testsuite/lib/dg-options.exp (dg-require-nanosleep): Add.
* testsuite/30_threads/thread/cons/1.cc: New.
* testsuite/30_threads/thread/cons/2.cc: Likewise.
* testsuite/30_threads/thread/cons/3.cc: Likewise.
* testsuite/30_threads/thread/cons/4.cc: Likewise.
* testsuite/30_threads/thread/algorithm/1.cc: Likewise.
* testsuite/30_threads/thread/algorithm/2.cc: Likewise.
* testsuite/30_threads/thread/member/1.cc: Likewise.
* testsuite/30_threads/thread/member/2.cc: Likewise.
* testsuite/30_threads/thread/member/3.cc: Likewise.
* testsuite/30_threads/thread/this_thread/1.cc: Likewise.
* testsuite/30_threads/thread/this_thread/2.cc: Likewise.
* testsuite/30_threads/thread/this_thread/3.cc: Likewise.
* testsuite/30_threads/thread/this_thread/4.cc: Likewise.
* testsuite/30_threads/headers/thread/types_std_c++0x.cc: Likewise.
* testsuite/30_threads/headers/thread/std_c++0x_neg.cc: Likewise.
* testsuite/17_intro/headers/c++200x/all.cc: Add thread.
* testsuite/17_intro/headers/c++200x/all_multiple_inclusion.cc:
Add thread, condition_variable and mutex.

Co-Authored-By: Benjamin Kosnik <bkoz@redhat.com>
From-SVN: r140332

31 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/acinclude.m4
libstdc++-v3/config.h.in
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/configure
libstdc++-v3/configure.ac
libstdc++-v3/include/Makefile.am
libstdc++-v3/include/Makefile.in
libstdc++-v3/include/std/thread [new file with mode: 0644]
libstdc++-v3/src/Makefile.am
libstdc++-v3/src/Makefile.in
libstdc++-v3/src/thread.cc [new file with mode: 0644]
libstdc++-v3/testsuite/17_intro/headers/c++200x/all.cc
libstdc++-v3/testsuite/17_intro/headers/c++200x/all_multiple_inclusion.cc
libstdc++-v3/testsuite/30_threads/headers/thread/std_c++0x_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/headers/thread/types_std_c++0x.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/algorithm/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/algorithm/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/cons/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/cons/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/cons/3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/cons/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/member/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/member/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/member/3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/this_thread/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/this_thread/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/this_thread/3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/thread/this_thread/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/lib/dg-options.exp
libstdc++-v3/testsuite/lib/libstdc++.exp

index 8b7cd469cfb7f0cb86166b1e0b891498f66d26c4..249eba7a9315055e55d50a77a1f93e3d17103df7 100644 (file)
@@ -1,3 +1,39 @@
+2008-09-12  Chris Fairles <chris.fairles@gmail.com>
+           Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/std/thread: New.
+       * include/Makefile.am: Update.
+       * include/Makefile.in: Regenerate.
+       * src/thread.cc: New.
+       * src/Makefile.am: Update.
+       * src/Makefile.in: Regenerate.
+       * acinclude.m4: Add check for nanosleep.
+       * configure.ac: Call it.
+       * configure: Regenerate.
+       * config.h.in: Likewise.
+       * config/abi/pre/gnu.ver: Add exports.
+       * doc/doxygen/user.cfg.in: Add thread header.
+       * testsuite/lib/libstdc++.exp (check_v3_target_nanosleep): Add.
+       * testsuite/lib/dg-options.exp (dg-require-nanosleep): Add.
+       * testsuite/30_threads/thread/cons/1.cc: New.
+       * testsuite/30_threads/thread/cons/2.cc: Likewise.
+       * testsuite/30_threads/thread/cons/3.cc: Likewise.
+       * testsuite/30_threads/thread/cons/4.cc: Likewise.
+       * testsuite/30_threads/thread/algorithm/1.cc: Likewise.
+       * testsuite/30_threads/thread/algorithm/2.cc: Likewise.
+       * testsuite/30_threads/thread/member/1.cc: Likewise.
+       * testsuite/30_threads/thread/member/2.cc: Likewise.
+       * testsuite/30_threads/thread/member/3.cc: Likewise.
+       * testsuite/30_threads/thread/this_thread/1.cc: Likewise.
+       * testsuite/30_threads/thread/this_thread/2.cc: Likewise.
+       * testsuite/30_threads/thread/this_thread/3.cc: Likewise.
+       * testsuite/30_threads/thread/this_thread/4.cc: Likewise.
+       * testsuite/30_threads/headers/thread/types_std_c++0x.cc: Likewise.
+       * testsuite/30_threads/headers/thread/std_c++0x_neg.cc: Likewise.
+       * testsuite/17_intro/headers/c++200x/all.cc: Add thread.
+       * testsuite/17_intro/headers/c++200x/all_multiple_inclusion.cc: 
+       Add thread, condition_variable and mutex.
+
 2008-09-10  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * src/ctype.cc (use_facet<ctype<char> >, use_facet<ctype<wchar_t>):
index 4936cc8cc4f6a8cbbed09805f57c85d3a2498177..bec563f0b4f3dcecd6b2007dfc692bba5977c391 100644 (file)
@@ -1200,6 +1200,39 @@ AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
   AC_LANG_RESTORE
 ])
 
+dnl
+dnl Check for nanosleep, used in the implementation of 30.2.2
+dnl [thread.thread.this] in the current C++0x working draft.
+dnl
+AC_DEFUN([GLIBCXX_CHECK_NANOSLEEP], [
+
+  AC_MSG_CHECKING([for nanosleep])
+
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+  ac_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS -fno-exceptions"
+
+  ac_has_nanosleep=no;
+  AC_CHECK_HEADERS(time.h, ac_has_time_h=yes, ac_has_time_h=no)
+  if test x"$ac_has_time_h" = x"yes"; then
+    AC_MSG_CHECKING([for nanosleep])
+    AC_TRY_COMPILE([#include <time.h>],                                                                                                         
+      [timespec ts; nanosleep(&ts, 0);],
+      [ac_has_nanosleep=yes], [ac_has_nanosleep=no])
+
+    AC_MSG_RESULT($ac_has_nanosleep)
+  fi
+
+  if test x"$ac_has_nanosleep" = x"yes"; then
+    AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
+      [ Defined if nanosleep is available. ])
+  fi
+
+  CXXFLAGS="$ac_save_CXXFLAGS"
+  AC_LANG_RESTORE
+])
+
 dnl
 dnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
 dnl facilities in Chapter 8, "C compatibility".
index 8e3b000fbd189ef86910c8159786cb283047366d..0cf3518b6399d318bd46eeecb86c79437b280b90 100644 (file)
 /* Define to 1 if you have the <tgmath.h> header file. */
 #undef HAVE_TGMATH_H
 
+/* Define to 1 if you have the <time.h> header file. */
+#undef HAVE_TIME_H
+
 /* Define to 1 if the target supports thread-local storage. */
 #undef HAVE_TLS
 
 /* Define if code specialized for long long should be used. */
 #undef _GLIBCXX_USE_LONG_LONG
 
+/* Defined if nanosleep is available. */
+#undef _GLIBCXX_USE_NANOSLEEP
+
 /* Define if NLS translations are to be used. */
 #undef _GLIBCXX_USE_NLS
 
index a3529baac9b0698dbcb9eaa49eef85b4f68774be..df69c87c3775561926259e1e83906a873c2dc9b8 100644 (file)
@@ -128,7 +128,11 @@ GLIBCXX_3.4 {
       std::strstream*;
       std::strstreambuf*;
 #     std::t[a-q]*;
-      std::t[a-n]*;
+      std::t[a-g]*;      
+      std::th[a-h]*;
+      std::th[j-q]*;
+      std::th[s-z]*;
+      std::t[i-n]*;
       std::tr1::h[^a]*;
       std::t[s-z]*;
 #     std::[A-Zu-z]*;
@@ -900,6 +904,23 @@ GLIBCXX_3.4.11 {
     _ZNSt22condition_variable_anyD1Ev;
     _ZNSt22condition_variable_anyD2Ev;
 
+    # thread
+    _ZNKSt6thread6get_idEv;
+    _ZNKSt6thread8joinableEv;
+    _ZNSt10shared_ptrISt18__thread_data_baseED1Ev;
+    _ZNSt11this_thread5yieldEv;
+    _ZNSt11this_thread6get_idEv;
+    _ZNSt12bad_weak_ptrD0Ev;
+    _ZNSt12bad_weak_ptrD1Ev;
+    _ZNSt6thread14__start_threadEv;
+    _ZNSt6thread4joinEv;
+    _ZNSt6thread4swapEOS_;
+    _ZNSt6thread6detachEv;
+    _ZNSt6threadC1Ev;
+    _ZNSt6threadC2Ev;
+    _ZNSt6threadD1Ev;
+    _ZNSt6threadD2Ev;
+
     # system_error
     _ZSt18get_posix_categoryv;
     _ZSt19get_system_categoryv;
index cf0c4247d43491cf6435629621428c6656cffd13..5f471504430e3d5315cba430c57c36c796fc677d 100755 (executable)
@@ -21736,6 +21736,246 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+# For nanosleep support
+
+
+  echo "$as_me:$LINENO: checking for nanosleep" >&5
+echo $ECHO_N "checking for nanosleep... $ECHO_C" >&6
+
+
+
+  ac_ext=cc
+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"
+
+  ac_has_nanosleep=no;
+
+for ac_header in time.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_cxx_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_cxx_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    (
+      cat <<\_ASBOX
+## ----------------------------------------- ##
+## Report this to the package-unused lists.  ##
+## ----------------------------------------- ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ ac_has_time_h=yes
+else
+  ac_has_time_h=no
+fi
+
+done
+
+  if test x"$ac_has_time_h" = x"yes"; then
+    echo "$as_me:$LINENO: checking for nanosleep" >&5
+echo $ECHO_N "checking for nanosleep... $ECHO_C" >&6
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <time.h>
+int
+main ()
+{
+timespec ts; nanosleep(&ts, 0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_cxx_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_has_nanosleep=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_has_nanosleep=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+    echo "$as_me:$LINENO: result: $ac_has_nanosleep" >&5
+echo "${ECHO_T}$ac_has_nanosleep" >&6
+  fi
+
+  if test x"$ac_has_nanosleep" = x"yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define _GLIBCXX_USE_NANOSLEEP 1
+_ACEOF
+
+  fi
+
+  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
+
+
+
 
   if test "${ac_cv_header_locale_h+set}" = set; then
   echo "$as_me:$LINENO: checking for locale.h" >&5
index ff388ab50c40bc7781c601102624540ced7fb4df..dca19cc42b0a4fc82bb1e6e63207607e5ac4c141 100644 (file)
@@ -153,6 +153,9 @@ GLIBCXX_ENABLE_CLOCK_GETTIME([no])
 # For gthread support
 GLIBCXX_CHECK_GTHREADS
 
+# For nanosleep support
+GLIBCXX_CHECK_NANOSLEEP
+
 AC_LC_MESSAGES
 
 # Check for available headers.
index d5f5fa2a119c9d8c19922e4a8f7d597ae40303b8..7b7e2c5944039a053f48f4749545785070387037 100644 (file)
@@ -63,6 +63,7 @@ std_headers = \
        ${std_srcdir}/streambuf \
        ${std_srcdir}/string \
        ${std_srcdir}/system_error \
+       ${std_srcdir}/thread \
        ${std_srcdir}/tuple \
        ${std_srcdir}/type_traits \
        ${std_srcdir}/unordered_map \
index a82b8843191d046ccaa255861137084b4b6b19e7..b86ac51bf1f14eb12783bfd727d5f4af54940059 100644 (file)
@@ -317,6 +317,7 @@ std_headers = \
        ${std_srcdir}/streambuf \
        ${std_srcdir}/string \
        ${std_srcdir}/system_error \
+       ${std_srcdir}/thread \
        ${std_srcdir}/tuple \
        ${std_srcdir}/type_traits \
        ${std_srcdir}/unordered_map \
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread
new file mode 100644 (file)
index 0000000..2a70100
--- /dev/null
@@ -0,0 +1,280 @@
+// <thread> -*- C++ -*-
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+/** @file thread
+ *  This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_THREAD
+#define _GLIBCXX_THREAD 1
+
+#pragma GCC system_header
+
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+# include <c++0x_warning.h>
+#else
+
+#include <chrono>
+#include <exception>
+#include <functional>
+#include <memory>
+#include <mutex>
+#include <condition_variable>
+#include <type_traits>
+#include <cstddef>
+#include <bits/functexcept.h>
+#include <bits/gthr.h>
+
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+
+namespace std
+{
+  class __thread_data_base;
+
+  typedef shared_ptr<__thread_data_base> __thread_data_ptr;
+
+  class __thread_data_base : public enable_shared_from_this<__thread_data_base>
+  {
+  public:
+    __thread_data_base() = default;
+    virtual ~__thread_data_base() = default;
+    
+    virtual void __run() const = 0;
+    
+    __gthread_t        _M_thread_handle;
+    __thread_data_ptr  _M_this_ptr;
+    mutex              _M_data_mutex;
+  };
+  
+  template<typename _Callable>
+    class __thread_data : public __thread_data_base
+    {
+    public:
+      __thread_data(_Callable&& __f)
+      : _M_func(std::forward<_Callable>(__f))
+      { }
+
+      void __run() const
+      { _M_func(); }
+
+    private:
+      _Callable _M_func;
+    };
+
+  /// thread
+  class thread
+  {
+  public:
+    // types
+    class id;
+    typedef __gthread_t native_handle_type;
+
+    // cons
+    thread();
+    
+    template<typename _Callable>
+      explicit thread(_Callable __f)
+      : _M_thread_data(__make_thread_data(__f))
+      { __start_thread(); }
+
+    template<typename _Callable, typename... _Args>
+      thread(_Callable&& __f, _Args&&... __args)
+      : _M_thread_data(__make_thread_data(std::bind(__f, __args...)))
+      { __start_thread(); }
+
+    ~thread();
+
+    thread(const thread&) = delete;
+    thread(thread&&);
+    thread& operator=(const thread&) = delete;
+    thread& operator=(thread&&);
+
+    // members
+    void 
+    swap(thread&& __t);
+
+    bool 
+    joinable() const;
+
+    void 
+    join();
+
+    void 
+    detach();
+
+    id
+    get_id() const;
+
+    native_handle_type 
+    native_handle()
+    { return _M_thread_data->_M_thread_handle; }
+
+    // static members
+    static unsigned hardware_concurrency();
+
+    __thread_data_ptr
+    _M_get_thread_data() const
+    {
+      lock_guard<mutex> __l(_M_thread_data_mutex);
+      return _M_thread_data;
+    }
+
+  private:
+    template<typename _Callable>
+      __thread_data_ptr 
+      __make_thread_data(_Callable&& __f)
+      { 
+       return __thread_data_ptr(
+         new __thread_data<_Callable>(std::forward<_Callable>(__f)));
+      }
+    
+    __thread_data_ptr
+    __make_thread_data(void(*__f)())
+    { return __thread_data_ptr(new __thread_data<void(*)()>(__f)); }
+    
+    void __start_thread();
+
+    __thread_data_ptr  _M_thread_data;
+    mutable mutex      _M_thread_data_mutex;
+  };
+
+  inline void
+  swap(thread& __x, thread& __y)
+  { __x.swap(__y); }
+
+  inline void
+  swap(thread&& __x, thread& __y)
+  { __x.swap(__y); }
+  
+  inline void
+  swap(thread& __x, thread&& __y)
+  { __x.swap(__y); }
+
+  namespace this_thread
+  {
+    thread::id
+    get_id();
+
+    void
+    yield();
+
+    template<typename _Clock, typename _Duration>
+      void
+      sleep_until(const chrono::time_point<_Clock, _Duration>& __atime)
+      {
+       sleep_for(__atime - _Clock::now());
+      }
+
+    template<typename _Rep, typename _Period>
+      void
+      sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
+      {
+       chrono::seconds __s =
+         chrono::duration_cast<chrono::seconds>(__rtime);
+
+       chrono::nanoseconds __ns =
+         chrono::duration_cast<chrono::nanoseconds>(__rtime - __s);
+
+       __gthread_time_t __ts = 
+         {
+           static_cast<std::time_t>(__s.count()),
+           static_cast<long>(__ns.count())
+         };
+
+#ifdef _GLIBCXX_USE_NANOSLEEP
+       ::nanosleep(&__ts, 0);
+#endif
+      }
+  }
+
+  /// thread::id
+  class thread::id
+  {
+  public:
+    id() : _M_thread_id() { }
+
+  private:
+    friend class thread;
+
+    friend thread::id this_thread::get_id();
+
+    friend bool 
+    operator==(thread::id __x, thread::id __y)
+    { 
+      return 
+       static_cast<bool>(__gthread_equal(__x._M_thread_id, __y._M_thread_id));
+    }
+
+    friend bool
+    operator<(thread::id __x, thread::id __y)
+    { return __x._M_thread_id < __y._M_thread_id; }
+
+    template<class _CharT, class _Traits>
+      friend basic_ostream<_CharT, _Traits>&
+      operator<<(basic_ostream<_CharT, _Traits>&& __out, thread::id __id); 
+
+    id(__gthread_t __id)
+    : _M_thread_id(__id)
+    { }
+      
+    __gthread_t _M_thread_id;
+  };
+
+  inline bool
+  operator!=(thread::id __x, thread::id __y)
+  { return !(__x == __y); }
+  
+  inline bool
+  operator<=(thread::id __x, thread::id __y)
+  { return !(__y < __x); }
+  
+  inline bool
+  operator>(thread::id __x, thread::id __y)
+  { return __y < __x; }
+  
+  inline bool
+  operator>=(thread::id __x, thread::id __y)
+  { return !(__x < __y); }
+  
+  template<class _CharT, class _Traits>
+    inline basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>&& __out, thread::id __id)
+    {
+      if(__id == thread::id())
+       return __out << "non-executing thread";
+      else
+       return __out << __id._M_thread_id;
+    }  
+}
+
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
+
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
+#endif // _GLIBCXX_THREAD
index cf4522fe28a09401b2ad30d691db39776190183c..4b086c6dc3407c31160d28f6d23e32ac1e2b3d27 100644 (file)
@@ -187,6 +187,7 @@ sources = \
        mutex.cc \
        condition_variable.cc \
        chrono.cc \
+       thread.cc \
        ${host_sources} \
        ${host_sources_extra} 
 
@@ -292,6 +293,11 @@ chrono.lo: chrono.cc
 chrono.o: chrono.cc
        $(CXXCOMPILE) -std=gnu++0x -c $<
 
+thread.lo: thread.cc
+       $(LTCXXCOMPILE) -std=gnu++0x -c $<
+thread.o: thread.cc
+       $(CXXCOMPILE) -std=gnu++0x -c $<
+
 if GLIBCXX_LDBL_COMPAT
 # Use special rules for compatibility-ldbl.cc compilation, as we need to
 # pass -mlong-double-64.
index 6c2030a845edf4fd511a8a273b92ff8d2ffe828d..50712547fe442951cc4924e85a9c7046f7367445 100644 (file)
@@ -86,7 +86,7 @@ am__libstdc___la_SOURCES_DIST = atomic.cc bitmap_allocator.cc \
        ostream-inst.cc sstream-inst.cc streambuf-inst.cc streambuf.cc \
        string-inst.cc valarray-inst.cc wlocale-inst.cc \
        wstring-inst.cc mutex.cc condition_variable.cc chrono.cc \
-       atomicity.cc codecvt_members.cc collate_members.cc \
+       thread.cc atomicity.cc codecvt_members.cc collate_members.cc \
        ctype_members.cc messages_members.cc monetary_members.cc \
        numeric_members.cc time_members.cc basic_file.cc c++locale.cc \
        compatibility-ldbl.cc parallel_list.cc parallel_settings.cc
@@ -111,7 +111,7 @@ am__objects_5 = atomic.lo bitmap_allocator.lo pool_allocator.lo \
        ostream-inst.lo sstream-inst.lo streambuf-inst.lo streambuf.lo \
        string-inst.lo valarray-inst.lo wlocale-inst.lo \
        wstring-inst.lo mutex.lo condition_variable.lo chrono.lo \
-       $(am__objects_1) $(am__objects_4)
+       thread.lo $(am__objects_1) $(am__objects_4)
 am_libstdc___la_OBJECTS = $(am__objects_5)
 libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
@@ -425,6 +425,7 @@ sources = \
        mutex.cc \
        condition_variable.cc \
        chrono.cc \
+       thread.cc \
        ${host_sources} \
        ${host_sources_extra} 
 
@@ -889,6 +890,11 @@ chrono.lo: chrono.cc
 chrono.o: chrono.cc
        $(CXXCOMPILE) -std=gnu++0x -c $<
 
+thread.lo: thread.cc
+       $(LTCXXCOMPILE) -std=gnu++0x -c $<
+thread.o: thread.cc
+       $(CXXCOMPILE) -std=gnu++0x -c $<
+
 # Use special rules for compatibility-ldbl.cc compilation, as we need to
 # pass -mlong-double-64.
 @GLIBCXX_LDBL_COMPAT_TRUE@compatibility-ldbl.lo: compatibility-ldbl.cc
diff --git a/libstdc++-v3/src/thread.cc b/libstdc++-v3/src/thread.cc
new file mode 100644 (file)
index 0000000..b869e07
--- /dev/null
@@ -0,0 +1,139 @@
+// thread -*- C++ -*-
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <thread>
+#include <bits/move.h> // std::move
+
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+
+namespace std
+{
+  namespace 
+  {
+    extern "C"
+    {
+      void* __thread_proxy(void* __p)
+      {
+       __thread_data_base* __t = static_cast<__thread_data_base*>(__p);
+       __thread_data_ptr __local_thread_data = __t->_M_this_ptr;
+       __t->_M_this_ptr.reset();
+
+       try
+         {
+           __local_thread_data->__run();
+         }
+       catch(...)
+         {
+           std::terminate();
+         }
+
+       return 0;
+      }
+    }
+  }
+
+  thread::thread()
+  { }
+
+  thread::~thread()
+  {
+    detach();
+  }
+
+  thread::id
+  thread::get_id() const
+  {
+    if(_M_thread_data)
+      return thread::id(_M_thread_data->_M_thread_handle); 
+    else
+      return thread::id();
+  }
+
+  bool
+  thread::joinable() const
+  { return get_id() != id(); }
+  
+  void
+  thread::join()
+  {
+    if(joinable())
+      {
+       void* __r = 0;
+       int __e = __gthread_join(_M_thread_data->_M_thread_handle, &__r);
+       if(__e)
+         __throw_system_error(__e);
+
+       lock_guard<mutex> __lock(_M_thread_data_mutex);
+       _M_thread_data.reset();
+      }
+  }
+
+  void
+  thread::detach()
+  {    
+    if(joinable())
+      {
+       int __e = __gthread_detach(_M_thread_data->_M_thread_handle);
+       if(__e)
+         __throw_system_error(__e);
+
+       lock_guard<mutex> __lock(_M_thread_data_mutex);
+       _M_thread_data.reset();
+      }
+  }
+
+  void
+  thread::swap(thread&& __t)
+  {
+    std::swap(_M_thread_data, __t._M_thread_data);
+  }
+
+  void 
+  thread::__start_thread()
+  {
+    _M_thread_data->_M_this_ptr = _M_thread_data;
+    int __e = __gthread_create(&_M_thread_data->_M_thread_handle, 
+                              &__thread_proxy, _M_thread_data.get());
+    if(__e)
+      __throw_system_error(__e);
+  }
+
+  namespace this_thread
+  {
+    thread::id
+    get_id()
+    { return thread::id(__gthread_self()); }
+    
+    void
+    yield()
+    { __gthread_yield(); }   
+  }
+}
+
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
index 4c2e31be081325993599e5cd2a78982b4d83752f..9a4ff7262315e298e30f2f8b3d93c8e2f4910efb 100644 (file)
@@ -96,8 +96,8 @@
 #include <array>
 #include <bitset>
 #include <chrono>
-#include <condition_variable>
 #include <complex>
+#include <condition_variable>
 #include <deque>
 #include <exception>
 #include <fstream>
 #include <streambuf>
 #include <string>
 #include <system_error>
+#include <thread>
 #include <tuple>
 #include <typeinfo>
 #include <type_traits>
index f88edc8268a2fa822bf9f51127262c5a0082c652..7402cf747fb7dbc8aa71f43ff0cdaeec0f3fa3f0 100644 (file)
@@ -95,6 +95,7 @@
 #include <bitset>
 #include <chrono>
 #include <complex>
+#include <condition_variable>
 #include <deque>
 #include <exception>
 #include <fstream>
 #include <locale>
 #include <map>
 #include <memory>
+#include <mutex>
 #include <new>
 #include <numeric>
 #include <ostream>
 #include <stdexcept>
 #include <streambuf>
 #include <string>
+#include <thread>
 #include <tuple>
 #include <typeinfo>
 #include <type_traits>
 #include <bitset>
 #include <chrono>
 #include <complex>
+#include <condition_variable>
 #include <deque>
 #include <exception>
 #include <fstream>
 #include <stdexcept>
 #include <streambuf>
 #include <string>
+#include <thread>
 #include <tuple>
 #include <typeinfo>
 #include <type_traits>
diff --git a/libstdc++-v3/testsuite/30_threads/headers/thread/std_c++0x_neg.cc b/libstdc++-v3/testsuite/30_threads/headers/thread/std_c++0x_neg.cc
new file mode 100644 (file)
index 0000000..a8abba3
--- /dev/null
@@ -0,0 +1,26 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++98" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <thread>  // { dg-excess-errors "In file included from" }
+
+// { dg-error "upcoming ISO" "" { target *-*-* } 36 }
diff --git a/libstdc++-v3/testsuite/30_threads/headers/thread/types_std_c++0x.cc b/libstdc++-v3/testsuite/30_threads/headers/thread/types_std_c++0x.cc
new file mode 100644 (file)
index 0000000..cc69b1b
--- /dev/null
@@ -0,0 +1,31 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <thread>
+
+void test01()
+{
+  typedef std::thread t_t;
+
+  using namespace std::this_thread;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/algorithm/1.cc b/libstdc++-v3/testsuite/30_threads/thread/algorithm/1.cc
new file mode 100644 (file)
index 0000000..950ffb3
--- /dev/null
@@ -0,0 +1,67 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <thread>
+#include <system_error>
+#include <bits/move.h> // std::move
+#include <testsuite_hooks.h>
+
+void f() { }
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+       std::thread t1(f);
+       std::thread::id t1_id = t1.get_id();
+       
+       std::thread t2;
+       t2.swap(std::move(t1));
+       
+       VERIFY( t1.get_id() == std::thread::id() );
+       VERIFY( t2.get_id() == t1_id ); 
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/algorithm/2.cc b/libstdc++-v3/testsuite/30_threads/thread/algorithm/2.cc
new file mode 100644 (file)
index 0000000..f587aac
--- /dev/null
@@ -0,0 +1,115 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <thread>
+#include <system_error>
+#include <bits/move.h> // std::move
+#include <testsuite_hooks.h>
+
+void f() { }
+
+void test01()
+{
+  try
+    {
+      std::thread t1(f);
+      std::thread::id t1_id = t1.get_id();
+      
+      std::thread t2;
+      std::swap(t1, t2);
+      
+      VERIFY( t1.get_id() == std::thread::id() );
+      VERIFY( t2.get_id() == t1_id );
+    }
+ catch (const std::system_error&)
+   {
+     VERIFY( false );
+   }
+ catch (...)
+   {
+     VERIFY( false );
+   }  
+}
+
+void test02()
+{
+  try
+    {
+      std::thread t1(f);
+      std::thread::id t1_id = t1.get_id();
+
+      std::thread t2;
+      std::swap(std::move(t1), t2);
+
+      VERIFY( t2.get_id() == t1_id );
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+}
+
+void test03()
+{
+  try
+    {
+      std::thread t1(f);
+      std::thread::id t1_id = t1.get_id();
+
+      std::thread t2;
+      std::swap(t2, std::move(t1));
+
+      VERIFY( t2.get_id() == t1_id );
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+}
+
+int main()
+{
+  test01();
+  test02();
+  test03();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/1.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/1.cc
new file mode 100644 (file)
index 0000000..a631e7e
--- /dev/null
@@ -0,0 +1,58 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+      std::thread t;
+      VERIFY( !t.joinable() );
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/2.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/2.cc
new file mode 100644 (file)
index 0000000..e53b088
--- /dev/null
@@ -0,0 +1,74 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <utility> // std::ref
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+void
+free_function(std::thread::id& id)
+{
+  id = std::this_thread::get_id();
+}
+
+void test02()
+{
+  bool test __attribute__((unused)) = true;
+
+  try
+    {
+      std::thread::id t1_id1;
+      std::thread t1(free_function, std::ref(t1_id1));
+      std::thread::id t1_id2 = t1.get_id();
+      VERIFY( t1.joinable() );
+      t1.join();      
+      VERIFY( !t1.joinable() );
+      VERIFY( t1_id1 == t1_id2 );
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+}
+
+int main()
+{
+  test02();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/3.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/3.cc
new file mode 100644 (file)
index 0000000..3df7ad0
--- /dev/null
@@ -0,0 +1,98 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <functional> // std::unary_function
+#include <utility> // std::ref
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+struct copyable : public std::unary_function<std::thread::id&, void>
+{
+  copyable() = default;
+  ~copyable() = default;
+  copyable(const copyable& c)
+  { ++copy_count; }
+
+  void operator()(std::thread::id& id) const
+  {
+    id = std::this_thread::get_id();
+  }
+
+  static int copy_count;
+};
+
+int copyable::copy_count = 0;
+
+void test03()
+{
+  bool test __attribute__((unused)) = true;
+
+  try
+    {
+      std::thread::id t1_id1;
+      copyable c1;
+      std::thread t1(std::ref(c1), std::ref(t1_id1));
+      std::thread::id t1_id2 = t1.get_id();
+      VERIFY( t1.joinable() );
+      t1.join();
+      VERIFY( !t1.joinable() );
+      VERIFY( t1_id1 == t1_id2 );
+      VERIFY( copyable::copy_count == 0 );
+
+      std::thread::id t2_id1;
+      copyable c2;
+      std::thread t2(c2, std::ref(t2_id1));
+      std::thread::id t2_id2 = t2.get_id();
+      VERIFY( t2.joinable() );
+      t2.join();
+      VERIFY( !t2.joinable() );
+      VERIFY( t2_id1 == t2_id2 );
+      VERIFY( copyable::copy_count > 0 );
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+}
+
+int main()
+{
+  test03();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/4.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/4.cc
new file mode 100644 (file)
index 0000000..76fc9ec
--- /dev/null
@@ -0,0 +1,91 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <functional> // std::unary_function
+#include <utility> // std::ref, std::cref
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+struct noncopyable : std::unary_function<std::thread::id&, void>
+{
+  noncopyable() = default;
+  ~noncopyable() = default;
+  noncopyable(const noncopyable&) = delete;
+  noncopyable& operator=(const noncopyable&) = delete;
+  void operator()(std::thread::id& id) const
+  { 
+    id = std::this_thread::get_id();
+  }
+};
+
+void test03()
+{
+  bool test __attribute__((unused)) = true;
+
+  try
+    {
+      std::thread::id t1_id1;
+      noncopyable nc1;
+      std::thread t1(std::ref(nc1), std::ref(t1_id1));
+      std::thread::id t1_id2 = t1.get_id();
+      VERIFY( t1.joinable() );
+      t1.join();
+      VERIFY( !t1.joinable() );
+      VERIFY( t1_id1 == t1_id2 );
+
+      std::thread::id t2_id1;
+      noncopyable nc2;
+      std::thread t2(std::cref(nc2), std::ref(t2_id1));
+      std::thread::id t2_id2 = t2.get_id();
+      VERIFY( t2.joinable() );
+      t2.join();
+      VERIFY( !t2.joinable() );
+      VERIFY( t2_id1 == t2_id2 );
+    }
+  catch(const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch(...)
+    {
+      VERIFY( false );
+    }
+}
+
+int main()
+{
+  test03();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/member/1.cc b/libstdc++-v3/testsuite/30_threads/thread/member/1.cc
new file mode 100644 (file)
index 0000000..a184cf1
--- /dev/null
@@ -0,0 +1,62 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+void f() { }
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+       std::thread t(f);
+       VERIFY( t.joinable() );
+       t.join();
+       VERIFY( !t.joinable() );
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/member/2.cc b/libstdc++-v3/testsuite/30_threads/thread/member/2.cc
new file mode 100644 (file)
index 0000000..f63313a
--- /dev/null
@@ -0,0 +1,62 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+void f() { }
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+       std::thread t(f);
+       VERIFY( t.joinable() );
+       t.detach();
+       VERIFY( !t.joinable() );
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/member/3.cc b/libstdc++-v3/testsuite/30_threads/thread/member/3.cc
new file mode 100644 (file)
index 0000000..cc52c32
--- /dev/null
@@ -0,0 +1,62 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+void f() { }
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+       std::thread t(f);
+       VERIFY( t.get_id() != std::thread::id() );
+       t.join();
+       VERIFY( t.get_id() == std::thread::id() );
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/this_thread/1.cc b/libstdc++-v3/testsuite/30_threads/thread/this_thread/1.cc
new file mode 100644 (file)
index 0000000..c012ea9
--- /dev/null
@@ -0,0 +1,58 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+      std::thread::id id = std::this_thread::get_id();
+      VERIFY( id != std::thread::id() );      
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/this_thread/2.cc b/libstdc++-v3/testsuite/30_threads/thread/this_thread/2.cc
new file mode 100644 (file)
index 0000000..cf60c2c
--- /dev/null
@@ -0,0 +1,57 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+      std::this_thread::yield();
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/this_thread/3.cc b/libstdc++-v3/testsuite/30_threads/thread/this_thread/3.cc
new file mode 100644 (file)
index 0000000..335e410
--- /dev/null
@@ -0,0 +1,72 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-nanosleep "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <chrono>
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+namespace chr = std::chrono;
+
+void foo()
+{
+  chr::system_clock::time_point begin = chr::system_clock::now();
+  chr::microseconds ms(500);
+
+  std::this_thread::sleep_for(ms);
+  
+  VERIFY( (chr::system_clock::now() - begin) >= ms );
+}
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+      std::thread t(foo);
+      t.join();
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/thread/this_thread/4.cc b/libstdc++-v3/testsuite/30_threads/thread/this_thread/4.cc
new file mode 100644 (file)
index 0000000..3612779
--- /dev/null
@@ -0,0 +1,72 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-nanosleep "" }
+
+// Copyright (C) 2008 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <chrono>
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+namespace chr = std::chrono;
+
+void foo()
+{
+  chr::system_clock::time_point begin = chr::system_clock::now();
+  chr::microseconds ms(500);
+
+  std::this_thread::sleep_until(chr::system_clock::now() + ms);
+  
+  VERIFY( (chr::system_clock::now() - begin) >= ms );
+}
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  try 
+    {
+      std::thread t(foo);
+      t.join();
+    }
+  catch (const std::system_error&)
+    {
+      VERIFY( false );
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  return 0;
+}
index 927aa47a58c6aeac6dad8170211744221b48343e..0f1bfcfe559fdc37c1358d69cfad8708956e0c4c 100644 (file)
@@ -115,3 +115,12 @@ proc dg-require-gthreads { args } {
     }
     return
 }
+
+proc dg-require-nanosleep { args } {
+    if { ![ check_v3_target_nanosleep ] } {
+        upvar dg-do-what dg-do-what
+        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+        return
+    }
+    return
+}
index 23060b4cc866b6a62bca0f144f27096c42172a54..10eac6294b51e25b85726e29328f121d8c423117 100644 (file)
@@ -1178,3 +1178,61 @@ proc check_v3_target_gthreads { } {
     verbose "check_v3_target_gthreads: $et_gthreads" 2
     return $et_gthreads
 }
+
+proc check_v3_target_nanosleep { } {
+    global cxxflags
+    global DEFAULT_CXXFLAGS
+    global et_nanosleep
+
+    global tool
+
+    if { ![info exists et_nanosleep_target_name] } {
+        set et_nanosleep_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_nanosleep_target_name } {
+        verbose "check_v3_target_nanosleep: `$et_nanosleep_target_name'" 2
+        set et_nanosleep_target_name $current_target
+        if [info exists et_nanosleep] {
+            verbose "check_v3_target_nanosleep: removing cached result" 2
+            unset et_nanosleep
+        }
+    }
+
+    if [info exists et_nanosleep] {
+        verbose "check_v3_target_nanosleep: using cached result" 2
+    } else {
+        set et_nanosleep 0
+       
+       # Set up and compile a C++0x test program that depends
+        # on the nanosleep facilities to be available.
+        set src nanosleep[pid].cc
+        set exe nanosleep[pid].exe
+
+        set f [open $src "w"]
+        puts $f "#include <bits/c++config.h>"
+        puts $f "int main()"
+        puts $f "#ifdef _GLIBCXX_USE_NANOSLEEP"
+        puts $f "{ return 0; }"
+        puts $f "#endif"
+        close $f
+
+        set cxxflags_saved $cxxflags
+        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
+
+        set lines [v3_target_compile $src $exe executable ""]
+        set cxxflags $cxxflags_saved
+        file delete $src
+
+        if [string match "" $lines] {
+            # No error message, compilation succeeded.
+            set et_nanosleep 1
+        } else {
+            verbose "check_v3_target_nanosleep: compilation failed" 2
+        }
+    }
+    verbose "check_v3_target_nanosleep: $et_nanosleep" 2
+    return $et_nanosleep
+}