ivmai/libatomic_ops

cas ptr

diakopter opened this issue · 4 comments

The header says "All operations operate on unsigned AO_t, which is the natural word size, and usually unsigned long".

Does this mean it can't CAS a pointer, or that it can? The APR has
apr underscore atomic underscore casptr
see http://apr.apache.org/docs/apr/trunk/group double underscore apr double underscore atomic.html
, which works for me on 64-bit. But I'm looking at using this library instead for the atomic operations because of the memory barrier precision. So I'm just wondering whether this library will let me CAS pointers on 64-bit.

Thanks again!

Hi Matthew,

Sat, 8 Sep 2012 11:37:14 -0700 Matthew Wilson notifications@github.com:

The header says "All operations operate on unsigned AO_t, which is the natural word size, and usually unsigned long".

This should be refined, I think. AO_t is typically size_t which should be (normally) the same size of pointer.

Also, there could be atomic operations defined for other types (like char, short, int) on some platforms.

Does this mean it can't CAS a pointer, or that it can? The APR has apratomic_casptr (see http://apr.apache.org/docs/apr/trunk/group__apr__atomic.html), which works for me on 64-bit. But I'm looking at using this library instead for the atomic operations because of the memory barrier precision. So I'm just wondering whether this library will let me CAS pointers on 64-bit.

Yes, cast between a pointer type and AO_t is valid both on 32- and 64-bit targets.

Thanks again!

Reply to this email directly or view it on GitHub.

Regards,
Ivan

excellent; thanks

AO_compare_and_swap seems not to be implemented on msvc 32-bit. (tested with vs2010). Is it supposed to be?

oops, reopened the wrong one