Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Sep 2015 07:20:30 +0000
From:      Alexey Dokuchaev <danfe@FreeBSD.org>
To:        Justin Hibbits <jrh29@alumni.cwru.edu>
Cc:        "Herminio Hernandez, Jr." <herminio.hernandezjr@gmail.com>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>
Subject:   64-bit atomic ops on 32-bit CPU (again)
Message-ID:  <20150906072030.GA96996@FreeBSD.org>
In-Reply-To: <CAHSQbTCfEOYwpE1JDaZJH9QymxNvg5T1RW1DV9bmX4Ngi%2B%2BTdA@mail.gmail.com>
References:  <CAJRA9dy=_QKTpgQreZtYjo8ZzW6QTJ6N=De0m9G6NW4DMCRnyg@mail.gmail.com> <CAHSQbTCDkRV1znAJxCiaW22kZTsfikrVUuYZnmOk4YFCU9kE0w@mail.gmail.com> <20150805185841.GA61013@FreeBSD.org> <CAHSQbTCfEOYwpE1JDaZJH9QymxNvg5T1RW1DV9bmX4Ngi%2B%2BTdA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150906072030.GA96996>