public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Christophe Lyon <christophe.lyon@linaro.org>
To: Hans-Peter Nilsson <hp@axis.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, jwakely@redhat.com
Subject: Re: Ping: [PATCH v2 1/2] testsuite: Add dg-require-atomic-cmpxchg-word
Date: Thu, 12 Oct 2023 16:38:54 +0200	[thread overview]
Message-ID: <CAPS5khY-T=SNW0wCt3wCeiktFdyx3YtcA6H993jejUjd1PA2iQ@mail.gmail.com> (raw)
In-Reply-To: <20231012022152.2321F203F1@pchp3.se.axis.com>

LGTM but I'm not a maintainer ;-)

On Thu, 12 Oct 2023 at 04:21, Hans-Peter Nilsson <hp@axis.com> wrote:
>
> Ping.
>
> > From: Hans-Peter Nilsson <hp@axis.com>
> > Date: Wed, 4 Oct 2023 19:04:55 +0200
> >
> > > From: Hans-Peter Nilsson <hp@axis.com>
> > > Date: Wed, 4 Oct 2023 17:15:28 +0200
> >
> > > New version coming up.
> >
> > Using pointer-sized int instead of int,
> > __atomic_compare_exchange instead of __atomic_exchange,
> > renamed to atomic-cmpxchg-word from atomic-exchange, and
> > updating a comment that already seemed reasonably well
> > placed.
> >
> > Tested as with v1 1/2.
> >
> > Ok to commit?
> >
> > -- >8 --
> > 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.
> > ---
> >  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 84ad0c65330b..850442b6b7c1 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 608056e5068e..4bedb36dc6f9 100644
> > --- a/libstdc++-v3/testsuite/lib/libstdc++.exp
> > +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
> > @@ -1221,6 +1221,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 {
> > --
> > 2.30.2
> >

  reply	other threads:[~2023-10-12 14:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230926143439.B589920431@pchp3.se.axis.com>
     [not found] ` <CAPS5khYXtGYLr-pqAQRy_UAsOJATted1Gs0xY4ytTWppFPVJaQ@mail.gmail.com>
2023-10-04  2:55   ` [PATCH 1/2] testsuite: Add dg-require-atomic-exchange non-atomic code Hans-Peter Nilsson
2023-10-04  8:13     ` Jonathan Wakely
2023-10-04  3:11   ` [PATCH 2/2] testsuite: Replace many dg-require-thread-fence with dg-require-atomic-exchange Hans-Peter Nilsson
2023-10-04  8:29     ` Jonathan Wakely
2023-10-04 15:15       ` Hans-Peter Nilsson
2023-10-04 16:01         ` Jonathan Wakely
2023-10-04 17:04         ` [PATCH v2 1/2] testsuite: Add dg-require-atomic-cmpxchg-word Hans-Peter Nilsson
2023-10-12  2:21           ` Ping: " Hans-Peter Nilsson
2023-10-12 14:38             ` Christophe Lyon [this message]
2023-10-12 16:10               ` Jeff Law
2023-10-12 22:23                 ` Jonathan Wakely
2024-02-07 16:31                   ` Torbjorn SVENSSON
2024-02-07 16:33                     ` Jonathan Wakely
2024-02-07 17:37                       ` Torbjorn SVENSSON
2023-10-04 17:08         ` [PATCH v2 2/2] testsuite: Replace many dg-require-thread-fence with dg-require-atomic-cmpxchg-word Hans-Peter Nilsson
2023-10-12  2:22           ` Ping: " Hans-Peter Nilsson
2023-10-12 14:40             ` Christophe Lyon
     [not found]   ` <20231003151633.CADF520410@pchp3.se.axis.com>
     [not found]     ` <CAPS5khY5fNB+AuOJOJPT7U6SgyfnvBKc+PNE4jY9oVG7UNOTCg@mail.gmail.com>
     [not found]       ` <20231004004929.9F76B2042E@pchp3.se.axis.com>
2023-10-04  8:53         ` [PATCH] __atomic_test_and_set: Fall back to library, not non-atomic code Christophe Lyon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPS5khY-T=SNW0wCt3wCeiktFdyx3YtcA6H993jejUjd1PA2iQ@mail.gmail.com' \
    --to=christophe.lyon@linaro.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hp@axis.com \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).