Hi all,
please, could some low-level s390 guru take a look at the atomic primitives in libatomic_ops [1]? Are they correct, any improvements possible, ...? I am trying to recommend this library as a universal source of atomic primitives for user space instead of developing a limited set for each project individually (and usually only for major archs like i386/x86_64).
Thanks Dan
[1] http://bdwgc.cvs.sourceforge.net/viewvc/bdwgc/bdwgc/libatomic_ops-1.2/ specifically the src/atomic_ops/sysdeps/gcc/s390.h file
Dan Horák wrote:
Hi all,
please, could some low-level s390 guru take a look at the atomic primitives in libatomic_ops [1]? Are they correct, any improvements possible, ...? I am trying to recommend this library as a universal source of atomic primitives for user space instead of developing a limited set for each project individually (and usually only for major archs like i386/x86_64).
Thanks Dan
[1] http://bdwgc.cvs.sourceforge.net/viewvc/bdwgc/bdwgc/libatomic_ops-1.2/ specifically the src/atomic_ops/sysdeps/gcc/s390.h file
I'm not sure the s390x version is correct.
Apparently (but I could be wrong), AO_t is pretty much guaranteed to be a host architecture 'int'.
On s390x, an int is a 32 bit entity.
On s390x, the s390.h code performs a "CSG" - which acts upon 64 bit registers, and the target memory address will be seen as a container for a 64 bit value (basically storing a 64 bit value in a 32 bit container - thus overshooting by 4 bytes).
The Compare and Swap instructions are as follow :
s390/32 bit : CS s390x/32 bit : CS s390/64 bit : CDS s390x/64 bit : CSG or CDS s390/128 bit : N/A s390/128 bit : CDSG
See z/Architecture Principles of Operation - SA22-7832-07 (aka dz9zr007.pdf) Page 7-66
--Ivan