Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22001

__sync_bool_compare_and_swap - return value if oldval and newval are same

$
0
0

the documentation does not say what happens when the expected oldval and the newval is the same. Following is from the gcc doc:

The “bool” version returns true if the comparison is successful and newval is written.

So if the newval and oldval is the same, effectively there is no write. So will following code always returns true if the *ptr == 0 ?

__sync_bool_compare_and_swap(&ptr, 0, 0)

Thanks


Viewing all articles
Browse latest Browse all 22001

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>