From: Willy Tarreau Date: Fri, 28 Jan 2022 07:52:57 +0000 (+0100) Subject: BUILD: atomic: make the old HA_ATOMIC_LOAD() support const pointers X-Git-Tag: v2.6-dev1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8da23393a1ec3f24dcd408f4b35fdd3d9a141a5f;p=thirdparty%2Fhaproxy.git BUILD: atomic: make the old HA_ATOMIC_LOAD() support const pointers We have an implementation of atomic ops for older versions of gcc that do not provide the __builtin_* API (< 4.4). Recent changes to the pools broke that in pool_releasable() by having a load from a const pointer, which doesn't work there due to a temporary local variable that is declared then assigned. Let's make use of a compount statement to assign it a value when declaring it. There's no need to backport this. --- diff --git a/include/haproxy/atomic.h b/include/haproxy/atomic.h index af0b10a07e..f60be95c1e 100644 --- a/include/haproxy/atomic.h +++ b/include/haproxy/atomic.h @@ -194,13 +194,12 @@ #if defined(__GNUC__) && (__GNUC__ < 4 || __GNUC__ == 4 && __GNUC_MINOR__ < 7) && !defined(__clang__) /* gcc < 4.7 */ -#define HA_ATOMIC_LOAD(val) \ - ({ \ - typeof(*(val)) ret; \ - __sync_synchronize(); \ - ret = *(volatile typeof(val))val; \ - __sync_synchronize(); \ - ret; \ +#define HA_ATOMIC_LOAD(val) \ + ({ \ + typeof(*(val)) ret = \ + ({ __sync_synchronize(); *(volatile typeof(val))val; }); \ + __sync_synchronize(); \ + ret; \ }) #define HA_ATOMIC_STORE(val, new) \