DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__
@ 2024-12-04 20:09 Andre Muezerie
  2024-12-04 20:09 ` [PATCH 1/6] drivers/bus: " Andre Muezerie
                   ` (6 more replies)
  0 siblings, 7 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 20:09 UTC (permalink / raw)
  Cc: dev, 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(-)

--
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH 1/6] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
@ 2024-12-04 20:09 ` Andre Muezerie
  2024-12-04 21:41   ` [PATCH v2 0/6] " Andre Muezerie
                     ` (3 more replies)
  2024-12-04 20:09 ` [PATCH 2/6] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
                   ` (5 subsequent siblings)
  6 siblings, 4 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 20:09 UTC (permalink / raw)
  To: Hemant Agrawal, Sachin Saxena; +Cc: dev, 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
index a768774c89..10804e6c5d 100644
--- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h
+++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
@@ -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))))
 
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH 2/6] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
  2024-12-04 20:09 ` [PATCH 1/6] drivers/bus: " Andre Muezerie
@ 2024-12-04 20:09 ` Andre Muezerie
  2024-12-05  1:14   ` Chaoyong He
  2024-12-04 20:09 ` [PATCH 3/6] drivers/dma: " Andre Muezerie
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 20:09 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra, Chaoyong He
  Cc: dev, 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/common/cnxk/roc_bits.h    | 4 ++--
 drivers/common/nfp/nfp_platform.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/common/cnxk/roc_bits.h b/drivers/common/cnxk/roc_bits.h
index 11216d9d63..aa4944ae7f 100644
--- a/drivers/common/cnxk/roc_bits.h
+++ b/drivers/common/cnxk/roc_bits.h
@@ -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
diff --git a/drivers/common/nfp/nfp_platform.h b/drivers/common/nfp/nfp_platform.h
index 0b02fcf1e8..27792aca97 100644
--- a/drivers/common/nfp/nfp_platform.h
+++ b/drivers/common/nfp/nfp_platform.h
@@ -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)))
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH 3/6] drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
  2024-12-04 20:09 ` [PATCH 1/6] drivers/bus: " Andre Muezerie
  2024-12-04 20:09 ` [PATCH 2/6] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
@ 2024-12-04 20:09 ` Andre Muezerie
  2024-12-04 20:09 ` [PATCH 4/6] drivers/net: " Andre Muezerie
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 20:09 UTC (permalink / raw)
  To: Gagandeep Singh, Sachin Saxena, Chengwen Feng; +Cc: dev, 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/dma/dpaa/dpaa_qdma.h        | 2 +-
 drivers/dma/hisilicon/hisi_dmadev.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dpaa/dpaa_qdma.h b/drivers/dma/dpaa/dpaa_qdma.h
index 579483ac34..3736c0d431 100644
--- a/drivers/dma/dpaa/dpaa_qdma.h
+++ b/drivers/dma/dpaa/dpaa_qdma.h
@@ -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
diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h
index 786fe3cc0e..777b9dd704 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.h
+++ b/drivers/dma/hisilicon/hisi_dmadev.h
@@ -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)
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH 4/6] drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
                   ` (2 preceding siblings ...)
  2024-12-04 20:09 ` [PATCH 3/6] drivers/dma: " Andre Muezerie
@ 2024-12-04 20:09 ` Andre Muezerie
  2024-12-04 20:09 ` [PATCH 5/6] drivers/raw: " Andre Muezerie
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 20:09 UTC (permalink / raw)
  To: Shai Brandes, Evgeny Schemeilin, Ron Beider, Amit Bernstein,
	Wajeeh Atrash, Jie Hai
  Cc: dev, 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/net/ena/base/ena_plat_dpdk.h | 4 ++--
 drivers/net/hns3/hns3_ethdev.h       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index 1121460470..24e0435ac1 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -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))))
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 7824503bb8..207a92f832 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -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))))
 
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH 5/6] drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
                   ` (3 preceding siblings ...)
  2024-12-04 20:09 ` [PATCH 4/6] drivers/net: " Andre Muezerie
@ 2024-12-04 20:09 ` Andre Muezerie
  2024-12-04 20:09 ` [PATCH 6/6] lib/mldev: " Andre Muezerie
  2024-12-04 21:50 ` [PATCH 0/6] " Stephen Hemminger
  6 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 20:09 UTC (permalink / raw)
  To: Rosen Xu; +Cc: dev, 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/raw/ifpga/base/opae_osdep.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/raw/ifpga/base/opae_osdep.h b/drivers/raw/ifpga/base/opae_osdep.h
index cb780b1fed..bb8d2a1dd6 100644
--- a/drivers/raw/ifpga/base/opae_osdep.h
+++ b/drivers/raw/ifpga/base/opae_osdep.h
@@ -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))
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH 6/6] lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
                   ` (4 preceding siblings ...)
  2024-12-04 20:09 ` [PATCH 5/6] drivers/raw: " Andre Muezerie
@ 2024-12-04 20:09 ` Andre Muezerie
  2024-12-04 21:50 ` [PATCH 0/6] " Stephen Hemminger
  6 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 20:09 UTC (permalink / raw)
  To: Srikanth Yalavarthi; +Cc: dev, 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/mldev/mldev_utils_scalar.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/mldev/mldev_utils_scalar.h b/lib/mldev/mldev_utils_scalar.h
