util/u_atomic: fix build on clang archs without 64-bit atomics
authorJonathan Gray <jsg@jsg.id.au>
Mon, 15 Jun 2020 04:40:06 +0000 (14:40 +1000)
committerMarge Bot <emma+marge@anholt.net>
Mon, 28 Feb 2022 14:28:23 +0000 (14:28 +0000)
commitf12c107b030b0aacc0c8b11c99fdce13f38bc98f
tree97dca0b0db7dc5aa0aa624af075aa8eaa7f2484c
parentd07df90bf4442492d5f94190484793cb52f23860
util/u_atomic: fix build on clang archs without 64-bit atomics

Make this build on clang architectures that don't have 64-bit atomic
instructions.  Clang doesn't allow redeclaration (and therefore
redefinition) of the __sync_* builtins.  Use #pragma redefine_extname
to work around that restriction.  Clang also turns __sync_add_and_fetch
into __sync_fetch_and_add (and __sync_sub_and_fetch into
__sync_fetch_and_sub) in certain cases, so provide these functions as
well.

Fixes: a6a38a038bd ("util/u_atomic: provide 64bit atomics where they're missing")
patch from Mark Kettenis

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6511>
src/util/u_atomic.c