[Bug target/50583] Many __sync_XXX builtin functions are incorrect
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Sep 30 17:34:00 GMT 2011
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.
More information about the Gcc-bugs
mailing list