index 57e66ddb60..d12e358fb5 100644
--- a/lib/mldev/mldev_utils_scalar.h
+++ b/lib/mldev/mldev_utils_scalar.h
@@ -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
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v2 0/6] eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 ` [PATCH 1/6] drivers/bus: " Andre Muezerie
@ 2024-12-04 21:41   ` Andre Muezerie
  2024-12-04 21:41     ` [PATCH v2 1/6] drivers/bus: " Andre Muezerie
                       ` (5 more replies)
  2024-12-05  4:20   ` [PATCH v3 0/7] " Andre Muezerie
                     ` (2 subsequent siblings)
  3 siblings, 6 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 21:41 UTC (permalink / raw)
  To: dev; +Cc: 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.

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


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v2 1/6] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 21:41   ` [PATCH v2 0/6] " Andre Muezerie
@ 2024-12-04 21:41     ` Andre Muezerie
  2024-12-04 21:41     ` [PATCH v2 2/6] drivers/common: " Andre Muezerie
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 21:41 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
index a768774c89..10804e6c5d 100644
--- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h
+++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
@@ -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))))
 
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v2 2/6] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 21:41   ` [PATCH v2 0/6] " Andre Muezerie
  2024-12-04 21:41     ` [PATCH v2 1/6] drivers/bus: " Andre Muezerie
@ 2024-12-04 21:41     ` Andre Muezerie
  2024-12-04 21:41     ` [PATCH v2 3/6] drivers/dma: " Andre Muezerie
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 21:41 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/common/cnxk/roc_bits.h    | 4 ++--
 drivers/common/nfp/nfp_platform.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/common/cnxk/roc_bits.h b/drivers/common/cnxk/roc_bits.h
index 11216d9d63..aa4944ae7f 100644
--- a/drivers/common/cnxk/roc_bits.h
+++ b/drivers/common/cnxk/roc_bits.h
@@ -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
diff --git a/drivers/common/nfp/nfp_platform.h b/drivers/common/nfp/nfp_platform.h
index 0b02fcf1e8..27792aca97 100644
--- a/drivers/common/nfp/nfp_platform.h
+++ b/drivers/common/nfp/nfp_platform.h
@@ -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)))
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v2 3/6] drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 21:41   ` [PATCH v2 0/6] " Andre Muezerie
  2024-12-04 21:41     ` [PATCH v2 1/6] drivers/bus: " Andre Muezerie
  2024-12-04 21:41     ` [PATCH v2 2/6] drivers/common: " Andre Muezerie
@ 2024-12-04 21:41     ` Andre Muezerie
  2024-12-04 21:41     ` [PATCH v2 4/6] drivers/net: " Andre Muezerie
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 21:41 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/dma/dpaa/dpaa_qdma.h        | 2 +-
 drivers/dma/hisilicon/hisi_dmadev.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dpaa/dpaa_qdma.h b/drivers/dma/dpaa/dpaa_qdma.h
index 579483ac34..3736c0d431 100644
--- a/drivers/dma/dpaa/dpaa_qdma.h
+++ b/drivers/dma/dpaa/dpaa_qdma.h
@@ -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
diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h
index 786fe3cc0e..777b9dd704 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.h
+++ b/drivers/dma/hisilicon/hisi_dmadev.h
@@ -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)
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v2 4/6] drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 21:41   ` [PATCH v2 0/6] " Andre Muezerie
                       ` (2 preceding siblings ...)
  2024-12-04 21:41     ` [PATCH v2 3/6] drivers/dma: " Andre Muezerie
@ 2024-12-04 21:41     ` Andre Muezerie
  2024-12-04 21:41     ` [PATCH v2 5/6] drivers/raw: " Andre Muezerie
  2024-12-04 21:41     ` [PATCH v2 6/6] lib/mldev: " Andre Muezerie
  5 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 21:41 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/net/ena/base/ena_plat_dpdk.h | 4 ++--
 drivers/net/hns3/hns3_ethdev.h       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index 1121460470..24e0435ac1 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -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))))
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 7824503bb8..207a92f832 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -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))))
 
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v2 5/6] drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 21:41   ` [PATCH v2 0/6] " Andre Muezerie
                       ` (3 preceding siblings ...)
  2024-12-04 21:41     ` [PATCH v2 4/6] drivers/net: " Andre Muezerie
@ 2024-12-04 21:41     ` Andre Muezerie
  2024-12-04 21:41     ` [PATCH v2 6/6] lib/mldev: " Andre Muezerie
  5 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 21:41 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/raw/ifpga/base/opae_osdep.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/raw/ifpga/base/opae_osdep.h b/drivers/raw/ifpga/base/opae_osdep.h
index cb780b1fed..bb8d2a1dd6 100644
--- a/drivers/raw/ifpga/base/opae_osdep.h
+++ b/drivers/raw/ifpga/base/opae_osdep.h
@@ -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))
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v2 6/6] lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 21:41   ` [PATCH v2 0/6] " Andre Muezerie
                       ` (4 preceding siblings ...)
  2024-12-04 21:41     ` [PATCH v2 5/6] drivers/raw: " Andre Muezerie
