This uses the built-in atomic functions. The test program is:
#include "XrdSys/XrdSysAtomics.hh"
int a;
void val_set(int v) { AtomicCAS(a, a, v); }
int val_get() { return AtomicGet(a); }
The assembler code for x86_64 is as expected:
_Z7val_seti:
.cfi_startproc
movl %edi, a(%rip)
ret
.cfi_endproc
_Z7val_getv:
.cfi_startproc
movl a(%rip), %eax
ret
.cfi_endproc
While for ARM it looks like this:
_Z7val_seti:
.fnstart
.LFB0:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
ldr r3, .L2
str r0, [r3, #0]
bx lr
.L3:
.align 2
.L2:
.word .LANCHOR0
.cantunwind
.fnend
_Z7val_getv:
.fnstart
.LFB1:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
ldr r3, .L5
ldr r0, [r3, #0]
bx lr
.L6:
.align 2
.L5:
.word .LANCHOR0
.cantunwind
.fnend
So, the conclusion is that for x86_64 there is no difference whether we use or not __sync_fetch*
. Obviously this also works without c++11. Let me know which one you prefer between this one and #265.
https://github.com/xrootd/xrootd/pull/266
—
Reply to this email directly or view it on GitHub.
Use REPLY-ALL to reply to list
To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1