All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Muezerie <andremue@linux.microsoft.com>
To: dev@dpdk.org
Cc: Andre Muezerie <andremue@linux.microsoft.com>
Subject: [PATCH v3 3/7] drivers/common: eliminate dependency on non-portable __SIZEOF_LONG__
Date: Wed,  4 Dec 2024 20:20:25 -0800	[thread overview]
Message-ID: <1733372429-3996-4-git-send-email-andremue@linux.microsoft.com> (raw)
In-Reply-To: <1733372429-3996-1-git-send-email-andremue@linux.microsoft.com>

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


  parent reply	other threads:[~2024-12-05  4:21 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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     ` Andre Muezerie [this message]
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
2025-02-07 10:56     ` David Marchand
2025-02-07 15:07       ` Andre Muezerie
2025-02-07 15:04   ` [PATCH v6] " Andre Muezerie
2025-02-07 15:08     ` Bruce Richardson
2025-02-09 14:47     ` Konstantin Ananyev
2025-03-06 13:10     ` David Marchand
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1733372429-3996-4-git-send-email-andremue@linux.microsoft.com \
    --to=andremue@linux.microsoft.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.