@ 2024-12-04 21:41     ` Andre Muezerie
  5 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-04 21:41 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/mldev/mldev_utils_scalar.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/mldev/mldev_utils_scalar.h b/lib/mldev/mldev_utils_scalar.h
index 57e66ddb60..d12e358fb5 100644
--- a/lib/mldev/mldev_utils_scalar.h
+++ b/lib/mldev/mldev_utils_scalar.h
@@ -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
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
                   ` (5 preceding siblings ...)
  2024-12-04 20:09 ` [PATCH 6/6] lib/mldev: " Andre Muezerie
@ 2024-12-04 21:50 ` Stephen Hemminger
  2024-12-05  4:19   ` Andre Muezerie
  6 siblings, 1 reply; 45+ messages in thread
From: Stephen Hemminger @ 2024-12-04 21:50 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev

On Wed,  4 Dec 2024 12:09:49 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:

> 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(-)
> 
> --

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

^ permalink raw reply	[flat|nested] 45+ messages in thread

* RE: [PATCH 2/6] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 ` [PATCH 2/6] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
@ 2024-12-05  1:14   ` Chaoyong He
  0 siblings, 0 replies; 45+ messages in thread
From: Chaoyong He @ 2024-12-05  1:14 UTC (permalink / raw)
  To: Andre Muezerie, Nithin Dabilpuram, Kiran Kumar K,
	Sunil Kumar Kori, Satha Rao, Harman Kalra
  Cc: dev

> 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.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---
>  drivers/common/cnxk/roc_bits.h    | 4 ++--
>  drivers/common/nfp/nfp_platform.h | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/common/cnxk/roc_bits.h
> b/drivers/common/cnxk/roc_bits.h index 11216d9d63..aa4944ae7f 100644
> --- a/drivers/common/cnxk/roc_bits.h
> +++ b/drivers/common/cnxk/roc_bits.h
> @@ -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
> diff --git a/drivers/common/nfp/nfp_platform.h
> b/drivers/common/nfp/nfp_platform.h
> index 0b02fcf1e8..27792aca97 100644
> --- a/drivers/common/nfp/nfp_platform.h
> +++ b/drivers/common/nfp/nfp_platform.h
> @@ -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.
Acked-by: Chaoyong He <chaoyong.he@corigine.com>

> 
>  #define GENMASK(h, l) \
>  	((~0UL << (l)) & (~0UL >> (BITS_PER_LONG - (h) - 1)))
> --
> 2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 21:50 ` [PATCH 0/6] " Stephen Hemminger
@ 2024-12-05  4:19   ` Andre Muezerie
  0 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-05  4:19 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Wed, Dec 04, 2024 at 01:50:58PM -0800, Stephen Hemminger wrote:
> On Wed,  4 Dec 2024 12:09:49 -0800
> Andre Muezerie <andremue@linux.microsoft.com> wrote:
> 
> > 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(-)
> > 
> > --
> 
> 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

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v3 0/7] eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 ` [PATCH 1/6] drivers/bus: " Andre Muezerie
  2024-12-04 21:41   ` [PATCH v2 0/6] " Andre Muezerie
@ 2024-12-05  4:20   ` Andre Muezerie
  2024-12-05  4:20     ` [PATCH v3 1/7] lib/eal: " Andre Muezerie
                       ` (6 more replies)
  2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
  2025-02-05 16:12   ` [PATCH v5] eal: define __SIZEOF_LONG__ when using MSVC Andre Muezerie
  3 siblings, 7 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-05  4:20 UTC (permalink / raw)
  To: dev; +Cc: 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


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v3 1/7] lib/eal: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-05  4:20   ` [PATCH v3 0/7] " Andre Muezerie
@ 2024-12-05  4:20     ` Andre Muezerie
  2024-12-05  4:20     ` [PATCH v3 2/7] drivers/bus: " Andre Muezerie
                       ` (5 subsequent siblings)
  6 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-05  4:20 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/eal/include/rte_common.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 4d299f2b36..d2338366a4 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -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. */
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-05  4:20   ` [PATCH v3 0/7] " Andre Muezerie
  2024-12-05  4:20     ` [PATCH v3 1/7] lib/eal: " Andre Muezerie
@ 2024-12-05  4:20     ` Andre Muezerie
  2024-12-06 12:22       ` Konstantin Ananyev
  2024-12-05  4:20     ` [PATCH v3 3/7] drivers/common: " Andre Muezerie
                       ` (4 subsequent siblings)
  6 siblings, 1 reply; 45+ messages in thread
From: Andre Muezerie @ 2024-12-05  4:20 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
index a768774c89..f27a18905d 100644
--- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h
+++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
@@ -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 {
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v3 3/7] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-05  4:20   ` [PATCH v3 0/7] " Andre Muezerie
  2024-12-05  4:20     ` [PATCH v3 1/7] lib/eal: " Andre Muezerie
  2024-12-05  4:20     ` [PATCH v3 2/7] drivers/bus: " Andre Muezerie
