[v3,1/7] lib/eal: eliminate dependency on non-portable __SIZEOF_LONG__

Message ID 1733372429-3996-2-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State New
Delegated to: David Marchand
Headers
Series eliminate dependency on non-portable __SIZEOF_LONG__ |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andre Muezerie Dec. 5, 2024, 4:20 a.m. UTC
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(+)
  

Patch

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. */