[PATCH] RFC: use C11 alignas instead of GCC attribute aligned
Tyler Retzlaff
roretzla at linux.microsoft.com
Thu Jan 25 19:37:13 CET 2024
ping.
Please review this thread if you have time, the main point of discussion
I would like to receive consensus on the following questions.
1. Should we continue to expand common alignments behind an __rte_macro
i.e. what do we prefer to appear in code
alignas(RTE_CACHE_LINE_MIN_SIZE)
-- or --
__rte_cache_aligned
One of the benefits of dropping the macro is it provides a clear visual
indicator that it is not placed in the same location or get applied
to types as is done with __attribute__((__aligned__(n))).
2. where should we place alignas(n) or __rte_macro (if we use a macro)
Should it be on the same line as the variable or field or on the
preceeding line?
/* same line example struct */
struct T {
/* alignas(64) applies to field0 *not* struct T type declaration */
alignas(64) void *field0;
void *field1;
... other fields ...
alignas(64) uint64_t field5;
uint32_t field6;
... more fields ...
};
/* same line example array */
alignas(64) static const uint32_t array[4] = { ... };
-- or --
/* preceeding line example struct */
struct T {
/* alignas(64) applies to field0 *not* struct T type declaration */
alignas(64)
void *field0;
void *field1;
... other fields ...
alignas(64)
uint64_t field5;
uint32_t field6;
... more fields ...
};
/* preceeding line example array */
alignas(64)
static const uint32_t array[4] = { ... };
I'll submit patches for lib/* once the discussion is concluded.
thanks folks
On Wed, Nov 15, 2023 at 09:39:56AM -0800, Tyler Retzlaff wrote:
> Now that we require a C11 conformant toolchain we are able to improve
> portability by further adoption of C11 features.
>
> Adapt EAL to use C11 alignas replacing __rte_cache_aligned and
> __rte_aligned(a) that expand to __attribute__((__aligned__(a))).
>
> Note: it appears that use of alignas has exposed a bug in
> lib/eal/riscv/include/rte_vect.h where the alignment
> specified was reduced to 8 for xmm_t.
>
> Please comment, subject to the outcome I will submit further series for
> lib/*
>
> Thanks
>
> Tyler Retzlaff (1):
> eal: use C11 alignas instead of GCC attribute aligned
>
> lib/eal/arm/include/rte_vect.h | 4 +++-
> lib/eal/common/malloc_elem.h | 4 +++-
> lib/eal/common/malloc_heap.h | 4 +++-
> lib/eal/common/rte_keepalive.c | 4 +++-
> lib/eal/common/rte_random.c | 5 ++++-
> lib/eal/common/rte_service.c | 7 +++++--
> lib/eal/include/generic/rte_atomic.h | 4 +++-
> lib/eal/loongarch/include/rte_vect.h | 7 +++++--
> lib/eal/ppc/include/rte_vect.h | 5 ++++-
> lib/eal/riscv/include/rte_vect.h | 4 +++-
> lib/eal/x86/include/rte_vect.h | 4 +++-
> lib/eal/x86/rte_power_intrinsics.c | 8 ++++++--
> 12 files changed, 45 insertions(+), 15 deletions(-)
>
> --
> 1.8.3.1
More information about the dev
mailing list