BUILD: threads: fix again the __ha_cas_dw() definition
authorWilly Tarreau <w@1wt.eu>
Sat, 11 May 2019 16:04:24 +0000 (18:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 11 May 2019 16:13:29 +0000 (18:13 +0200)
commit6a38b3297ca52386a1ab5ac93fea569b62e1b99f
tree18f7495dc3e14348427bf696ac5fba8a3226cc2f
parent295d614de18a204c624339b030bae55453b2126d
BUILD: threads: fix again the __ha_cas_dw() definition

This low-level asm implementation of a double CAS was implemented only
for certain architectures (x86_64, armv7, armv8). When threads are not
used, they were not defined, but since they were called directly from
a few locations, they were causing build issues on certain platforms
with threads disabled. This was addressed in commit f4436e1 ("BUILD:
threads: Add __ha_cas_dw fallback for single threaded builds") by
making it fall back to HA_ATOMIC_CAS() when threads are not defined,
but this actually made the situation worse by breaking other cases.

This patch fixes this by creating a high-level macro HA_ATOMIC_DWCAS()
which is similar to HA_ATOMIC_CAS() except that it's intended to work
on a double word, and which rely on the asm implementations when threads
are in use, and uses its own open-coded implementation when threads are
not used. The 3 call places relying on __ha_cas_dw() were updated to
use HA_ATOMIC_DWCAS() instead.

This change was tested on i586, x86_64, armv7, armv8 with and without
threads with gcc 4.7, armv8 with gcc 5.4 with and without threads, as
well as i586 with gcc-3.4 without threads. It will need to be backported
to 1.9 along with the fix above to fix build on armv7 with threads
disabled.
include/common/hathreads.h
include/common/memory.h
src/fd.c
src/memory.c