From: Willy Tarreau Date: Thu, 28 Oct 2021 07:41:29 +0000 (+0200) Subject: MINOR: atomic: remove the memcpy() call and dependency on string.h X-Git-Tag: v2.5-dev12~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04065b87ced8bc9aad204942a49253e1650af48b;p=thirdparty%2Fhaproxy.git MINOR: atomic: remove the memcpy() call and dependency on string.h The memcpy() call in the aarch64 version of __ha_cas_dw() is sometimes inlined and sometimes not, depending on the gcc version. It's only used to copy two void*, so let's use direct assignment instead of memcpy(). It would also be possible to change the asm code to directly write there, but it's not worth it. With this change the code is 8kB smaller with gcc-5.4. --- diff --git a/include/haproxy/atomic.h b/include/haproxy/atomic.h index 4306b75c1e..af0b10a07e 100644 --- a/include/haproxy/atomic.h +++ b/include/haproxy/atomic.h @@ -23,8 +23,6 @@ #ifndef _HAPROXY_ATOMIC_H #define _HAPROXY_ATOMIC_H -#include - /* A few notes for the macros and functions here: * - this file is painful to edit, most operations exist in 3 variants, * no-thread, threads with gcc<4.7, threads with gcc>=4.7. Be careful when @@ -781,7 +779,8 @@ static __inline int __ha_cas_dw(void *target, void *compare, void *set) : "r" (target), "r" (((void **)(compare))[0]), "r" (((void **)(compare))[1]), "r" (((void **)(set))[0]), "r" (((void **)(set))[1]) : "cc", "memory"); - memcpy(compare, &value, sizeof(value)); + ((void **)(compare))[0] = value[0]; + ((void **)(compare))[1] = value[1]; return (tmp1); } #endif // ARMv8.1-A atomics