@ 2024-12-05  4:20     ` Andre Muezerie
  2024-12-05  4:20     ` [PATCH v3 4/7] drivers/dma: " Andre Muezerie
                       ` (3 subsequent siblings)
  6 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-05  4:20 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Acked-by: Chaoyong He <chaoyong.he@corigine.com>
---
 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(-)

diff --git a/drivers/common/cnxk/cnxk_security_ar.h b/drivers/common/cnxk/cnxk_security_ar.h
index d0151a752c..9e88d0063b 100644
--- a/drivers/common/cnxk/cnxk_security_ar.h
+++ b/drivers/common/cnxk/cnxk_security_ar.h
@@ -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)
diff --git a/drivers/common/cnxk/roc_bits.h b/drivers/common/cnxk/roc_bits.h
index 11216d9d63..654e5a85d7 100644
--- a/drivers/common/cnxk/roc_bits.h
+++ b/drivers/common/cnxk/roc_bits.h
@@ -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_ */
diff --git a/drivers/common/cnxk/roc_ie_ot.h b/drivers/common/cnxk/roc_ie_ot.h
index 1420e3d586..2d94dd3f81 100644
--- a/drivers/common/cnxk/roc_ie_ot.h
+++ b/drivers/common/cnxk/roc_ie_ot.h
@@ -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
 
diff --git a/drivers/common/cnxk/roc_ie_ot_tls.h b/drivers/common/cnxk/roc_ie_ot_tls.h
index 2d6a290d9b..5df9c98b00 100644
--- a/drivers/common/cnxk/roc_ie_ot_tls.h
+++ b/drivers/common/cnxk/roc_ie_ot_tls.h
@@ -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
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index df4f88f288..6abbc672cc 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -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
diff --git a/drivers/common/nfp/nfp_platform.h b/drivers/common/nfp/nfp_platform.h
index 0b02fcf1e8..e34781a88d 100644
--- a/drivers/common/nfp/nfp_platform.h
+++ b/drivers/common/nfp/nfp_platform.h
@@ -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)
 
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v3 4/7] drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-05  4:20   ` [PATCH v3 0/7] " Andre Muezerie
                       ` (2 preceding siblings ...)
  2024-12-05  4:20     ` [PATCH v3 3/7] drivers/common: " Andre Muezerie
@ 2024-12-05  4:20     ` Andre Muezerie
  2024-12-05  4:20     ` [PATCH v3 5/7] drivers/net: " Andre Muezerie
                       ` (2 subsequent siblings)
  6 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-05  4:20 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/dma/dpaa/dpaa_qdma.h        | 3 +--
 drivers/dma/hisilicon/hisi_dmadev.h | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/dpaa/dpaa_qdma.h b/drivers/dma/dpaa/dpaa_qdma.h
index 91eaf1455a..617e15fbc4 100644
--- a/drivers/dma/dpaa/dpaa_qdma.h
+++ b/drivers/dma/dpaa/dpaa_qdma.h
@@ -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
diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h
index 786fe3cc0e..d1b4ae7da8 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.h
+++ b/drivers/dma/hisilicon/hisi_dmadev.h
@@ -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)))
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v3 5/7] drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-05  4:20   ` [PATCH v3 0/7] " Andre Muezerie
                       ` (3 preceding siblings ...)
  2024-12-05  4:20     ` [PATCH v3 4/7] drivers/dma: " Andre Muezerie
@ 2024-12-05  4:20     ` Andre Muezerie
  2024-12-05  4:20     ` [PATCH v3 6/7] drivers/raw: " Andre Muezerie
  2024-12-05  4:20     ` [PATCH v3 7/7] lib/mldev: " Andre Muezerie
  6 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-05  4:20 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/net/ena/base/ena_plat_dpdk.h | 6 ++----
 drivers/net/hns3/hns3_ethdev.h       | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index 1121460470..63f6ef70ee 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -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...)				       \
 	(								       \
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 7824503bb8..c7ad9a61c7 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -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)))
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v3 6/7] drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-05  4:20   ` [PATCH v3 0/7] " Andre Muezerie
                       ` (4 preceding siblings ...)
  2024-12-05  4:20     ` [PATCH v3 5/7] drivers/net: " Andre Muezerie
@ 2024-12-05  4:20     ` Andre Muezerie
  2024-12-05  4:20     ` [PATCH v3 7/7] lib/mldev: " Andre Muezerie
  6 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-05  4:20 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/raw/ifpga/base/opae_osdep.h | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/raw/ifpga/base/opae_osdep.h b/drivers/raw/ifpga/base/opae_osdep.h
index cb780b1fed..e4767e2d7a 100644
--- a/drivers/raw/ifpga/base/opae_osdep.h
+++ b/drivers/raw/ifpga/base/opae_osdep.h
@@ -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 */
 
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v3 7/7] lib/mldev: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-05  4:20   ` [PATCH v3 0/7] " Andre Muezerie
                       ` (5 preceding siblings ...)
  2024-12-05  4:20     ` [PATCH v3 6/7] drivers/raw: " Andre Muezerie
@ 2024-12-05  4:20     ` Andre Muezerie
  6 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2024-12-05  4:20 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/mldev/mldev_utils_scalar.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/mldev/mldev_utils_scalar.h b/lib/mldev/mldev_utils_scalar.h
