[PATCH v6 1/9] eal: generic 64 bit counter
Stephen Hemminger
stephen at networkplumber.org
Fri May 17 17:05:27 CEST 2024
On Fri, 17 May 2024 08:44:42 +0200
Morten Brørup <mb at smartsharesystems.com> wrote:
> I guess it depends on the architecture's natural alignment size and the compiler - especially on 32 bit architectures, where the natural alignment size is 4 bytes.
>
> We could play it safe and add alignment to the counter type:
>
> #include <stdalign.h>
> #ifdef RTE_ARCH_64
> #if alignof(uint64_t) < sizeof(uint64_t)
I don't think this case is possible, what architecture is that broken?
> typedef alignas(8) uint64_t rte_counter64_t;
> #else
> typedef uint64_t rte_counter64_t;
> #endif
> #else
> #if alignof(RTE_ATOMIC(uint64_t)) < sizeof(uint64_t)
> typedef alignas(8) RTE_ATOMIC(uint64_t) rte_counter64_t;
> #else
> typedef RTE_ATOMIC(uint64_t) rte_counter64_t;
> #endif
> #endif
The bigger question is how to detect 32 bit x86 being safe without atomic?
(and does it still matter).
More information about the dev
mailing list