Tuesday 3 September 2013

Atomic reads/writes of 64 bit values in 32 bit mode with gcc

Atomic reads/writes of 64 bit values in 32 bit mode with gcc

Is there any intrinsic or other way in gcc of persuading it to do 64 bit
reads and writes atomically rather than as 2 32 bit writes? (At least in
one or two places).
Currently I'm having to do __sync_lock_test_and_set and
__sync_fetch_and_add to get it to do the reads/writes atomically, but the
CPUs in question have 64 bit fetch and store instructions.
I'd prefer not to write loads of inline assembler (presumably one for each
CPU we have to support) with #ifs spread around.
I'm currently using gcc 4.4.6 and am unlikely to get that upgraded in the
short term.

No comments:

Post a Comment