From owner-freebsd-ppc@freebsd.org Sun Sep 6 07:20:30 2015 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 64EE49CB156 for ; Sun, 6 Sep 2015 07:20:30 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 56A9D189B; Sun, 6 Sep 2015 07:20:30 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1033) id 55F94117C; Sun, 6 Sep 2015 07:20:30 +0000 (UTC) Date: Sun, 6 Sep 2015 07:20:30 +0000 From: Alexey Dokuchaev To: Justin Hibbits Cc: "Herminio Hernandez, Jr." , FreeBSD PowerPC ML Subject: 64-bit atomic ops on 32-bit CPU (again) Message-ID: <20150906072030.GA96996@FreeBSD.org> References: <20150805185841.GA61013@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2015 07:20:30 -0000 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