index 57e66ddb60..a9462089d7 100644
--- a/lib/mldev/mldev_utils_scalar.h
+++ b/lib/mldev/mldev_utils_scalar.h
@@ -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 */
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* RE: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-05  4:20     ` [PATCH v3 2/7] drivers/bus: " Andre Muezerie
@ 2024-12-06 12:22       ` Konstantin Ananyev
  2024-12-06 16:19         ` Andre Muezerie
  0 siblings, 1 reply; 45+ messages in thread
From: Konstantin Ananyev @ 2024-12-06 12:22 UTC (permalink / raw)
  To: Andre Muezerie, dev



> 
> 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.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---
>  drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> index a768774c89..f27a18905d 100644
> --- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> +++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> @@ -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.

> 
>  struct mc_cmd_header {
>  	union {
> --
> 2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-06 12:22       ` Konstantin Ananyev
@ 2024-12-06 16:19         ` Andre Muezerie
  2024-12-06 16:41           ` Konstantin Ananyev
  0 siblings, 1 reply; 45+ messages in thread
From: Andre Muezerie @ 2024-12-06 16:19 UTC (permalink / raw)
  To: Konstantin Ananyev; +Cc: dev

On Fri, Dec 06, 2024 at 12:22:42PM +0000, Konstantin Ananyev wrote:
> 
> 
> > 
> > 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.
> > 
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > ---
> >  drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > index a768774c89..f27a18905d 100644
> > --- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > +++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > @@ -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.
> 

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

