From: Willy Tarreau Date: Fri, 17 May 2024 06:38:00 +0000 (+0200) Subject: BUILD: stick-tables: better mark the stktable_data as 32-bit aligned X-Git-Tag: v3.0-dev12~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ea3b89952d95452161ba28ada8e30656a374aac8;p=thirdparty%2Fhaproxy.git BUILD: stick-tables: better mark the stktable_data as 32-bit aligned Aurélien reported that clang's build was broken by the recent fix 845fb846c7 ("BUG/MEDIUM: stick-tables: properly mark stktable_data as packed"), because it now wants to use a helper for some atomic ops (to increment std_t_uint). While this makes no sense to do something that slow on modern architectures like x86 and arm64 which are fine with unaligned accesses, we actually we can simply mark the struct as aligned to its smallest element which is 32-bit (but still packed). With this, it was verified that it is enough for clang to see that its 32-bit operations will always be aligned, while making 64-bit operations safe on 64-bit platforms that do not support unaligned accesses. This should be backported wherever the patch above is backported. --- diff --git a/include/haproxy/stick_table-t.h b/include/haproxy/stick_table-t.h index fe23848dd7..4b984396e9 100644 --- a/include/haproxy/stick_table-t.h +++ b/include/haproxy/stick_table-t.h @@ -119,7 +119,7 @@ union stktable_data { unsigned long long std_t_ull; struct freq_ctr std_t_frqp; struct dict_entry *std_t_dict; -} __attribute__((packed)); +} __attribute__((packed, aligned(sizeof(int)))); /* known data types */ struct stktable_data_type {