[PATCH][libstc++v3]Add new dg-require-thread-fence directive.
authorRenlin Li <renlin.li@arm.com>
Wed, 22 Apr 2015 14:01:02 +0000 (14:01 +0000)
committerRenlin Li <renlin@gcc.gnu.org>
Wed, 22 Apr 2015 14:01:02 +0000 (14:01 +0000)
libstdc++-v3/

2015-04-22  Renlin Li  <renlin.li@arm.com>

* testsuite/lib/dg-options.exp (dg-require-thread-fence): New.
* testsuite/lib/libstdc++.exp (check_v3_target_thread_fence): New.
* testsuite/29_atomics/atomic_flag/clear/1.cc: Use it.
* testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc: Likewise.
* testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc: Likewise.

From-SVN: r222324

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc
libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc
libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc
libstdc++-v3/testsuite/lib/dg-options.exp
libstdc++-v3/testsuite/lib/libstdc++.exp

index f285f8c2fccd3e357ab8ac60fbdeb8944bbc870c..12f87c35b11737ca7bd703fc10c44d6a8635f06a 100644 (file)
@@ -1,3 +1,11 @@
+2015-04-22  Renlin Li  <renlin.li@arm.com>
+
+       * testsuite/lib/dg-options.exp (dg-require-thread-fence): New.
+       * testsuite/lib/libstdc++.exp (check_v3_target_thread_fence): New.
+       * testsuite/29_atomics/atomic_flag/clear/1.cc: Use it.
+       * testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc: Likewise.
+       * testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc: Likewise.
+
 2015-04-21  Jonathan Wakely  <jwakely@redhat.com>
 
        * doc/xml/manual/configure.xml: Update descriptions of options
index 0a4219c17a81fca0953f3e772ab8bdadbcd93df7..a6e229945e324b9f6517138f2bf492491e49e78e 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-options "-std=gnu++11" }
+// { dg-require-thread-fence "" }
 
 // Copyright (C) 2009-2015 Free Software Foundation, Inc.
 //
index 2ff740b57793c0d5a0079eb5b15b910e324db397..0655be41d2ddbca5c186a4ade3e51abe08dea7fc 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-options "-std=gnu++11" }
+// { dg-require-thread-fence "" }
 
 // Copyright (C) 2008-2015 Free Software Foundation, Inc.
 //
index 6ac20c077b574b6f801151dafa4aa3aabe3032f1..a867da2edfc425bf5d349b21e7fb64e04d83f4b4 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-options "-std=gnu++11" }
+// { dg-require-thread-fence "" }
 
 // Copyright (C) 2008-2015 Free Software Foundation, Inc.
 //
index 38c8206ad445c19f16b5087249e8496c7a0b3fa0..56ca89617aba06430067bf146838517ee241b331 100644 (file)
@@ -115,6 +115,15 @@ proc dg-require-cmath { args } {
     return
 }
 
+proc dg-require-thread-fence { args } {
+    if { ![ check_v3_target_thread_fence ] } {
+       upvar dg-do-what dg-do-what
+       set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+       return
+    }
+    return
+}
+
 proc dg-require-atomic-builtins { args } {
     if { ![ check_v3_target_atomic_builtins ] } {
        upvar dg-do-what dg-do-what
index b2f7d0030af7963b5dacc6bb56ddb911b2b02850..6a6374a8e6baa951d71a9919fb20d15b1a1f9d64 100644 (file)
@@ -1221,6 +1221,62 @@ proc check_v3_target_cmath { } {
     return $et_c99_math
 }
 
+proc check_v3_target_thread_fence { } {
+    global cxxflags
+    global DEFAULT_CXXFLAGS
+    global et_thread_fence
+
+    global tool
+
+    if { ![info exists et_thread_fence_target_name] } {
+       set et_thread_fence_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_thread_fence_target_name } {
+       verbose "check_v3_target_thread_fence: `$et_thread_fence_target_name'" 2
+       set et_thread_fence_target_name $current_target
+       if [info exists et_thread_fence] {
+           verbose "check_v3_target_thread_fence: removing cached result" 2
+           unset et_thread_fence
+       }
+    }
+
+    if [info exists et_thread_fence] {
+       verbose "check_v3_target_thread_fence: using cached result" 2
+    } else {
+       set et_thread_fence 0
+
+       # Set up and preprocess a C++11 test program that depends
+       # on the thread fence to be available.
+       set src thread_fence[pid].cc
+
+       set f [open $src "w"]
+       puts $f "int main() {"
+       puts $f "__atomic_thread_fence (__ATOMIC_SEQ_CST);"
+       puts $f "return 0;"
+       puts $f "}"
+       close $f
+
+       set cxxflags_saved $cxxflags
+       set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11"
+
+       set lines [v3_target_compile $src /dev/null executable ""]
+       set cxxflags $cxxflags_saved
+       file delete $src
+
+       if [string match "" $lines] {
+           # No error message, linking succeeded.
+           set et_thread_fence 1
+       } else {
+           verbose "check_v3_target_thread_fence: compilation failed" 2
+       }
+    }
+    verbose "check_v3_target_thread_fence: $et_thread_fence" 2
+    return $et_thread_fence
+}
+
 proc check_v3_target_atomic_builtins { } {
     global cxxflags
     global DEFAULT_CXXFLAGS