> > 
> >  struct mc_cmd_header {
> >  	union {
> > --
> > 2.47.0.vfs.0.3

^ permalink raw reply	[flat|nested] 45+ messages in thread

* RE: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-06 16:19         ` Andre Muezerie
@ 2024-12-06 16:41           ` Konstantin Ananyev
  2024-12-06 16:43             ` Konstantin Ananyev
  2024-12-06 18:14             ` Andre Muezerie
  0 siblings, 2 replies; 45+ messages in thread
From: Konstantin Ananyev @ 2024-12-06 16:41 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev


> > > 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.
> > >
> > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > > ---
> > >  drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
> > >  1 file changed, 1 insertion(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > index a768774c89..f27a18905d 100644
> > > --- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > +++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > @@ -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.
> >
> 
> 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.

> --
> Andre Muezerie
> 
> > >
> > >  struct mc_cmd_header {
> > >  	union {
> > > --
> > > 2.47.0.vfs.0.3

^ permalink raw reply	[flat|nested] 45+ messages in thread

* RE: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-06 16:41           ` Konstantin Ananyev
@ 2024-12-06 16:43             ` Konstantin Ananyev
  2024-12-06 18:14             ` Andre Muezerie
  1 sibling, 0 replies; 45+ messages in thread
From: Konstantin Ananyev @ 2024-12-06 16:43 UTC (permalink / raw)
  To: Konstantin Ananyev, Andre Muezerie; +Cc: dev



> -----Original Message-----
> From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> Sent: Friday, December 6, 2024 4:41 PM
> To: Andre Muezerie <andremue@linux.microsoft.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v3 2/7] 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.
> > > >
> > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > > > ---
> > > >  drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
> > > >  1 file changed, 1 insertion(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > > index a768774c89..f27a18905d 100644
> > > > --- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > > +++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > > @@ -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.
> > >
> >
> > 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.
:)
 
> Just thought that doing something like:
> #define GENMASK(h, l)	RTE_GENMASK64(h, l)
> Would be less work for you and less code churn.
> 
> > --
> > Andre Muezerie
> >
> > > >
> > > >  struct mc_cmd_header {
> > > >  	union {
> > > > --
> > > > 2.47.0.vfs.0.3

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-06 16:41           ` Konstantin Ananyev
  2024-12-06 16:43             ` Konstantin Ananyev
@ 2024-12-06 18:14             ` Andre Muezerie
  2025-02-04 15:58               ` Thomas Monjalon
  1 sibling, 1 reply; 45+ messages in thread
From: Andre Muezerie @ 2024-12-06 18:14 UTC (permalink / raw)
  To: Konstantin Ananyev; +Cc: dev

On Fri, Dec 06, 2024 at 04:41:16PM +0000, Konstantin Ananyev wrote:
> 
> > > > 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.
> > > >
> > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > > > ---
> > > >  drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
> > > >  1 file changed, 1 insertion(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > > index a768774c89..f27a18905d 100644
> > > > --- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > > +++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > > @@ -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.
> > >
> > 
> > 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.
> 

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.

> > --
> > Andre Muezerie
> > 
> > > >
> > > >  struct mc_cmd_header {
> > > >  	union {
> > > > --
> > > > 2.47.0.vfs.0.3

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v3 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-06 18:14             ` Andre Muezerie
@ 2025-02-04 15:58               ` Thomas Monjalon
  0 siblings, 0 replies; 45+ messages in thread
From: Thomas Monjalon @ 2025-02-04 15:58 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: Konstantin Ananyev, dev

06/12/2024 19:14, Andre Muezerie:
> On Fri, Dec 06, 2024 at 04:41:16PM +0000, Konstantin Ananyev wrote:
> > 
> > > > > 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.
> > > > >
> > > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > > > > ---
> > > > >  drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
> > > > >  1 file changed, 1 insertion(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > > > index a768774c89..f27a18905d 100644
> > > > > --- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > > > +++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
> > > > > @@ -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.
> > > >
> > > 
> > > 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.
> > 
> 
> 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.






^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v4 0/7] eliminate dependency on non-portable __SIZEOF_LONG__
  2024-12-04 20:09 ` [PATCH 1/6] drivers/bus: " Andre Muezerie
  2024-12-04 21:41   ` [PATCH v2 0/6] " Andre Muezerie
  2024-12-05  4:20   ` [PATCH v3 0/7] " Andre Muezerie
@ 2025-02-04 18:54   ` Andre Muezerie
  2025-02-04 18:54     ` [PATCH v4 1/7] eal: " Andre Muezerie
                       ` (7 more replies)
  2025-02-05 16:12   ` [PATCH v5] eal: define __SIZEOF_LONG__ when using MSVC Andre Muezerie
  3 siblings, 8 replies; 45+ messages in thread
From: Andre Muezerie @ 2025-02-04 18:54 UTC (permalink / raw)
  To: dev; +Cc: 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


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v4 1/7] eal: eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
@ 2025-02-04 18:54     ` Andre Muezerie
  2025-02-04 18:54     ` [PATCH v4 2/7] drivers/bus: " Andre Muezerie
                       ` (6 subsequent siblings)
  7 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2025-02-04 18:54 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/eal/include/rte_common.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 7a252c1997..47e3201006 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -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. */
-- 
2.47.2.vfs.0.1


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v4 2/7] drivers/bus: eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
  2025-02-04 18:54     ` [PATCH v4 1/7] eal: " Andre Muezerie
@ 2025-02-04 18:54     ` Andre Muezerie
  2025-02-04 18:54     ` [PATCH v4 3/7] drivers/common: " Andre Muezerie
                       ` (5 subsequent siblings)
  7 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2025-02-04 18:54 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
index a768774c89..f27a18905d 100644
--- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h
+++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
@@ -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 {
-- 
2.47.2.vfs.0.1


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v4 3/7] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
  2025-02-04 18:54     ` [PATCH v4 1/7] eal: " Andre Muezerie
  2025-02-04 18:54     ` [PATCH v4 2/7] drivers/bus: " Andre Muezerie
@ 2025-02-04 18:54     ` Andre Muezerie
  2025-02-04 18:54     ` [PATCH v4 4/7] drivers/dma: " Andre Muezerie
                       ` (4 subsequent siblings)
  7 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2025-02-04 18:54 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Acked-by: Chaoyong He <chaoyong.he@corigine.com>
---
 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(-)

diff --git a/drivers/common/cnxk/cnxk_security_ar.h b/drivers/common/cnxk/cnxk_security_ar.h
index d0151a752c..9e88d0063b 100644
--- a/drivers/common/cnxk/cnxk_security_ar.h
+++ b/drivers/common/cnxk/cnxk_security_ar.h
@@ -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)
diff --git a/drivers/common/cnxk/roc_bits.h b/drivers/common/cnxk/roc_bits.h
index 11216d9d63..654e5a85d7 100644
--- a/drivers/common/cnxk/roc_bits.h
+++ b/drivers/common/cnxk/roc_bits.h
@@ -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_ */
diff --git a/drivers/common/cnxk/roc_ie_ot.h b/drivers/common/cnxk/roc_ie_ot.h
index 1420e3d586..bfefe792b0 100644
--- a/drivers/common/cnxk/roc_ie_ot.h
+++ b/drivers/common/cnxk/roc_ie_ot.h
@@ -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
 
diff --git a/drivers/common/cnxk/roc_ie_ot_tls.h b/drivers/common/cnxk/roc_ie_ot_tls.h
index 2d6a290d9b..ff86bcb877 100644
--- a/drivers/common/cnxk/roc_ie_ot_tls.h
+++ b/drivers/common/cnxk/roc_ie_ot_tls.h
@@ -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
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 1eb54446a8..1ed03430f9 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -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
diff --git a/drivers/common/nfp/nfp_platform.h b/drivers/common/nfp/nfp_platform.h
index 0b02fcf1e8..e34781a88d 100644
--- a/drivers/common/nfp/nfp_platform.h
+++ b/drivers/common/nfp/nfp_platform.h
@@ -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)
 
-- 
2.47.2.vfs.0.1


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v4 4/7] drivers/dma: eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
                       ` (2 preceding siblings ...)
  2025-02-04 18:54     ` [PATCH v4 3/7] drivers/common: " Andre Muezerie
@ 2025-02-04 18:54     ` Andre Muezerie
  2025-02-04 18:54     ` [PATCH v4 5/7] drivers/net: " Andre Muezerie
                       ` (3 subsequent siblings)
  7 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2025-02-04 18:54 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/dma/dpaa/dpaa_qdma.h        | 3 +--
 drivers/dma/hisilicon/hisi_dmadev.h | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/dpaa/dpaa_qdma.h b/drivers/dma/dpaa/dpaa_qdma.h
index 0b08909221..c017bec48f 100644
--- a/drivers/dma/dpaa/dpaa_qdma.h
+++ b/drivers/dma/dpaa/dpaa_qdma.h
@@ -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
diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h
index 786fe3cc0e..d1b4ae7da8 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.h
+++ b/drivers/dma/hisilicon/hisi_dmadev.h
@@ -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)))
-- 
2.47.2.vfs.0.1


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v4 5/7] drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
                       ` (3 preceding siblings ...)
  2025-02-04 18:54     ` [PATCH v4 4/7] drivers/dma: " Andre Muezerie
@ 2025-02-04 18:54     ` Andre Muezerie
  2025-02-04 18:54     ` [PATCH v4 6/7] drivers/raw: " Andre Muezerie
                       ` (2 subsequent siblings)
  7 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2025-02-04 18:54 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/net/ena/base/ena_plat_dpdk.h | 6 ++----
 drivers/net/hns3/hns3_ethdev.h       | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index 3b574f888a..8ab1442c22 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -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, ...)				       \
 	(								       \
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 7824503bb8..c7ad9a61c7 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -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)))
-- 
2.47.2.vfs.0.1


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v4 6/7] drivers/raw: eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
                       ` (4 preceding siblings ...)
  2025-02-04 18:54     ` [PATCH v4 5/7] drivers/net: " Andre Muezerie
