[v5,02/39] eal: redefine macro to be integer literal for MSVC
Checks
Commit Message
MSVC __declspec(align(#)) is limited and accepts only integer literals
as opposed to constant expressions. define XMM_SIZE to be 16 instead of
sizeof(xmm_t) and static_assert that sizeof(xmm_t) == 16 for
compatibility.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
---
lib/eal/x86/include/rte_vect.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
> MSVC __declspec(align(#)) is limited and accepts only integer literals
> as opposed to constant expressions. define XMM_SIZE to be 16 instead of
> sizeof(xmm_t) and static_assert that sizeof(xmm_t) == 16 for
> compatibility.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
> ---
> lib/eal/x86/include/rte_vect.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/lib/eal/x86/include/rte_vect.h b/lib/eal/x86/include/rte_vect.h
> index a1a537e..441f1a0 100644
> --- a/lib/eal/x86/include/rte_vect.h
> +++ b/lib/eal/x86/include/rte_vect.h
> @@ -11,6 +11,7 @@
> * RTE SSE/AVX related header.
> */
>
> +#include <assert.h>
> #include <stdint.h>
> #include <rte_config.h>
> #include <rte_common.h>
> @@ -33,9 +34,11 @@
>
> typedef __m128i xmm_t;
>
> -#define XMM_SIZE (sizeof(xmm_t))
> +#define XMM_SIZE 16
> #define XMM_MASK (XMM_SIZE - 1)
>
> +static_assert(sizeof(xmm_t) == 16, "");
I think it is better be:
static_assert(sizeof(xmm_t) == XMM_SIZE, "");
BTW, is there any chance that in future versions MSVC would accept align(<constant_expression>)?
> +
> typedef union rte_xmm {
> xmm_t x;
> uint8_t u8[XMM_SIZE / sizeof(uint8_t)];
> --
> 1.8.3.1
On Mon, Feb 26, 2024 at 12:51:38PM +0000, Konstantin Ananyev wrote:
>
>
> > MSVC __declspec(align(#)) is limited and accepts only integer literals
> > as opposed to constant expressions. define XMM_SIZE to be 16 instead of
> > sizeof(xmm_t) and static_assert that sizeof(xmm_t) == 16 for
> > compatibility.
> >
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > Acked-by: Morten Brørup <mb@smartsharesystems.com>
> > ---
> > lib/eal/x86/include/rte_vect.h | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/eal/x86/include/rte_vect.h b/lib/eal/x86/include/rte_vect.h
> > index a1a537e..441f1a0 100644
> > --- a/lib/eal/x86/include/rte_vect.h
> > +++ b/lib/eal/x86/include/rte_vect.h
> > @@ -11,6 +11,7 @@
> > * RTE SSE/AVX related header.
> > */
> >
> > +#include <assert.h>
> > #include <stdint.h>
> > #include <rte_config.h>
> > #include <rte_common.h>
> > @@ -33,9 +34,11 @@
> >
> > typedef __m128i xmm_t;
> >
> > -#define XMM_SIZE (sizeof(xmm_t))
> > +#define XMM_SIZE 16
> > #define XMM_MASK (XMM_SIZE - 1)
> >
> > +static_assert(sizeof(xmm_t) == 16, "");
>
> I think it is better be:
> static_assert(sizeof(xmm_t) == XMM_SIZE, "");
>
ack, will fix
>
> BTW, is there any chance that in future versions MSVC would accept align(<constant_expression>)?
it does seem an oversight. i will ask the msvc team if they would like to enhance it.
thanks
>
> > +
> > typedef union rte_xmm {
> > xmm_t x;
> > uint8_t u8[XMM_SIZE / sizeof(uint8_t)];
> > --
> > 1.8.3.1
>
@@ -11,6 +11,7 @@
* RTE SSE/AVX related header.
*/
+#include <assert.h>
#include <stdint.h>
#include <rte_config.h>
#include <rte_common.h>
@@ -33,9 +34,11 @@
typedef __m128i xmm_t;
-#define XMM_SIZE (sizeof(xmm_t))
+#define XMM_SIZE 16
#define XMM_MASK (XMM_SIZE - 1)
+static_assert(sizeof(xmm_t) == 16, "");
+
typedef union rte_xmm {
xmm_t x;
uint8_t u8[XMM_SIZE / sizeof(uint8_t)];