64-bit atomic ops on 32-bit CPU (again)
Alexey Dokuchaev
danfe at FreeBSD.org
Sun Sep 6 07:20:30 UTC 2015
On Wed, Aug 05, 2015 at 03:16:58PM -0700, Justin Hibbits wrote:
> I *think* all that's needed is atomic64 emulation. I had written a
> patch implementing them, [...]
Hmm, perhaps you can help me here for a slightly different problem? I
need to do __sync_fetch_and_add() on int64_t argument (in userspace),
but linking fails due to undefined reference to `__sync_fetch_and_add_8'
(this is on 32-bit G4).
I've googled a bit on how to implement a lock-free atomic 64-bit addition
on a 32-bit ppc (e.g. [1], [2]), it looks certainly doable (albeit would
require good understanding of CPU and cache details, and a manual ;-).
What's my best bet here: implement local __sync_fetch_and_add_64() with
inline asm(), or teach gcc how to avoid __sync_fetch_and_add_8() linking
problem somehow?
./danfe
[1] http://lists.apple.com/archives/perfoptimization-dev/2008/Nov/msg00012.html
[2] https://lists.freebsd.org/pipermail/freebsd-ppc/2008-September/003129.html
More information about the freebsd-ppc
mailing list