@ 2025-02-04 18:54     ` Andre Muezerie
  2025-02-04 18:54     ` [PATCH v4 7/7] mldev: " Andre Muezerie
  2025-02-05  9:15     ` [PATCH v4 0/7] " Bruce Richardson
  7 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2025-02-04 18:54 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/raw/ifpga/base/opae_osdep.h | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/raw/ifpga/base/opae_osdep.h b/drivers/raw/ifpga/base/opae_osdep.h
index e35a21c80e..af61716f61 100644
--- a/drivers/raw/ifpga/base/opae_osdep.h
+++ b/drivers/raw/ifpga/base/opae_osdep.h
@@ -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 */
 
-- 
2.47.2.vfs.0.1


^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v4 7/7] mldev: eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
                       ` (5 preceding siblings ...)
  2025-02-04 18:54     ` [PATCH v4 6/7] drivers/raw: " Andre Muezerie
@ 2025-02-04 18:54     ` Andre Muezerie
  2025-02-05  9:15     ` [PATCH v4 0/7] " Bruce Richardson
  7 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2025-02-04 18:54 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/mldev/mldev_utils_scalar.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/mldev/mldev_utils_scalar.h b/lib/mldev/mldev_utils_scalar.h
index 57e66ddb60..a9462089d7 100644
--- a/lib/mldev/mldev_utils_scalar.h
+++ b/lib/mldev/mldev_utils_scalar.h
@@ -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 */
-- 
2.47.2.vfs.0.1


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v4 0/7] eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
                       ` (6 preceding siblings ...)
  2025-02-04 18:54     ` [PATCH v4 7/7] mldev: " Andre Muezerie
@ 2025-02-05  9:15     ` Bruce Richardson
  2025-02-05 15:37       ` Andre Muezerie
  7 siblings, 1 reply; 45+ messages in thread
From: Bruce Richardson @ 2025-02-05  9:15 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev

On Tue, Feb 04, 2025 at 10:54:24AM -0800, Andre Muezerie wrote:
> 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__
> 
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

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v4 0/7] eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-05  9:15     ` [PATCH v4 0/7] " Bruce Richardson
@ 2025-02-05 15:37       ` Andre Muezerie
  2025-02-05 15:47         ` Bruce Richardson
  0 siblings, 1 reply; 45+ messages in thread
From: Andre Muezerie @ 2025-02-05 15:37 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Wed, Feb 05, 2025 at 09:15:43AM +0000, Bruce Richardson wrote:
> On Tue, Feb 04, 2025 at 10:54:24AM -0800, Andre Muezerie wrote:
> > 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__
> > 
> 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

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


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v4 0/7] eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-05 15:37       ` Andre Muezerie
@ 2025-02-05 15:47         ` Bruce Richardson
  2025-02-05 15:50           ` Konstantin Ananyev
  0 siblings, 1 reply; 45+ messages in thread
From: Bruce Richardson @ 2025-02-05 15:47 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, david.marchand, thomas, stephen

On Wed, Feb 05, 2025 at 07:37:21AM -0800, Andre Muezerie wrote:
> On Wed, Feb 05, 2025 at 09:15:43AM +0000, Bruce Richardson wrote:
> > On Tue, Feb 04, 2025 at 10:54:24AM -0800, Andre Muezerie wrote:
> > > 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__
> > > 
> > 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
> 
> 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

^ permalink raw reply	[flat|nested] 45+ messages in thread

* RE: [PATCH v4 0/7] eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-05 15:47         ` Bruce Richardson
@ 2025-02-05 15:50           ` Konstantin Ananyev
  2025-02-05 16:11             ` Andre Muezerie
  0 siblings, 1 reply; 45+ messages in thread
From: Konstantin Ananyev @ 2025-02-05 15:50 UTC (permalink / raw)
  To: Bruce Richardson, Andre Muezerie; +Cc: dev, david.marchand, thomas, stephen


> On Wed, Feb 05, 2025 at 07:37:21AM -0800, Andre Muezerie wrote:
> > On Wed, Feb 05, 2025 at 09:15:43AM +0000, Bruce Richardson wrote:
> > > On Tue, Feb 04, 2025 at 10:54:24AM -0800, Andre Muezerie wrote:
> > > > 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__
> > > >
> > > 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
> >
> > 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.
 


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v4 0/7] eliminate dependency on non-portable __SIZEOF_LONG__
  2025-02-05 15:50           ` Konstantin Ananyev
@ 2025-02-05 16:11             ` Andre Muezerie
  0 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2025-02-05 16:11 UTC (permalink / raw)
  To: Konstantin Ananyev; +Cc: Bruce Richardson, dev, david.marchand, thomas, stephen

