From: Renlin Li Date: Wed, 22 Apr 2015 14:01:02 +0000 (+0000) Subject: [PATCH][libstc++v3]Add new dg-require-thread-fence directive. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=04934297b8b00232358a54205a53f55f9e292c89;p=gcc.git [PATCH][libstc++v3]Add new dg-require-thread-fence directive. libstdc++-v3/ 2015-04-22 Renlin Li * 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f285f8c2fcc..12f87c35b11 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2015-04-22 Renlin Li + + * 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 * doc/xml/manual/configure.xml: Update descriptions of options diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc b/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc index 0a4219c17a8..a6e229945e3 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++11" } +// { dg-require-thread-fence "" } // Copyright (C) 2009-2015 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc b/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc index 2ff740b5779..0655be41d2d 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++11" } +// { dg-require-thread-fence "" } // Copyright (C) 2008-2015 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc b/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc index 6ac20c077b5..a867da2edfc 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++11" } +// { dg-require-thread-fence "" } // Copyright (C) 2008-2015 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 38c8206ad44..56ca89617ab 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -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 diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index b2f7d0030af..6a6374a8e6b 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -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