public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Clarify __atomic_compare_exchange_n docs
Date: Tue, 29 Sep 2015 16:00:00 -0000	[thread overview]
Message-ID: <560AAC7B.4030904@codesourcery.com> (raw)
In-Reply-To: <20150929120038.GW12094@redhat.com>

On 09/29/2015 06:00 AM, Jonathan Wakely wrote:
> Someone on IRC incorrectly parsed the docs at
> https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gcc/_005f_005fatomic-Builtins.html#index-g_t_005f_005fatomic_005fcompare_005fexchange_005fn-3536
>
> as:
>
>   IF
>   (
>    desired is written into *ptr
>    AND
>    the execution is considered to conform to the memory model
>    specified by success_memmodel.
>   )
>   {
>    true is returned
>   }
>   otherwise ...
>
> rather than the intended:
>
>   IF ( desired is written into *ptr )
>   {
>    true is returned
>    AND
>    the execution is considered to conform to the memory model
>    specified by success_memmodel.
>   }
>   otherwise ...
>
> So they asked:
>
>> What is otherwise, here? Can I make the function return false even
>> when 'desired' has been written into 'ptr'? How do I do it? I could
>> not write an example, so far.
>
> This patch rewords it to avoid the ambiguity.
>
> I've also replaced the rather clunky "the operation is considered to
> conform to" phrasing. (It's only _considered_ to? So does it or doesn't
> it use that memory order?) Instead I've used the terminology from the
> C and C++ standards, which say "memory is affected according to".
>
> OK for trunk?

This is OK, as far as it goes, but while we're at it, can we do 
something to fix the description of the weak parameter?

> @@ -9353,17 +9353,17 @@ This compares the contents of @code{*@var{ptr}} with the contents of
>  @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
>  operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
>  equal, the operation is a @emph{read} and the current contents of
> -@code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
> +@code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is true
>  for weak compare_exchange, and false for the strong variation.  Many targets
>  only offer the strong variation and ignore the parameter.  When in doubt, use
>  the strong variation.

What is "weak compare_exchange", and what is "the strong variation", and 
how do they differ in terms of behavior?

-Sandra

  reply	other threads:[~2015-09-29 15:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29 12:42 Jonathan Wakely
2015-09-29 16:00 ` Sandra Loosemore [this message]
2015-10-01 11:28   ` Andrew Haley
2015-10-01 17:32     ` Jonathan Wakely
2015-10-01 17:34       ` Andrew Haley
2015-10-01 17:42         ` Jonathan Wakely
2015-10-01 17:58     ` Sandra Loosemore
2015-10-01 18:35       ` Jonathan Wakely
2015-10-01 18:40         ` Jonathan Wakely
2015-10-03 13:00           ` Jonathan Wakely
2016-01-13 14:27             ` Jonathan Wakely
2016-01-13 17:16               ` Sandra Loosemore
2016-01-13 19:26                 ` Jonathan Wakely

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=560AAC7B.4030904@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    /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).