> -----Original Message-----
> From: Andre Muezerie <andre...@linux.microsoft.com>
> Sent: Wednesday, February 26, 2025 1:07 AM
> To: andre...@linux.microsoft.com
> Cc: dev@dpdk.org
> Subject: [PATCH v2 2/5] eal: only use numbers as align parameters for MSVC
>
> After the instruction set updates for MSVC the error below popped up:
>
> ..\lib\eal\x86\include\rte_vect.h(82): error C2059: syntax error: '('
>
> The issue is that MSVC does not allow __rte_aligned(RTE_X86_ZMM_SIZE).
> It only accepts numbers that are power of 2. So, even though
> RTE_X86_ZMM_SIZE represents a number that is a power of two it cannot
> be used directly.
> https://learn.microsoft.com/en-us/cpp/cpp/align-cpp?view=msvc-170
>
> Signed-off-by: Andre Muezerie <andre...@linux.microsoft.com>
> ---
> lib/eal/x86/include/rte_vect.h | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/lib/eal/x86/include/rte_vect.h b/lib/eal/x86/include/rte_vect.h
> index 70c78e9b77..0a51c539a4 100644
> --- a/lib/eal/x86/include/rte_vect.h
> +++ b/lib/eal/x86/include/rte_vect.h
> @@ -79,7 +79,16 @@ __extension__ ({ \
> #define RTE_X86_ZMM_SIZE (sizeof(__m512i))
> #define RTE_X86_ZMM_MASK (RTE_X86_ZMM_SIZE - 1)
>
> -typedef union __rte_aligned(RTE_X86_ZMM_SIZE) __rte_x86_zmm {
> +/*
> + * MSVC does not allow __rte_aligned(RTE_X86_ZMM_SIZE). It only accepts
> + * numbers that are power of 2. So, even though RTE_X86_ZMM_SIZE represents a
> + * number that is a power of two it cannot be used directly.
> + * Ref: https://learn.microsoft.com/en-us/cpp/cpp/align-cpp?view=msvc-170
> + * The static assert below ensures that RTE_X86_ZMM_SIZE is equal to what is
> + * used in the __rte_aligned() expression.
> + */
> +static_assert(RTE_X86_ZMM_SIZE == 64, "Unexpected size of __m512i");
> +typedef union __rte_aligned(64) __rte_x86_zmm {
Just wonder, would then MSVC understand something like:
#define RTE_X86_ZMM_SIZE 64
static_assert(RTE_X86_ZMM_SIZE == sizeof((__m512i), "Unexpected size of
__m512i");
typedef union __rte_aligned(RTE_X86_ZMM_SIZE) __rte_x86_zmm {
?
> __m512i z;
> ymm_t y[RTE_X86_ZMM_SIZE / sizeof(ymm_t)];
> xmm_t x[RTE_X86_ZMM_SIZE / sizeof(xmm_t)];
> --
> 2.48.1.vfs.0.0