Patchwork [1/2] Improve __atomic_clear/test_and_set documentation

login
register
mail settings
Submitter Andi Kleen
Date June 20, 2013, 1:20 p.m.
Message ID <1371734413-12372-1-git-send-email-andi@firstfloor.org>
Download mbox | patch
Permalink /patch/252928/
State New
Headers show

Comments

Andi Kleen - June 20, 2013, 1:20 p.m.
From: Andi Kleen <ak@linux.intel.com>

Document that __atomic_clear and __atomic_test_and_set should
only be used with bool.

gcc/:
2013-06-13  Andi Kleen  <ak@linux.intel.com>

	* doc/extend.texi: Document that __atomic_clear and
	  __atomic_test_and_set should only be used with bool.
---
 gcc/doc/extend.texi | 6 ++++++
 1 file changed, 6 insertions(+)
Richard Henderson - June 20, 2013, 6:04 p.m.
On 06/20/2013 06:20 AM, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> Document that __atomic_clear and __atomic_test_and_set should
> only be used with bool.
> 
> gcc/:
> 2013-06-13  Andi Kleen  <ak@linux.intel.com>
> 
> 	* doc/extend.texi: Document that __atomic_clear and
> 	  __atomic_test_and_set should only be used with bool.
> ---
>  gcc/doc/extend.texi | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
> index 1e1f8b3..aa3abef 100644
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -7438,6 +7438,8 @@ This built-in function performs an atomic test-and-set operation on
>  the byte at @code{*@var{ptr}}.  The byte is set to some implementation
>  defined nonzero ``set'' value and the return value is @code{true} if and only
>  if the previous contents were ``set''.
> +It should be only used for operands of type bool or atomic_flag. For 
> +other types only part of the value may be set.

@code{bool}.  We have no definition for atomic_flag.  Perhaps just @code{char}
for now?

> +It should be only used for operands of type bool or atomic_flag and 

Same.

> +in conjunction with __atomic_test_and_set.

@code{__atomic_test_and_set}.



r~
Andi Kleen - June 20, 2013, 6:14 p.m.
> > +It should be only used for operands of type bool or atomic_flag. For 
> > +other types only part of the value may be set.
> 
> @code{bool}.  We have no definition for atomic_flag.  Perhaps just @code{char}
> for now?
> 
> > +It should be only used for operands of type bool or atomic_flag and 
> 
> Same.
> 
> > +in conjunction with __atomic_test_and_set.
> 
> @code{__atomic_test_and_set}.

Ok with these changes?

-Andi
Richard Henderson - June 20, 2013, 6:26 p.m.
On 06/20/2013 11:14 AM, Andi Kleen wrote:
>>> +It should be only used for operands of type bool or atomic_flag. For 
>>> +other types only part of the value may be set.
>>
>> @code{bool}.  We have no definition for atomic_flag.  Perhaps just @code{char}
>> for now?
>>
>>> +It should be only used for operands of type bool or atomic_flag and 
>>
>> Same.
>>
>>> +in conjunction with __atomic_test_and_set.
>>
>> @code{__atomic_test_and_set}.
> 
> Ok with these changes?

Yeah.


r~

Patch

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 1e1f8b3..aa3abef 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -7438,6 +7438,8 @@  This built-in function performs an atomic test-and-set operation on
 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
 defined nonzero ``set'' value and the return value is @code{true} if and only
 if the previous contents were ``set''.
+It should be only used for operands of type bool or atomic_flag. For 
+other types only part of the value may be set.
 
 All memory models are valid.
 
@@ -7447,6 +7449,10 @@  All memory models are valid.
 
 This built-in function performs an atomic clear operation on
 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
+It should be only used for operands of type bool or atomic_flag and 
+in conjunction with __atomic_test_and_set.
+For other types it may only clear partially. If the type is not bool
+prefer using @code{__atomic_store}.
 
 The valid memory model variants are
 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and