[v3,5/7] drivers/net: eliminate dependency on non-portable __SIZEOF_LONG__
Checks
Commit Message
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(-)
@@ -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...) \
( \
@@ -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)))