Skip to contentSkip to conversation

eliminate dependency on non-portable __SIZEOF_LONG__

PATCH Superseded Andre Muezerie 7 participants 51 messages Dec 4, 2024 – Mar 6, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover eliminate dependency on non-portable __SIZEOF_LONG__

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equaly well use sizeof(long) instead.

Andre Muezerie (6):
drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__ lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__

 drivers/bus/fslmc/mc/fsl_mc_cmd.h    | 2 +-
 drivers/common/cnxk/roc_bits.h       | 4 ++--
 drivers/common/nfp/nfp_platform.h    | 4 ++--
 drivers/dma/dpaa/dpaa_qdma.h         | 2 +-
 drivers/dma/hisilicon/hisi_dmadev.h  | 2 +-
 drivers/net/ena/base/ena_plat_dpdk.h | 4 ++--
 drivers/net/hns3/hns3_ethdev.h       | 2 +-
 drivers/raw/ifpga/base/opae_osdep.h  | 4 ++--
 lib/mldev/mldev_utils_scalar.h       | 2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)

--
2.47.0.vfs.0.3

#1 lore raw

PATCH 1/6 drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equaly well use sizeof(long) instead.

---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/fslmc/mc/fsl_mc_cmd.h +1 -1
index a768774c89..10804e6c5d 100644
@@ -29,7 +29,7 @@
 #define le32_to_cpu	rte_le_to_cpu_32
 #define le16_to_cpu	rte_le_to_cpu_16
 
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #define GENMASK(h, l) \
 		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 
Signature · 1 line
2.47.0.vfs.0.3
#2 lore raw

v2 cover eliminate dependency on non-portable __SIZEOF_LONG__

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

v2:
* fixed typo in commit message

Andre Muezerie (6):
drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__ lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__

 drivers/bus/fslmc/mc/fsl_mc_cmd.h    | 2 +-
 drivers/common/cnxk/roc_bits.h       | 4 ++--
 drivers/common/nfp/nfp_platform.h    | 4 ++--
 drivers/dma/dpaa/dpaa_qdma.h         | 2 +-
 drivers/dma/hisilicon/hisi_dmadev.h  | 2 +-
 drivers/net/ena/base/ena_plat_dpdk.h | 4 ++--
 drivers/net/hns3/hns3_ethdev.h       | 2 +-
 drivers/raw/ifpga/base/opae_osdep.h  | 4 ++--
 lib/mldev/mldev_utils_scalar.h       | 2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)

--
2.47.0.vfs.0.3

#3 lore raw

PATCH v2 1/6 drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/fslmc/mc/fsl_mc_cmd.h +1 -1
index a768774c89..10804e6c5d 100644
@@ -29,7 +29,7 @@
 #define le32_to_cpu	rte_le_to_cpu_32
 #define le16_to_cpu	rte_le_to_cpu_16
 
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #define GENMASK(h, l) \
 		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 
Signature · 1 line
2.47.0.vfs.0.3
#4 lore raw

PATCH v2 2/6 drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/common/cnxk/roc_bits.h    | 4 ++--
 drivers/common/nfp/nfp_platform.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/common/cnxk/roc_bits.h +2 -2
index 11216d9d63..aa4944ae7f 100644
@@ -14,10 +14,10 @@
 #endif
 
 #ifndef BITS_PER_LONG
-#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG (sizeof(long) * 8)
 #endif
 #ifndef BITS_PER_LONG_LONG
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
+#define BITS_PER_LONG_LONG (sizeof(long long) * 8)
 #endif
 
 #ifndef GENMASK
drivers/common/nfp/nfp_platform.h +2 -2
index 0b02fcf1e8..27792aca97 100644
@@ -14,8 +14,8 @@
 
 #define DMA_BIT_MASK(n)    ((1ULL << (n)) - 1)
 
-#define BITS_PER_LONG      (__SIZEOF_LONG__ * 8)
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
+#define BITS_PER_LONG      (sizeof(long) * 8)
+#define BITS_PER_LONG_LONG (sizeof(long long) * 8)
 
 #define GENMASK(h, l) \
 	((~0UL << (l)) & (~0UL >> (BITS_PER_LONG - (h) - 1)))
Signature · 1 line
2.47.0.vfs.0.3
#5 lore raw

PATCH v2 3/6 drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/dma/dpaa/dpaa_qdma.h        | 2 +-
 drivers/dma/hisilicon/hisi_dmadev.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/dma/dpaa/dpaa_qdma.h +1 -1
index 579483ac34..3736c0d431 100644
@@ -14,7 +14,7 @@
 #define RETRIES	5
 
 #ifndef GENMASK
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #define GENMASK(h, l) \
 		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 #endif
drivers/dma/hisilicon/hisi_dmadev.h +1 -1
index 786fe3cc0e..777b9dd704 100644
@@ -12,7 +12,7 @@
 #include <rte_dmadev_pmd.h>
 
 #define BIT(x)	(1ul << (x))
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #define GENMASK(h, l) \
 		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 #define BF_SHF(x) rte_bsf64(x)
Signature · 1 line
2.47.0.vfs.0.3
#6 lore raw

PATCH v2 4/6 drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 4 ++--
 drivers/net/hns3/hns3_ethdev.h       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +2 -2