On Wed, Feb 05, 2025 at 03:50:03PM +0000, Konstantin Ananyev wrote:
> 
> > On Wed, Feb 05, 2025 at 07:37:21AM -0800, Andre Muezerie wrote:
> > > On Wed, Feb 05, 2025 at 09:15:43AM +0000, Bruce Richardson wrote:
> > > > On Tue, Feb 04, 2025 at 10:54:24AM -0800, Andre Muezerie wrote:
> > > > > 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__
> > > > >
> > > > 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
> > >
> > > 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.

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v5] eal: define __SIZEOF_LONG__ when using MSVC
  2024-12-04 20:09 ` [PATCH 1/6] drivers/bus: " Andre Muezerie
                     ` (2 preceding siblings ...)
  2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
@ 2025-02-05 16:12   ` Andre Muezerie
  3 siblings, 0 replies; 45+ messages in thread
From: Andre Muezerie @ 2025-02-05 16:12 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/eal/include/rte_compat.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/eal/include/rte_compat.h b/lib/eal/include/rte_compat.h
index 97c1540bd0..6676a1bb13 100644
--- a/lib/eal/include/rte_compat.h
+++ b/lib/eal/include/rte_compat.h
@@ -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_ */
-- 
2.47.2.vfs.0.1


^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2025-02-05 16:12 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-04 20:09 [PATCH 0/6] eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
2024-12-04 20:09 ` [PATCH 1/6] drivers/bus: " Andre Muezerie
2024-12-04 21:41   ` [PATCH v2 0/6] " Andre Muezerie
2024-12-04 21:41     ` [PATCH v2 1/6] drivers/bus: " Andre Muezerie
2024-12-04 21:41     ` [PATCH v2 2/6] drivers/common: " Andre Muezerie
2024-12-04 21:41     ` [PATCH v2 3/6] drivers/dma: " Andre Muezerie
2024-12-04 21:41     ` [PATCH v2 4/6] drivers/net: " Andre Muezerie
2024-12-04 21:41     ` [PATCH v2 5/6] drivers/raw: " Andre Muezerie
2024-12-04 21:41     ` [PATCH v2 6/6] lib/mldev: " Andre Muezerie
2024-12-05  4:20   ` [PATCH v3 0/7] " Andre Muezerie
2024-12-05  4:20     ` [PATCH v3 1/7] lib/eal: " Andre Muezerie
2024-12-05  4:20     ` [PATCH v3 2/7] drivers/bus: " Andre Muezerie
2024-12-06 12:22       ` Konstantin Ananyev
2024-12-06 16:19         ` Andre Muezerie
2024-12-06 16:41           ` Konstantin Ananyev
2024-12-06 16:43             ` Konstantin Ananyev
2024-12-06 18:14             ` Andre Muezerie
2025-02-04 15:58               ` Thomas Monjalon
2024-12-05  4:20     ` [PATCH v3 3/7] drivers/common: " Andre Muezerie
2024-12-05  4:20     ` [PATCH v3 4/7] drivers/dma: " Andre Muezerie
2024-12-05  4:20     ` [PATCH v3 5/7] drivers/net: " Andre Muezerie
2024-12-05  4:20     ` [PATCH v3 6/7] drivers/raw: " Andre Muezerie
2024-12-05  4:20     ` [PATCH v3 7/7] lib/mldev: " Andre Muezerie
2025-02-04 18:54   ` [PATCH v4 0/7] " Andre Muezerie
2025-02-04 18:54     ` [PATCH v4 1/7] eal: " Andre Muezerie
2025-02-04 18:54     ` [PATCH v4 2/7] drivers/bus: " Andre Muezerie
2025-02-04 18:54     ` [PATCH v4 3/7] drivers/common: " Andre Muezerie
2025-02-04 18:54     ` [PATCH v4 4/7] drivers/dma: " Andre Muezerie
2025-02-04 18:54     ` [PATCH v4 5/7] drivers/net: " Andre Muezerie
2025-02-04 18:54     ` [PATCH v4 6/7] drivers/raw: " Andre Muezerie
2025-02-04 18:54     ` [PATCH v4 7/7] mldev: " Andre Muezerie
2025-02-05  9:15     ` [PATCH v4 0/7] " Bruce Richardson
2025-02-05 15:37       ` Andre Muezerie
2025-02-05 15:47         ` Bruce Richardson
2025-02-05 15:50           ` Konstantin Ananyev
2025-02-05 16:11             ` Andre Muezerie
2025-02-05 16:12   ` [PATCH v5] eal: define __SIZEOF_LONG__ when using MSVC Andre Muezerie
2024-12-04 20:09 ` [PATCH 2/6] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__ Andre Muezerie
2024-12-05  1:14   ` Chaoyong He
2024-12-04 20:09 ` [PATCH 3/6] drivers/dma: " Andre Muezerie
2024-12-04 20:09 ` [PATCH 4/6] drivers/net: " Andre Muezerie
2024-12-04 20:09 ` [PATCH 5/6] drivers/raw: " Andre Muezerie
2024-12-04 20:09 ` [PATCH 6/6] lib/mldev: " Andre Muezerie
2024-12-04 21:50 ` [PATCH 0/6] " Stephen Hemminger
2024-12-05  4:19   ` Andre Muezerie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).