This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/50583] Many __sync_XXX builtin functions are incorrect
- From: "hjl.tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 30 Sep 2011 16:57:14 +0000
- Subject: [Bug target/50583] Many __sync_XXX builtin functions are incorrect
- Auto-submitted: auto-generated
- References: <bug-50583-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50583
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2011-09-30 16:57:14 UTC ---
We have 2 choices:
1. Update document of
`TYPE __sync_fetch_and_add (TYPE *ptr, TYPE value, ...)'
`TYPE __sync_fetch_and_sub (TYPE *ptr, TYPE value, ...)'
`TYPE __sync_fetch_and_or (TYPE *ptr, TYPE value, ...)'
`TYPE __sync_fetch_and_and (TYPE *ptr, TYPE value, ...)'
`TYPE __sync_fetch_and_xor (TYPE *ptr, TYPE value, ...)'
`TYPE __sync_fetch_and_nand (TYPE *ptr, TYPE value, ...)'
to
{
tmp = *ptr;
tmp1 = tmp OP value;
return __sync_val_compare_and_swap (ptr, tmp, tmp1);
}
2. Remove those __sync_fetch_and_XXX which aren't
{ tmp = *ptr; *ptr OP= value; return tmp; }
Since only
{ tmp = *ptr; *ptr OP= value; return tmp; }
can be used to implement locks, I think we should do 2.