index 1121460470..24e0435ac1 100644
@@ -97,11 +97,11 @@ extern int ena_logtype_com;
 #define ENA_MIN16(x, y) ENA_MIN_T(uint16_t, (x), (y))
 #define ENA_MIN8(x, y) ENA_MIN_T(uint8_t, (x), (y))
 
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
+#define BITS_PER_LONG_LONG (sizeof(long long) * 8)
 #define U64_C(x) x ## ULL
 #define BIT(nr)	RTE_BIT32(nr)
 #define BIT64(nr)	RTE_BIT64(nr)
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 #define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) &		       \
 			  (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
drivers/net/hns3/hns3_ethdev.h +1 -1
index 7824503bb8..207a92f832 100644
@@ -952,7 +952,7 @@ static inline struct hns3_vf *HNS3_DEV_HW_TO_VF(struct hns3_hw *hw)
 
 #define BIT_ULL(x) (1ULL << (x))
 
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #define GENMASK(h, l) \
 	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 
Signature · 1 line
2.47.0.vfs.0.3
#7 lore raw

PATCH v2 5/6 drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/raw/ifpga/base/opae_osdep.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/raw/ifpga/base/opae_osdep.h +2 -2
index cb780b1fed..bb8d2a1dd6 100644
@@ -31,10 +31,10 @@ struct uuid {
 
 #ifndef LINUX_MACROS
 #ifndef BITS_PER_LONG
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #endif
 #ifndef BITS_PER_LONG_LONG
-#define BITS_PER_LONG_LONG  (__SIZEOF_LONG_LONG__ * 8)
+#define BITS_PER_LONG_LONG  (sizeof(long long) * 8)
 #endif
 #ifndef BIT
 #define BIT(a) (1UL << (a))
Signature · 1 line
2.47.0.vfs.0.3
#8 lore raw

PATCH v2 6/6 lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 lib/mldev/mldev_utils_scalar.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/mldev/mldev_utils_scalar.h +1 -1
index 57e66ddb60..d12e358fb5 100644
@@ -13,7 +13,7 @@
 #endif
 
 #ifndef BITS_PER_LONG
-#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG (sizeof(long) * 8)
 #endif
 
 #ifndef GENMASK_U32
Signature · 1 line
2.47.0.vfs.0.3
#9 lore raw

v3 cover eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

v3:
* added prefix RTE_ to BITS_PER_LONG* and moved them to rte_common.h
* defined PLT_BITS_PER_LONG* in drivers/common/cnxk/roc_platform.h to avoid warnings from checkpatches.sh like:

Warning in drivers/common/cnxk/roc_bits.h:
Warning in drivers/common/cnxk/roc_ie_ot.h:
Warning in drivers/common/cnxk/roc_ie_ot_tls.h:
Use plt_ symbols instead of rte_ API in cnxk base driver

It can be seen that the same was done in the past for similar macros like PLT_CACHE_LINE_SIZE

v2:
* fixed typo in commit message

Andre Muezerie (7):
lib/eal: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__ lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__

 drivers/bus/fslmc/mc/fsl_mc_cmd.h      |  3 +--
 drivers/common/cnxk/cnxk_security_ar.h |  4 ++--
 drivers/common/cnxk/roc_bits.h         | 13 ++++---------
 drivers/common/cnxk/roc_ie_ot.h        |  4 ++--
 drivers/common/cnxk/roc_ie_ot_tls.h    |  5 +++--
 drivers/common/cnxk/roc_platform.h     |  2 ++
 drivers/common/nfp/nfp_platform.h      |  8 +++-----
 drivers/dma/dpaa/dpaa_qdma.h           |  3 +--
 drivers/dma/hisilicon/hisi_dmadev.h    |  3 +--
 drivers/net/ena/base/ena_plat_dpdk.h   |  6 ++----
 drivers/net/hns3/hns3_ethdev.h         |  3 +--
 drivers/raw/ifpga/base/opae_osdep.h    | 12 ++++--------
 lib/eal/include/rte_common.h           |  5 +++++
 lib/mldev/mldev_utils_scalar.h         |  6 +-----
 14 files changed, 32 insertions(+), 45 deletions(-)

--
2.47.0.vfs.0.3

#10 lore raw

PATCH v3 1/7 lib/eal: eliminate dependency on non-portable __SIZEOF_LONG__

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 lib/eal/include/rte_common.h | 5 +++++
 1 file changed, 5 insertions(+)
lib/eal/include/rte_common.h +5 -0
index 4d299f2b36..d2338366a4 100644
@@ -603,6 +603,11 @@ rte_is_aligned(const void * const __rte_restrict ptr, const unsigned int align)
  */
 #define RTE_BUILD_BUG_ON(condition) do { static_assert(!(condition), #condition); } while (0)
 
+/*********** Data type size related macros ********/
+
+#define RTE_BITS_PER_LONG (sizeof(long) * 8)
+#define RTE_BITS_PER_LONG_LONG (sizeof(long long) * 8)
+
 /*********** Cache line related macros ********/
 
 /** Cache line mask. */
Signature · 1 line
2.47.0.vfs.0.3
#11 lore raw

PATCH v3 2/7 drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bus/fslmc/mc/fsl_mc_cmd.h +1 -2
index a768774c89..f27a18905d 100644
@@ -29,9 +29,8 @@
 #define le32_to_cpu	rte_le_to_cpu_32
 #define le16_to_cpu	rte_le_to_cpu_16
 
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 
 struct mc_cmd_header {
 	union {
Signature · 1 line
2.47.0.vfs.0.3
#12 lore raw

RE: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

Quoted 29 lines

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -0
index a768774c89..f27a18905d 100644

drivers/bus/fslmc/mc/fsl_mc_cmd.h line 33

Quoted 7 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +1 -2
@@ -29,9 +29,8 @@
 #define le32_to_cpu	rte_le_to_cpu_32
 #define le16_to_cpu	rte_le_to_cpu_16
 
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))

Inside
There are macros: RTE_GENMASK64 (and RTE_GENMASK32). Which as I understand does same thing.
Might be better to just use these ones instead of hand-crafting same thing over different PMDs.

Quoted 5 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -1
 struct mc_cmd_header {
 	union {
--

2.47.0.vfs.0.3

#13 lore raw

Re: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

Quoted 32 lines · Konstantin Ananyev
Quoted 32 lines

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -0
index a768774c89..f27a18905d 100644
@@ -29,9 +29,8 @@
 #define le32_to_cpu	rte_le_to_cpu_32
 #define le16_to_cpu	rte_le_to_cpu_16
 
Quoted 11 lines

drivers/bus/fslmc/mc/fsl_mc_cmd.h line 33

Quoted 4 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +1 -2
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))

Inside
There are macros: RTE_GENMASK64 (and RTE_GENMASK32). Which as I understand does same thing.
Might be better to just use these ones instead of hand-crafting same thing over different PMDs.

I agree. I can submit a separate patch for that once this series aimed at unblocking MSVC from being used on this code goes in, if that is OK. If instead you feel strongly that this change should be made as part of this series let me know.
--
Andre Muezerie

Quoted 5 lines
Quoted 5 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -1
 struct mc_cmd_header {
 	union {
--

2.47.0.vfs.0.3

#14 lore raw

RE: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

Quoted 42 lines
Quoted 30 lines
Quoted 30 lines

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -0
index a768774c89..f27a18905d 100644
@@ -29,9 +29,8 @@
 #define le32_to_cpu	rte_le_to_cpu_32
 #define le16_to_cpu	rte_le_to_cpu_16
 
Quoted 11 lines

drivers/bus/fslmc/mc/fsl_mc_cmd.h line 33

Quoted 4 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +1 -2
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))

Inside
There are macros: RTE_GENMASK64 (and RTE_GENMASK32). Which as I understand does same thing.
Might be better to just use these ones instead of hand-crafting same thing over different PMDs.

Quoted 4 lines

I agree. I can submit a separate patch for that once this series aimed at unblocking MSVC from being used on this code goes in, if that is OK. If instead you feel strongly that this change should be made as part of this series let me know.

I am fine anyway.
Just thought that doing something like:
#define GENMASK(h, l) RTE_GENMASK64(h, l)
Would be less work for you and less code churn.

Quoted 8 lines

--
Andre Muezerie

Quoted 5 lines
Quoted 5 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -1
 struct mc_cmd_header {
 	union {
--

2.47.0.vfs.0.3

#15 lore raw

RE: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

Quoted 51 lines

-----Original Message-----
From: Konstantin Ananyev <[email protected]>
Sent: Friday, December 6, 2024 4:41 PM
To: Andre Muezerie <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

Quoted 41 lines
Quoted 40 lines
Quoted 26 lines

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -0
index a768774c89..f27a18905d 100644

drivers/bus/fslmc/mc/fsl_mc_cmd.h line 33

Quoted 7 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +1 -2
@@ -29,9 +29,8 @@
 #define le32_to_cpu	rte_le_to_cpu_32
 #define le16_to_cpu	rte_le_to_cpu_16
 
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))

Inside
There are macros: RTE_GENMASK64 (and RTE_GENMASK32). Which as I understand does same thing.
Might be better to just use these ones instead of hand-crafting same thing over different PMDs.

Quoted 6 lines
Quoted 4 lines

I agree. I can submit a separate patch for that once this series aimed at unblocking MSVC from being used on this code goes in, if that is OK. If instead you feel strongly that this change should be made as part of this series let me know.

I am fine anyway.

Sorry meant to say: I am fine either way.
:)

Quoted 12 lines

Just thought that doing something like:
#define GENMASK(h, l) RTE_GENMASK64(h, l)
Would be less work for you and less code churn.

Quoted 8 lines

--
Andre Muezerie

Quoted 5 lines
Quoted 5 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -1
 struct mc_cmd_header {
 	union {
--

2.47.0.vfs.0.3

#16 lore raw

Re: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Konstantin Ananyev
Quoted 47 lines · Konstantin Ananyev
Quoted 42 lines
Quoted 30 lines
Quoted 30 lines

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -0
index a768774c89..f27a18905d 100644
@@ -29,9 +29,8 @@
 #define le32_to_cpu	rte_le_to_cpu_32
 #define le16_to_cpu	rte_le_to_cpu_16
 
Quoted 11 lines

drivers/bus/fslmc/mc/fsl_mc_cmd.h line 33

Quoted 4 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +1 -2
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))

Inside
There are macros: RTE_GENMASK64 (and RTE_GENMASK32). Which as I understand does same thing.
Might be better to just use these ones instead of hand-crafting same thing over different PMDs.

Quoted 4 lines

I agree. I can submit a separate patch for that once this series aimed at unblocking MSVC from being used on this code goes in, if that is OK. If instead you feel strongly that this change should be made as part of this series let me know.

Quoted 5 lines

I am fine anyway.
Just thought that doing something like:
#define GENMASK(h, l) RTE_GENMASK64(h, l)
Would be less work for you and less code churn.

I thought about that option too, but getting rid of that "redefine" and just replace all occurrences of GENMASK would be better I think, despite the code churn.

Quoted 8 lines
Quoted 8 lines

--
Andre Muezerie

Quoted 5 lines
Quoted 5 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -1
 struct mc_cmd_header {
 	union {
--

2.47.0.vfs.0.3

#17 lore raw

Re: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

06/12/2024 19:14, Andre Muezerie:

Quoted 54 lines · Konstantin Ananyev
Quoted 47 lines
Quoted 42 lines
Quoted 30 lines
Quoted 30 lines

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bus/fslmc/mc/fsl_mc_cmd.h +0 -0
index a768774c89..f27a18905d 100644
@@ -29,9 +29,8 @@
 #define le32_to_cpu	rte_le_to_cpu_32
 #define le16_to_cpu	rte_le_to_cpu_16
 
Quoted 11 lines

drivers/bus/fslmc/mc/fsl_mc_cmd.h line 33

Quoted 4 lines
drivers/bus/fslmc/mc/fsl_mc_cmd.h +1 -2
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))

Inside
There are macros: RTE_GENMASK64 (and RTE_GENMASK32). Which as I understand does same thing.
Might be better to just use these ones instead of hand-crafting same thing over different PMDs.

Quoted 4 lines

I agree. I can submit a separate patch for that once this series aimed at unblocking MSVC from being used on this code goes in, if that is OK. If instead you feel strongly that this change should be made as part of this series let me know.

Quoted 5 lines

I am fine anyway.
Just thought that doing something like:
#define GENMASK(h, l) RTE_GENMASK64(h, l)
Would be less work for you and less code churn.

Quoted 3 lines

I thought about that option too, but getting rid of that "redefine" and just replace all occurrences of GENMASK would be better I think, despite the code churn.

Yes please, it is better to remove these macros and directly use RTE_ equivalents where needed. Thanks.

#18 lore raw

PATCH v3 3/7 drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/common/cnxk/cnxk_security_ar.h |  4 ++--
 drivers/common/cnxk/roc_bits.h         | 13 ++++---------
 drivers/common/cnxk/roc_ie_ot.h        |  4 ++--
 drivers/common/cnxk/roc_ie_ot_tls.h    |  5 +++--
 drivers/common/cnxk/roc_platform.h     |  2 ++
 drivers/common/nfp/nfp_platform.h      |  8 +++-----
 6 files changed, 16 insertions(+), 20 deletions(-)
drivers/common/cnxk/cnxk_security_ar.h +2 -2
index d0151a752c..9e88d0063b 100644
@@ -13,8 +13,8 @@
 
 /* u64 array size to fit anti replay window bits */
 #define AR_WIN_ARR_SZ                                                          \
-	(PLT_ALIGN_CEIL(CNXK_ON_AR_WIN_SIZE_MAX + 1, BITS_PER_LONG_LONG) /     \
-	 BITS_PER_LONG_LONG)
+	(PLT_ALIGN_CEIL(CNXK_ON_AR_WIN_SIZE_MAX + 1, PLT_BITS_PER_LONG_LONG) /     \
+	 PLT_BITS_PER_LONG_LONG)
 
 #define WORD_SHIFT 6
 #define WORD_SIZE  (1ULL << WORD_SHIFT)
drivers/common/cnxk/roc_bits.h +4 -9
index 11216d9d63..654e5a85d7 100644
@@ -5,6 +5,8 @@
 #ifndef _ROC_BITS_H_
 #define _ROC_BITS_H_
 
+#include <rte_common.h>
+
 #ifndef BIT_ULL
 #define BIT_ULL(nr) (1ULL << (nr))
 #endif
@@ -13,20 +15,13 @@
 #define BIT(nr) (1UL << (nr))
 #endif
 
-#ifndef BITS_PER_LONG
-#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
-#endif
-#ifndef BITS_PER_LONG_LONG
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
-#endif
-
 #ifndef GENMASK
-#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (PLT_BITS_PER_LONG - 1 - (h))))
 #endif
 #ifndef GENMASK_ULL
 #define GENMASK_ULL(h, l)                                                      \
 	(((~0ULL) - (1ULL << (l)) + 1) &                                       \
-	 (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+	 (~0ULL >> (PLT_BITS_PER_LONG_LONG - 1 - (h))))
 #endif
 
 #endif /* _ROC_BITS_H_ */
drivers/common/cnxk/roc_ie_ot.h +2 -2
index 1420e3d586..2d94dd3f81 100644
@@ -168,8 +168,8 @@ roc_ie_ot_ucc_is_success(uint8_t ucc)
 
 /* u64 array size to fit anti replay window bits */
 #define ROC_AR_WINBITS_SZ                                                      \
-	(PLT_ALIGN_CEIL(ROC_AR_WIN_SIZE_MAX, BITS_PER_LONG_LONG) /             \
-	 BITS_PER_LONG_LONG)
+	(PLT_ALIGN_CEIL(ROC_AR_WIN_SIZE_MAX, PLT_BITS_PER_LONG_LONG) /             \
+	 PLT_BITS_PER_LONG_LONG)
 
 #define ROC_IPSEC_ERR_RING_MAX_ENTRY 65536
 
drivers/common/cnxk/roc_ie_ot_tls.h +3 -2
index 2d6a290d9b..5df9c98b00 100644
@@ -13,8 +13,9 @@
 #define ROC_IE_OT_TLS_LOG_MIN_AR_WIN_SIZE_M1 5
 
 /* u64 array size to fit anti replay window bits */
-#define ROC_IE_OT_TLS_AR_WINBITS_SZ                                                                \
-	(PLT_ALIGN_CEIL(ROC_IE_OT_TLS_AR_WIN_SIZE_MAX, BITS_PER_LONG_LONG) / BITS_PER_LONG_LONG)
+#define ROC_IE_OT_TLS_AR_WINBITS_SZ                                           \
+	(PLT_ALIGN_CEIL(ROC_IE_OT_TLS_AR_WIN_SIZE_MAX, PLT_BITS_PER_LONG_LONG) /  \
+	PLT_BITS_PER_LONG_LONG)
 
 /* CN10K TLS opcodes */
 #define ROC_IE_OT_TLS_MAJOR_OP_RECORD_ENC   0x16UL
drivers/common/cnxk/roc_platform.h +2 -0
index df4f88f288..6abbc672cc 100644
@@ -58,6 +58,8 @@
 #define PLT_ALIGN		 RTE_ALIGN
 #define PLT_ALIGN_MUL_CEIL	 RTE_ALIGN_MUL_CEIL
 #define PLT_MODEL_MZ_NAME	 "roc_model_mz"
+#define PLT_BITS_PER_LONG		 RTE_BITS_PER_LONG
+#define PLT_BITS_PER_LONG_LONG	 RTE_BITS_PER_LONG_LONG
 #define PLT_CACHE_LINE_SIZE	 RTE_CACHE_LINE_SIZE
 #define BITMASK_ULL		 GENMASK_ULL
 #define PLT_ALIGN_CEIL		 RTE_ALIGN_CEIL
drivers/common/nfp/nfp_platform.h +3 -5
index 0b02fcf1e8..e34781a88d 100644
@@ -9,19 +9,17 @@
 #include <stdint.h>
 
 #include <rte_bitops.h>
+#include <rte_common.h>
 
 #define DIV_ROUND_UP(n, d)             (((n) + (d) - 1) / (d))
 
 #define DMA_BIT_MASK(n)    ((1ULL << (n)) - 1)
 
-#define BITS_PER_LONG      (__SIZEOF_LONG__ * 8)
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
-
 #define GENMASK(h, l) \
-	((~0UL << (l)) & (~0UL >> (BITS_PER_LONG - (h) - 1)))
+	((~0UL << (l)) & (~0UL >> (RTE_BITS_PER_LONG - (h) - 1)))
 
 #define GENMASK_ULL(h, l) \
-	((~0ULL << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - (h) - 1)))
+	((~0ULL << (l)) & (~0ULL >> (RTE_BITS_PER_LONG_LONG - (h) - 1)))
 
 #define __bf_shf(x) rte_bsf64(x)
 
Signature · 1 line
2.47.0.vfs.0.3
#19 lore raw

PATCH v3 4/7 drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/dma/dpaa/dpaa_qdma.h        | 3 +--
 drivers/dma/hisilicon/hisi_dmadev.h | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/dma/dpaa/dpaa_qdma.h +1 -2
index 91eaf1455a..617e15fbc4 100644
@@ -14,9 +14,8 @@
 #define RETRIES	5
 
 #ifndef GENMASK
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 #endif
 
 #define QDMA_CTRL_REGION_OFFSET 0
drivers/dma/hisilicon/hisi_dmadev.h +1 -2
index 786fe3cc0e..d1b4ae7da8 100644
@@ -12,9 +12,8 @@
 #include <rte_dmadev_pmd.h>
 
 #define BIT(x)	(1ul << (x))
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 #define BF_SHF(x) rte_bsf64(x)
 #define FIELD_GET(mask, reg) \
 		((typeof(mask))(((reg) & (mask)) >> BF_SHF(mask)))
Signature · 1 line
2.47.0.vfs.0.3
#20 lore raw

PATCH v3 5/7 drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 6 ++----
 drivers/net/hns3/hns3_ethdev.h       | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +2 -4
index 1121460470..63f6ef70ee 100644
@@ -97,14 +97,12 @@ extern int ena_logtype_com;
 #define ENA_MIN16(x, y) ENA_MIN_T(uint16_t, (x), (y))
 #define ENA_MIN8(x, y) ENA_MIN_T(uint8_t, (x), (y))
 
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
 #define U64_C(x) x ## ULL
 #define BIT(nr)	RTE_BIT32(nr)
 #define BIT64(nr)	RTE_BIT64(nr)
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
-#define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 #define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) &		       \
-			  (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+			  (~0ULL >> (RTE_BITS_PER_LONG_LONG - 1 - (h))))
 
 #define ena_trc_log(dev, level, fmt, arg...)				       \
 	(								       \
drivers/net/hns3/hns3_ethdev.h +1 -2
index 7824503bb8..c7ad9a61c7 100644
@@ -952,9 +952,8 @@ static inline struct hns3_vf *HNS3_DEV_HW_TO_VF(struct hns3_hw *hw)
 
 #define BIT_ULL(x) (1ULL << (x))
 
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+	(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 
 #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
 #define rounddown(x, y) ((x) - ((x) % (y)))
Signature · 1 line
2.47.0.vfs.0.3
#21 lore raw

PATCH v3 6/7 drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/raw/ifpga/base/opae_osdep.h | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/raw/ifpga/base/opae_osdep.h +4 -8
index cb780b1fed..e4767e2d7a 100644
@@ -9,6 +9,8 @@
 #include <stdbool.h>
 #include <pthread.h>
 
+#include <rte_common.h>
+
 #ifdef RTE_LIB_EAL
 #include "osdep_rte/osdep_generic.h"
 #else
@@ -30,12 +32,6 @@ struct uuid {
 };
 
 #ifndef LINUX_MACROS
-#ifndef BITS_PER_LONG
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
-#endif
-#ifndef BITS_PER_LONG_LONG
-#define BITS_PER_LONG_LONG  (__SIZEOF_LONG_LONG__ * 8)
-#endif
 #ifndef BIT
 #define BIT(a) (1UL << (a))
 #endif /* BIT */
@@ -43,11 +39,11 @@ struct uuid {
 #define BIT_ULL(a) (1ULL << (a))
 #endif /* BIT_ULL */
 #ifndef GENMASK
-#define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 #endif /* GENMASK */
 #ifndef GENMASK_ULL
 #define GENMASK_ULL(h, l) \
-	(((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+	(((~0ULL) << (l)) & (~0ULL >> (RTE_BITS_PER_LONG_LONG - 1 - (h))))
 #endif /* GENMASK_ULL */
 #endif /* LINUX_MACROS */
 
Signature · 1 line
2.47.0.vfs.0.3
#22 lore raw

PATCH v3 7/7 lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 lib/mldev/mldev_utils_scalar.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
lib/mldev/mldev_utils_scalar.h +1 -5
index 57e66ddb60..a9462089d7 100644
@@ -12,12 +12,8 @@
 #define BIT(nr) (1UL << (nr))
 #endif
 
-#ifndef BITS_PER_LONG
-#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
-#endif
-
 #ifndef GENMASK_U32
-#define GENMASK_U32(h, l) (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#define GENMASK_U32(h, l) (((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 #endif
 
 /* float32: bit index of MSB & LSB of sign, exponent and mantissa */
Signature · 1 line
2.47.0.vfs.0.3
#23 lore raw

v4 cover eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

v4:
* rebased on latest main as previous patch was not applying cleanly anymore.

v3:
* added prefix RTE_ to BITS_PER_LONG* and moved them to rte_common.h
* defined PLT_BITS_PER_LONG* in drivers/common/cnxk/roc_platform.h to avoid warnings from checkpatches.sh like:

Warning in drivers/common/cnxk/roc_bits.h:
Warning in drivers/common/cnxk/roc_ie_ot.h:
Warning in drivers/common/cnxk/roc_ie_ot_tls.h:
Use plt_ symbols instead of rte_ API in cnxk base driver

It can be seen that the same was done in the past for similar macros like PLT_CACHE_LINE_SIZE

v2:
* fixed typo in commit message

Andre Muezerie (7):
eal: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__
mldev: eliminate dependency on non-portable __SIZEOF_LONG__

 drivers/bus/fslmc/mc/fsl_mc_cmd.h      |  3 +--
 drivers/common/cnxk/cnxk_security_ar.h |  4 ++--
 drivers/common/cnxk/roc_bits.h         | 13 ++++---------
 drivers/common/cnxk/roc_ie_ot.h        |  4 ++--
 drivers/common/cnxk/roc_ie_ot_tls.h    |  5 +++--
 drivers/common/cnxk/roc_platform.h     |  2 ++
 drivers/common/nfp/nfp_platform.h      |  8 +++-----
 drivers/dma/dpaa/dpaa_qdma.h           |  3 +--
 drivers/dma/hisilicon/hisi_dmadev.h    |  3 +--
 drivers/net/ena/base/ena_plat_dpdk.h   |  6 ++----
 drivers/net/hns3/hns3_ethdev.h         |  3 +--
 drivers/raw/ifpga/base/opae_osdep.h    | 12 ++++--------
 lib/eal/include/rte_common.h           |  5 +++++
 lib/mldev/mldev_utils_scalar.h         |  6 +-----
 14 files changed, 32 insertions(+), 45 deletions(-)

--
2.47.2.vfs.0.1

#24 lore raw

PATCH v4 1/7 eal: eliminate dependency on non-portable __SIZEOF_LONG__

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 lib/eal/include/rte_common.h | 5 +++++
 1 file changed, 5 insertions(+)
lib/eal/include/rte_common.h +5 -0
index 7a252c1997..47e3201006 100644
@@ -679,6 +679,11 @@ rte_is_aligned(const void * const __rte_restrict ptr, const unsigned int align)
  */
 #define RTE_BUILD_BUG_ON(condition) do { static_assert(!(condition), #condition); } while (0)
 
+/*********** Data type size related macros ********/
+
+#define RTE_BITS_PER_LONG (sizeof(long) * 8)
+#define RTE_BITS_PER_LONG_LONG (sizeof(long long) * 8)
+
 /*********** Cache line related macros ********/
 
 /** Cache line mask. */
Signature · 1 line
2.47.2.vfs.0.1
#25 lore raw

PATCH v4 2/7 drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bus/fslmc/mc/fsl_mc_cmd.h +1 -2
index a768774c89..f27a18905d 100644
@@ -29,9 +29,8 @@
 #define le32_to_cpu	rte_le_to_cpu_32
 #define le16_to_cpu	rte_le_to_cpu_16
 
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 
 struct mc_cmd_header {
 	union {
Signature · 1 line
2.47.2.vfs.0.1
#26 lore raw

PATCH v4 3/7 drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/common/cnxk/cnxk_security_ar.h |  4 ++--
 drivers/common/cnxk/roc_bits.h         | 13 ++++---------
 drivers/common/cnxk/roc_ie_ot.h        |  4 ++--
 drivers/common/cnxk/roc_ie_ot_tls.h    |  5 +++--
 drivers/common/cnxk/roc_platform.h     |  2 ++
 drivers/common/nfp/nfp_platform.h      |  8 +++-----
 6 files changed, 16 insertions(+), 20 deletions(-)
drivers/common/cnxk/cnxk_security_ar.h +2 -2
index d0151a752c..9e88d0063b 100644
@@ -13,8 +13,8 @@
 
 /* u64 array size to fit anti replay window bits */
 #define AR_WIN_ARR_SZ                                                          \
-	(PLT_ALIGN_CEIL(CNXK_ON_AR_WIN_SIZE_MAX + 1, BITS_PER_LONG_LONG) /     \
-	 BITS_PER_LONG_LONG)
+	(PLT_ALIGN_CEIL(CNXK_ON_AR_WIN_SIZE_MAX + 1, PLT_BITS_PER_LONG_LONG) /     \
+	 PLT_BITS_PER_LONG_LONG)
 
 #define WORD_SHIFT 6
 #define WORD_SIZE  (1ULL << WORD_SHIFT)
drivers/common/cnxk/roc_bits.h +4 -9
index 11216d9d63..654e5a85d7 100644
@@ -5,6 +5,8 @@
 #ifndef _ROC_BITS_H_
 #define _ROC_BITS_H_
 
+#include <rte_common.h>
+
 #ifndef BIT_ULL
 #define BIT_ULL(nr) (1ULL << (nr))
 #endif
@@ -13,20 +15,13 @@
 #define BIT(nr) (1UL << (nr))
 #endif
 
-#ifndef BITS_PER_LONG
-#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
-#endif
-#ifndef BITS_PER_LONG_LONG
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
-#endif
-
 #ifndef GENMASK
-#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (PLT_BITS_PER_LONG - 1 - (h))))
 #endif
 #ifndef GENMASK_ULL
 #define GENMASK_ULL(h, l)                                                      \
 	(((~0ULL) - (1ULL << (l)) + 1) &                                       \
-	 (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+	 (~0ULL >> (PLT_BITS_PER_LONG_LONG - 1 - (h))))
 #endif
 
 #endif /* _ROC_BITS_H_ */
drivers/common/cnxk/roc_ie_ot.h +2 -2
index 1420e3d586..bfefe792b0 100644
@@ -168,8 +168,8 @@ roc_ie_ot_ucc_is_success(uint8_t ucc)
 
 /* u64 array size to fit anti replay window bits */
 #define ROC_AR_WINBITS_SZ                                                      \
-	(PLT_ALIGN_CEIL(ROC_AR_WIN_SIZE_MAX, BITS_PER_LONG_LONG) /             \
-	 BITS_PER_LONG_LONG)
+	(PLT_ALIGN_CEIL(ROC_AR_WIN_SIZE_MAX, PLT_BITS_PER_LONG_LONG) /         \
+	 PLT_BITS_PER_LONG_LONG)
 
 #define ROC_IPSEC_ERR_RING_MAX_ENTRY 65536
 
drivers/common/cnxk/roc_ie_ot_tls.h +3 -2
index 2d6a290d9b..ff86bcb877 100644
@@ -13,8 +13,9 @@
 #define ROC_IE_OT_TLS_LOG_MIN_AR_WIN_SIZE_M1 5
 
 /* u64 array size to fit anti replay window bits */
-#define ROC_IE_OT_TLS_AR_WINBITS_SZ                                                                \
-	(PLT_ALIGN_CEIL(ROC_IE_OT_TLS_AR_WIN_SIZE_MAX, BITS_PER_LONG_LONG) / BITS_PER_LONG_LONG)
+#define ROC_IE_OT_TLS_AR_WINBITS_SZ                                               \
+	(PLT_ALIGN_CEIL(ROC_IE_OT_TLS_AR_WIN_SIZE_MAX, PLT_BITS_PER_LONG_LONG) /  \
+	PLT_BITS_PER_LONG_LONG)
 
 /* CN10K TLS opcodes */
 #define ROC_IE_OT_TLS_MAJOR_OP_RECORD_ENC   0x16UL
drivers/common/cnxk/roc_platform.h +2 -0
index 1eb54446a8..1ed03430f9 100644
@@ -58,6 +58,8 @@
 #define PLT_ALIGN		 RTE_ALIGN
 #define PLT_ALIGN_MUL_CEIL	 RTE_ALIGN_MUL_CEIL
 #define PLT_MODEL_MZ_NAME	 "roc_model_mz"
+#define PLT_BITS_PER_LONG	 RTE_BITS_PER_LONG
+#define PLT_BITS_PER_LONG_LONG	 RTE_BITS_PER_LONG_LONG
 #define PLT_CACHE_LINE_SIZE	 RTE_CACHE_LINE_SIZE
 #define BITMASK_ULL		 GENMASK_ULL
 #define PLT_ALIGN_CEIL		 RTE_ALIGN_CEIL
drivers/common/nfp/nfp_platform.h +3 -5
index 0b02fcf1e8..e34781a88d 100644
@@ -9,19 +9,17 @@
 #include <stdint.h>
 
 #include <rte_bitops.h>
+#include <rte_common.h>
 
 #define DIV_ROUND_UP(n, d)             (((n) + (d) - 1) / (d))
 
 #define DMA_BIT_MASK(n)    ((1ULL << (n)) - 1)
 
-#define BITS_PER_LONG      (__SIZEOF_LONG__ * 8)
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
-
 #define GENMASK(h, l) \
-	((~0UL << (l)) & (~0UL >> (BITS_PER_LONG - (h) - 1)))
+	((~0UL << (l)) & (~0UL >> (RTE_BITS_PER_LONG - (h) - 1)))
 
 #define GENMASK_ULL(h, l) \
-	((~0ULL << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - (h) - 1)))
+	((~0ULL << (l)) & (~0ULL >> (RTE_BITS_PER_LONG_LONG - (h) - 1)))
 
 #define __bf_shf(x) rte_bsf64(x)
 
Signature · 1 line
2.47.2.vfs.0.1
#27 lore raw

PATCH v4 4/7 drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/dma/dpaa/dpaa_qdma.h        | 3 +--
 drivers/dma/hisilicon/hisi_dmadev.h | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/dma/dpaa/dpaa_qdma.h +1 -2
index 0b08909221..c017bec48f 100644
@@ -14,9 +14,8 @@
 #define RETRIES	5
 
 #ifndef GENMASK
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 #endif
 
 #define QDMA_CTRL_REGION_OFFSET 0
drivers/dma/hisilicon/hisi_dmadev.h +1 -2
index 786fe3cc0e..d1b4ae7da8 100644
@@ -12,9 +12,8 @@
 #include <rte_dmadev_pmd.h>
 
 #define BIT(x)	(1ul << (x))
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+		(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 #define BF_SHF(x) rte_bsf64(x)
 #define FIELD_GET(mask, reg) \
 		((typeof(mask))(((reg) & (mask)) >> BF_SHF(mask)))
Signature · 1 line
2.47.2.vfs.0.1
#28 lore raw

PATCH v4 5/7 drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 6 ++----
 drivers/net/hns3/hns3_ethdev.h       | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +2 -4
index 3b574f888a..8ab1442c22 100644
@@ -97,14 +97,12 @@ extern int ena_logtype_com;
 #define ENA_MIN16(x, y) ENA_MIN_T(uint16_t, (x), (y))
 #define ENA_MIN8(x, y) ENA_MIN_T(uint8_t, (x), (y))
 
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
 #define U64_C(x) x ## ULL
 #define BIT(nr)	RTE_BIT32(nr)
 #define BIT64(nr)	RTE_BIT64(nr)
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
-#define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 #define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) &		       \
-			  (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+			  (~0ULL >> (RTE_BITS_PER_LONG_LONG - 1 - (h))))
 
 #define ena_trc_log(dev, level, fmt, ...)				       \
 	(								       \
drivers/net/hns3/hns3_ethdev.h +1 -2
index 7824503bb8..c7ad9a61c7 100644
@@ -952,9 +952,8 @@ static inline struct hns3_vf *HNS3_DEV_HW_TO_VF(struct hns3_hw *hw)
 
 #define BIT_ULL(x) (1ULL << (x))
 
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l) \
-	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+	(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 
 #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
 #define rounddown(x, y) ((x) - ((x) % (y)))
Signature · 1 line
2.47.2.vfs.0.1
#29 lore raw

PATCH v4 6/7 drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 drivers/raw/ifpga/base/opae_osdep.h | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/raw/ifpga/base/opae_osdep.h +4 -8
index e35a21c80e..af61716f61 100644
@@ -9,6 +9,8 @@
 #include <stdbool.h>
 #include <pthread.h>
 
+#include <rte_common.h>
+
 #ifdef RTE_LIB_EAL
 #include "osdep_rte/osdep_generic.h"
 #else
@@ -30,12 +32,6 @@ struct uuid {
 };
 
 #ifndef LINUX_MACROS
-#ifndef BITS_PER_LONG
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
-#endif
-#ifndef BITS_PER_LONG_LONG
-#define BITS_PER_LONG_LONG  (__SIZEOF_LONG_LONG__ * 8)
-#endif
 #ifndef BIT
 #define BIT(a) (1UL << (a))
 #endif /* BIT */
@@ -43,11 +39,11 @@ struct uuid {
 #define BIT_ULL(a) (1ULL << (a))
 #endif /* BIT_ULL */
 #ifndef GENMASK
-#define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 #endif /* GENMASK */
 #ifndef GENMASK_ULL
 #define GENMASK_ULL(h, l) \
-	(((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+	(((~0ULL) << (l)) & (~0ULL >> (RTE_BITS_PER_LONG_LONG - 1 - (h))))
 #endif /* GENMASK_ULL */
 #endif /* LINUX_MACROS */
 
Signature · 1 line
2.47.2.vfs.0.1
#30 lore raw

PATCH v4 7/7 mldev: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

---
 lib/mldev/mldev_utils_scalar.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
lib/mldev/mldev_utils_scalar.h +1 -5
index 57e66ddb60..a9462089d7 100644
@@ -12,12 +12,8 @@
 #define BIT(nr) (1UL << (nr))
 #endif
 
-#ifndef BITS_PER_LONG
-#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
-#endif
-
 #ifndef GENMASK_U32
-#define GENMASK_U32(h, l) (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#define GENMASK_U32(h, l) (((~0UL) << (l)) & (~0UL >> (RTE_BITS_PER_LONG - 1 - (h))))
 #endif
 
 /* float32: bit index of MSB & LSB of sign, exponent and mantissa */
Signature · 1 line
2.47.2.vfs.0.1
#31 lore raw
In reply to Andre Muezerie
Quoted 36 lines · Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

v4:
* rebased on latest main as previous patch was not applying cleanly anymore.

v3:
* added prefix RTE_ to BITS_PER_LONG* and moved them to rte_common.h
* defined PLT_BITS_PER_LONG* in drivers/common/cnxk/roc_platform.h to avoid warnings from checkpatches.sh like:

Warning in drivers/common/cnxk/roc_bits.h:
Warning in drivers/common/cnxk/roc_ie_ot.h:
Warning in drivers/common/cnxk/roc_ie_ot_tls.h:
Use plt_ symbols instead of rte_ API in cnxk base driver

It can be seen that the same was done in the past for similar macros like PLT_CACHE_LINE_SIZE

v2:
* fixed typo in commit message

Quoted 9 lines

Andre Muezerie (7):
eal: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__
mldev: eliminate dependency on non-portable __SIZEOF_LONG__

Just out of interest, is there are reason why the simple solution of just putting "#define __SIZEOF_LONG__ (sizeof(long))" in a header file for MSVC is not done? Should be a couple of lines in a single patch, rather than a 7-patch series, no?

After all, just because something is non-standard, doesn't mean that we can't use it if its widely available.

/Bruce

#32 lore raw
Quoted 51 lines · Bruce Richardson
Quoted 36 lines · Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

v4:
* rebased on latest main as previous patch was not applying cleanly anymore.

v3:
* added prefix RTE_ to BITS_PER_LONG* and moved them to rte_common.h
* defined PLT_BITS_PER_LONG* in drivers/common/cnxk/roc_platform.h to avoid warnings from checkpatches.sh like:

Warning in drivers/common/cnxk/roc_bits.h:
Warning in drivers/common/cnxk/roc_ie_ot.h:
Warning in drivers/common/cnxk/roc_ie_ot_tls.h:
Use plt_ symbols instead of rte_ API in cnxk base driver

It can be seen that the same was done in the past for similar macros like PLT_CACHE_LINE_SIZE

v2:
* fixed typo in commit message

Quoted 9 lines

Andre Muezerie (7):
eal: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__
mldev: eliminate dependency on non-portable __SIZEOF_LONG__

Just out of interest, is there are reason why the simple solution of just putting "#define __SIZEOF_LONG__ (sizeof(long))" in a header file for MSVC is not done? Should be a couple of lines in a single patch, rather than a 7-patch series, no?

Quoted 4 lines

After all, just because something is non-standard, doesn't mean that we can't use it if its widely available.

/Bruce

Yes, that can be done instead. I'll send out a new series with that approach.

#33 lore raw
Quoted 52 lines · Andre Muezerie
Quoted 51 lines · Bruce Richardson
Quoted 36 lines · Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

v4:
* rebased on latest main as previous patch was not applying cleanly anymore.

v3:
* added prefix RTE_ to BITS_PER_LONG* and moved them to rte_common.h
* defined PLT_BITS_PER_LONG* in drivers/common/cnxk/roc_platform.h to avoid warnings from checkpatches.sh like:

Warning in drivers/common/cnxk/roc_bits.h:
Warning in drivers/common/cnxk/roc_ie_ot.h:
Warning in drivers/common/cnxk/roc_ie_ot_tls.h:
Use plt_ symbols instead of rte_ API in cnxk base driver

It can be seen that the same was done in the past for similar macros like PLT_CACHE_LINE_SIZE

v2:
* fixed typo in commit message

Quoted 9 lines

Andre Muezerie (7):
eal: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__
mldev: eliminate dependency on non-portable __SIZEOF_LONG__

Just out of interest, is there are reason why the simple solution of just putting "#define __SIZEOF_LONG__ (sizeof(long))" in a header file for MSVC is not done? Should be a couple of lines in a single patch, rather than a 7-patch series, no?

Quoted 7 lines
Quoted 4 lines

After all, just because something is non-standard, doesn't mean that we can't use it if its widely available.

/Bruce

Yes, that can be done instead. I'll send out a new series with that approach.

Maybe wait in case there is input from others before spending time on a patch? I think the simpler solution is better, but others may feel that removing the macro completely is the better approach.

/Bruce

#34 lore raw
Quoted 57 lines · Andre Muezerie
Quoted 55 lines · Bruce Richardson
Quoted 54 lines · Andre Muezerie
Quoted 36 lines

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

v4:
* rebased on latest main as previous patch was not applying cleanly anymore.

v3:
* added prefix RTE_ to BITS_PER_LONG* and moved them to rte_common.h
* defined PLT_BITS_PER_LONG* in drivers/common/cnxk/roc_platform.h to avoid warnings from checkpatches.sh like:

Warning in drivers/common/cnxk/roc_bits.h:
Warning in drivers/common/cnxk/roc_ie_ot.h:
Warning in drivers/common/cnxk/roc_ie_ot_tls.h:
Use plt_ symbols instead of rte_ API in cnxk base driver

It can be seen that the same was done in the past for similar macros like PLT_CACHE_LINE_SIZE

v2:
* fixed typo in commit message

Quoted 9 lines

Andre Muezerie (7):
eal: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__
mldev: eliminate dependency on non-portable __SIZEOF_LONG__

Just out of interest, is there are reason why the simple solution of just putting "#define __SIZEOF_LONG__ (sizeof(long))" in a header file for MSVC is not done? Should be a couple of lines in a single patch, rather than a 7-patch series, no?

After all, just because something is non-standard, doesn't mean that we can't use it if its widely available.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

/Bruce

Yes, that can be done instead. I'll send out a new series with that approach.

Maybe wait in case there is input from others before spending time on a patch? I think the simpler solution is better, but others may feel that removing the macro completely is the better approach.

+1 to what Bruce suggested.

#35 lore raw
Quoted 59 lines · Konstantin Ananyev
Quoted 59 lines · Andre Muezerie
Quoted 57 lines · Bruce Richardson
Quoted 55 lines · Andre Muezerie
Quoted 36 lines

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equally well use sizeof(long) instead.

v4:
* rebased on latest main as previous patch was not applying cleanly anymore.

v3:
* added prefix RTE_ to BITS_PER_LONG* and moved them to rte_common.h
* defined PLT_BITS_PER_LONG* in drivers/common/cnxk/roc_platform.h to avoid warnings from checkpatches.sh like:

Warning in drivers/common/cnxk/roc_bits.h:
Warning in drivers/common/cnxk/roc_ie_ot.h:
Warning in drivers/common/cnxk/roc_ie_ot_tls.h:
Use plt_ symbols instead of rte_ API in cnxk base driver

It can be seen that the same was done in the past for similar macros like PLT_CACHE_LINE_SIZE

v2:
* fixed typo in commit message

Quoted 9 lines

Andre Muezerie (7):
eal: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__
mldev: eliminate dependency on non-portable __SIZEOF_LONG__

Just out of interest, is there are reason why the simple solution of just putting "#define __SIZEOF_LONG__ (sizeof(long))" in a header file for MSVC is not done? Should be a couple of lines in a single patch, rather than a 7-patch series, no?

After all, just because something is non-standard, doesn't mean that we can't use it if its widely available.

/Bruce

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Yes, that can be done instead. I'll send out a new series with that approach.

Maybe wait in case there is input from others before spending time on a patch? I think the simpler solution is better, but others may feel that removing the macro completely is the better approach.

+1 to what Bruce suggested.

Thomas also mentioned he would prefer to minimize changes. I'm fine with that too, as that is good enough to get the code to compile with MSVC.

#36 lore raw

PATCH v5 1/1 eal: define __SIZEOF_LONG__ when using MSVC

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

The fix is to define __SIZEOF_LONG__ in a common header when MSVC is used.

---
 lib/eal/include/rte_compat.h | 5 +++++
 1 file changed, 5 insertions(+)
lib/eal/include/rte_compat.h +5 -0
index 97c1540bd0..6676a1bb13 100644
@@ -66,4 +66,9 @@ __attribute__((section(".text.internal")))
 
 #endif
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __SIZEOF_LONG__		(sizeof(long))
+#define __SIZEOF_LONG_LONG__	(sizeof(long long))
+#endif
+
 #endif /* _RTE_COMPAT_H_ */
Signature · 1 line
2.47.2.vfs.0.1
#37 lore raw

Re: [PATCH v5] eal: define __SIZEOF_LONG__ when using MSVC

Quoted 14 lines · Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Quoted 7 lines

The fix is to define __SIZEOF_LONG__ in a common header when MSVC is used.

---
 lib/eal/include/rte_compat.h | 5 +++++
 1 file changed, 5 insertions(+)

rte_compat only deals with symbol versioning. I think a better location would be windows/rte_os.h.

Signature · 1 line
David Marchand
#38 lore raw

Re: [PATCH v5] eal: define __SIZEOF_LONG__ when using MSVC

Quoted 19 lines · David Marchand
Quoted 17 lines · Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

The fix is to define __SIZEOF_LONG__ in a common header when MSVC is used.

Quoted 12 lines
Quoted 4 lines
---
 lib/eal/include/rte_compat.h | 5 +++++
 1 file changed, 5 insertions(+)

rte_compat only deals with symbol versioning. I think a better location would be windows/rte_os.h.

Signature · 1 line
David Marchand

Thanks for the suggestion. I updated the patch accordingly.

#39 lore raw

PATCH v6 1/1 eal: define __SIZEOF_LONG__ when using MSVC

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

The fix is to define __SIZEOF_LONG__ in a common header when MSVC is used.

---
 lib/eal/windows/include/rte_os.h | 5 +++++
 1 file changed, 5 insertions(+)
lib/eal/windows/include/rte_os.h +5 -0
index d09adeb3b4..c787027866 100644
@@ -56,4 +56,9 @@ struct { \
  */
 typedef long long ssize_t;
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __SIZEOF_LONG__		(sizeof(long))
+#define __SIZEOF_LONG_LONG__	(sizeof(long long))
+#endif
+
 #endif /* _RTE_OS_H_ */
Signature · 1 line
2.47.2.vfs.0.1
Acked-by on v6 1/1
#40 lore raw

Re: [PATCH v6] eal: define __SIZEOF_LONG__ when using MSVC

Quoted 13 lines · Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Quoted 8 lines

The fix is to define __SIZEOF_LONG__ in a common header when MSVC is used.

---
 lib/eal/windows/include/rte_os.h | 5 +++++
 1 file changed, 5 insertions(+)
Acked-by on v6 1/1
#41 lore raw

RE: [PATCH v6] eal: define __SIZEOF_LONG__ when using MSVC

In reply to Andre Muezerie
Quoted 27 lines

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

The fix is to define __SIZEOF_LONG__ in a common header when MSVC is used.

---
 lib/eal/windows/include/rte_os.h | 5 +++++
 1 file changed, 5 insertions(+)
lib/eal/windows/include/rte_os.h +0 -0
index d09adeb3b4..c787027866 100644

lib/eal/windows/include/rte_os.h struct { \

Quoted 10 lines
lib/eal/windows/include/rte_os.h +5 -1
@@ -56,4 +56,9 @@ struct { \
  */
 typedef long long ssize_t;
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __SIZEOF_LONG__		(sizeof(long))
+#define __SIZEOF_LONG_LONG__	(sizeof(long long))
+#endif
+
 #endif /* _RTE_OS_H_ */
--
Quoted 1 line

2.47.2.vfs.0.1

#42 lore raw

Re: [PATCH v6] eal: define __SIZEOF_LONG__ when using MSVC

In reply to Andre Muezerie
Quoted 14 lines · Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Quoted 4 lines

The fix is to define __SIZEOF_LONG__ in a common header when MSVC is used.

Applied, thanks.

Signature · 1 line
David Marchand
#43 lore raw

PATCH 2/6 drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equaly well use sizeof(long) instead.

---
 drivers/common/cnxk/roc_bits.h    | 4 ++--
 drivers/common/nfp/nfp_platform.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/common/cnxk/roc_bits.h +2 -2
index 11216d9d63..aa4944ae7f 100644
@@ -14,10 +14,10 @@
 #endif
 
 #ifndef BITS_PER_LONG
-#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG (sizeof(long) * 8)
 #endif
 #ifndef BITS_PER_LONG_LONG
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
+#define BITS_PER_LONG_LONG (sizeof(long long) * 8)
 #endif
 
 #ifndef GENMASK
drivers/common/nfp/nfp_platform.h +2 -2
index 0b02fcf1e8..27792aca97 100644
@@ -14,8 +14,8 @@
 
 #define DMA_BIT_MASK(n)    ((1ULL << (n)) - 1)
 
-#define BITS_PER_LONG      (__SIZEOF_LONG__ * 8)
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
+#define BITS_PER_LONG      (sizeof(long) * 8)
+#define BITS_PER_LONG_LONG (sizeof(long long) * 8)
 
 #define GENMASK(h, l) \
 	((~0UL << (l)) & (~0UL >> (BITS_PER_LONG - (h) - 1)))
Signature · 1 line
2.47.0.vfs.0.3
Acked-by on v1 2/6
#44 lore raw

RE: [PATCH 2/6] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__

Quoted 45 lines

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equaly well use sizeof(long) instead.

---
 drivers/common/cnxk/roc_bits.h    | 4 ++--
 drivers/common/nfp/nfp_platform.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/common/cnxk/roc_bits.h index 11216d9d63..aa4944ae7f 100644

drivers/common/cnxk/roc_bits.h +2 -2
@@ -14,10 +14,10 @@
 #endif
 
 #ifndef BITS_PER_LONG
-#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG (sizeof(long) * 8)
 #endif
 #ifndef BITS_PER_LONG_LONG
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
+#define BITS_PER_LONG_LONG (sizeof(long long) * 8)
 #endif
 
 #ifndef GENMASK
drivers/common/nfp/nfp_platform.h +0 -0
index 0b02fcf1e8..27792aca97 100644

drivers/common/nfp/nfp_platform.h line 18

Quoted 7 lines
drivers/common/nfp/nfp_platform.h +2 -2
@@ -14,8 +14,8 @@
 
 #define DMA_BIT_MASK(n)    ((1ULL << (n)) - 1)
 
-#define BITS_PER_LONG      (__SIZEOF_LONG__ * 8)
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
+#define BITS_PER_LONG      (sizeof(long) * 8)
+#define BITS_PER_LONG_LONG (sizeof(long long) * 8)

This looks good to me, thanks.

Quoted 5 lines
drivers/common/nfp/nfp_platform.h +0 -1
 #define GENMASK(h, l) \
 	((~0UL << (l)) & (~0UL >> (BITS_PER_LONG - (h) - 1)))
--

2.47.0.vfs.0.3

#45 lore raw

PATCH 3/6 drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equaly well use sizeof(long) instead.

---
 drivers/dma/dpaa/dpaa_qdma.h        | 2 +-
 drivers/dma/hisilicon/hisi_dmadev.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/dma/dpaa/dpaa_qdma.h +1 -1
index 579483ac34..3736c0d431 100644
@@ -14,7 +14,7 @@
 #define RETRIES	5
 
 #ifndef GENMASK
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #define GENMASK(h, l) \
 		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 #endif
drivers/dma/hisilicon/hisi_dmadev.h +1 -1
index 786fe3cc0e..777b9dd704 100644
@@ -12,7 +12,7 @@
 #include <rte_dmadev_pmd.h>
 
 #define BIT(x)	(1ul << (x))
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #define GENMASK(h, l) \
 		(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 #define BF_SHF(x) rte_bsf64(x)
Signature · 1 line
2.47.0.vfs.0.3
#46 lore raw

PATCH 4/6 drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equaly well use sizeof(long) instead.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 4 ++--
 drivers/net/hns3/hns3_ethdev.h       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +2 -2
index 1121460470..24e0435ac1 100644
@@ -97,11 +97,11 @@ extern int ena_logtype_com;
 #define ENA_MIN16(x, y) ENA_MIN_T(uint16_t, (x), (y))
 #define ENA_MIN8(x, y) ENA_MIN_T(uint8_t, (x), (y))
 
-#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
+#define BITS_PER_LONG_LONG (sizeof(long long) * 8)
 #define U64_C(x) x ## ULL
 #define BIT(nr)	RTE_BIT32(nr)
 #define BIT64(nr)	RTE_BIT64(nr)
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 #define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) &		       \
 			  (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
drivers/net/hns3/hns3_ethdev.h +1 -1
index 7824503bb8..207a92f832 100644
@@ -952,7 +952,7 @@ static inline struct hns3_vf *HNS3_DEV_HW_TO_VF(struct hns3_hw *hw)
 
 #define BIT_ULL(x) (1ULL << (x))
 
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #define GENMASK(h, l) \
 	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 
Signature · 1 line
2.47.0.vfs.0.3
#47 lore raw

PATCH 5/6 drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equaly well use sizeof(long) instead.

---
 drivers/raw/ifpga/base/opae_osdep.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/raw/ifpga/base/opae_osdep.h +2 -2
index cb780b1fed..bb8d2a1dd6 100644
@@ -31,10 +31,10 @@ struct uuid {
 
 #ifndef LINUX_MACROS
 #ifndef BITS_PER_LONG
-#define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG	(sizeof(long) * 8)
 #endif
 #ifndef BITS_PER_LONG_LONG
-#define BITS_PER_LONG_LONG  (__SIZEOF_LONG_LONG__ * 8)
+#define BITS_PER_LONG_LONG  (sizeof(long long) * 8)
 #endif
 #ifndef BIT
 #define BIT(a) (1UL << (a))
Signature · 1 line
2.47.0.vfs.0.3
#48 lore raw

PATCH 6/6 lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__

In reply to Andre Muezerie

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equaly well use sizeof(long) instead.

---
 lib/mldev/mldev_utils_scalar.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/mldev/mldev_utils_scalar.h +1 -1
index 57e66ddb60..d12e358fb5 100644
@@ -13,7 +13,7 @@
 #endif
 
 #ifndef BITS_PER_LONG
-#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
+#define BITS_PER_LONG (sizeof(long) * 8)
 #endif
 
 #ifndef GENMASK_U32
Signature · 1 line
2.47.0.vfs.0.3
#49 lore raw
In reply to Andre Muezerie
Quoted 35 lines · On Wed, 4 Dec 2024 12:09:49 -0800 Andre Muezerie…

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equaly well use sizeof(long) instead.

Andre Muezerie (6):
drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__ lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__

 drivers/bus/fslmc/mc/fsl_mc_cmd.h    | 2 +-
 drivers/common/cnxk/roc_bits.h       | 4 ++--
 drivers/common/nfp/nfp_platform.h    | 4 ++--
 drivers/dma/dpaa/dpaa_qdma.h         | 2 +-
 drivers/dma/hisilicon/hisi_dmadev.h  | 2 +-
 drivers/net/ena/base/ena_plat_dpdk.h | 4 ++--
 drivers/net/hns3/hns3_ethdev.h       | 2 +-
 drivers/raw/ifpga/base/opae_osdep.h  | 4 ++--
 lib/mldev/mldev_utils_scalar.h       | 2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)
Quoted 1 line

--

BITS_PER_LONG etc should be in rte_common.h not scattered all over these drivers.

#50 lore raw
Quoted 38 lines · Stephen Hemminger
Quoted 35 lines · On Wed, 4 Dec 2024 12:09:49 -0800 Andre Muezerie…

Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it. Therefore the errors below are seen with MSVC:

../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant

../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant

Turns out that the places where __SIZEOF_LONG__ is currently being used can equaly well use sizeof(long) instead.

Andre Muezerie (6):
drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__ drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__ lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__

 drivers/bus/fslmc/mc/fsl_mc_cmd.h    | 2 +-
 drivers/common/cnxk/roc_bits.h       | 4 ++--
 drivers/common/nfp/nfp_platform.h    | 4 ++--
 drivers/dma/dpaa/dpaa_qdma.h         | 2 +-
 drivers/dma/hisilicon/hisi_dmadev.h  | 2 +-
 drivers/net/ena/base/ena_plat_dpdk.h | 4 ++--
 drivers/net/hns3/hns3_ethdev.h       | 2 +-
 drivers/raw/ifpga/base/opae_osdep.h  | 4 ++--
 lib/mldev/mldev_utils_scalar.h       | 2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)
Quoted 4 lines
Quoted 1 line

--

BITS_PER_LONG etc should be in rte_common.h not scattered all over these drivers.

Makes sense. I'll update the series, but will limit the additional changes to BITS_PER_LONG and BITS_PER_LONG_LONG to limit the size of this series.
--
Andre Muezerie