public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-8295] testsuite: Add dg-require-atomic-cmpxchg-word
@ 2024-02-07 17:35 Torbjorn Svensson
  0 siblings, 0 replies; only message in thread
From: Torbjorn Svensson @ 2024-02-07 17:35 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:fa0e0c28ee8f6ca2f8d5c50737647bef734dc898

commit r13-8295-gfa0e0c28ee8f6ca2f8d5c50737647bef734dc898
Author: Hans-Peter Nilsson <hp@axis.com>
Date:   Wed Oct 4 03:40:25 2023 +0200

    testsuite: Add dg-require-atomic-cmpxchg-word
    
    Some targets (armv6-m) support inline atomic load and store,
    i.e. dg-require-thread-fence matches, but not atomic operations like
    compare and exchange.
    
    This directive can be used to replace uses of dg-require-thread-fence
    where an atomic operation is actually used.
    
            * testsuite/lib/dg-options.exp (dg-require-atomic-cmpxchg-word):
            New proc.
            * testsuite/lib/libstdc++.exp (check_v3_target_atomic_cmpxchg_word):
            Ditto.
    
    (cherry picked from commit 2a4d9e4f533c77870cc0eb60fbbd8047da4c7386)

Diff:
---
 libstdc++-v3/testsuite/lib/dg-options.exp |  9 ++++++++
 libstdc++-v3/testsuite/lib/libstdc++.exp  | 37 +++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 15e34f8a6461..f7d5b05d6ed7 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -133,6 +133,15 @@ proc dg-require-thread-fence { args } {
     return
 }
 
+proc dg-require-atomic-cmpxchg-word { args } {
+    if { ![ check_v3_target_atomic_cmpxchg_word ] } {
+	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 6412b2826b6d..6c57cfab725e 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1110,6 +1110,43 @@ proc check_v3_target_thread_fence { } {
     }]
 }
 
+proc check_v3_target_atomic_cmpxchg_word { } {
+    return [check_v3_target_prop_cached et_atomic_cmpxchg_word {
+	global cxxflags
+	global DEFAULT_CXXFLAGS
+
+	# Set up and link a C++11 test program that depends on
+	# atomic-compare-exchange being available for a pointer-sized
+	# integer.  It should be sufficient as gcc can derive all
+	# other operations when a target implements this operation.
+	set src atomic_cmpxchg_word[pid].cc
+
+	set f [open $src "w"]
+	puts $f "
+	__UINTPTR_TYPE__ i, j, k;
+	int main() {
+	__atomic_compare_exchange (&i, &j, &k, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+	return 0;
+	}"
+	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.
+	    return 1
+	} else {
+	    verbose "check_v3_target_atomic_cmpxchg_word: compilation failed" 2
+	    return 0
+	}
+    }]
+}
+
 # Return 1 if atomics_bool and atomic_int are always lock-free, 0 otherwise.
 proc check_v3_target_atomic_builtins { } {
     return [check_v3_target_prop_cached et_atomic_builtins {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-07 17:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 17:35 [gcc r13-8295] testsuite: Add dg-require-atomic-cmpxchg-word Torbjorn Svensson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).