[v6] eal: define __SIZEOF_LONG__ when using MSVC

Message ID 1738940668-21653-1-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Accepted
Delegated to: David Marchand
Headers
Series [v6] eal: define __SIZEOF_LONG__ when using MSVC |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-abi-testing pending Testing pending
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing warning Testing issues

Commit Message

Andre Muezerie Feb. 7, 2025, 3:04 p.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

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/windows/include/rte_os.h | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Bruce Richardson Feb. 7, 2025, 3:08 p.m. UTC | #1
On Fri, Feb 07, 2025 at 07:04:28AM -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
> 
> 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/windows/include/rte_os.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Konstantin Ananyev Feb. 9, 2025, 2:47 p.m. UTC | #2
> 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/windows/include/rte_os.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/eal/windows/include/rte_os.h b/lib/eal/windows/include/rte_os.h
> index d09adeb3b4..c787027866 100644
> --- a/lib/eal/windows/include/rte_os.h
> +++ b/lib/eal/windows/include/rte_os.h
> @@ -56,4 +56,9 @@ struct { \
>   */
>  typedef long long ssize_t;
> 
> +#ifdef RTE_TOOLCHAIN_MSVC
> +#define __SIZEOF_LONG__		(sizeof(long))
> +#define __SIZEOF_LONG_LONG__	(sizeof(long long))
> +#endif
> +
>  #endif /* _RTE_OS_H_ */
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
 

> 2.47.2.vfs.0.1
  
David Marchand March 6, 2025, 1:10 p.m. UTC | #3
On Fri, Feb 7, 2025 at 4:04 PM 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
>
> The fix is to define __SIZEOF_LONG__ in a common header when
> MSVC is used.
>
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>

Applied, thanks.
  

Patch

diff --git a/lib/eal/windows/include/rte_os.h b/lib/eal/windows/include/rte_os.h
index d09adeb3b4..c787027866 100644
--- a/lib/eal/windows/include/rte_os.h
+++ b/lib/eal/windows/include/rte_os.h
@@ -56,4 +56,9 @@  struct { \
  */
 typedef long long ssize_t;
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __SIZEOF_LONG__		(sizeof(long))
+#define __SIZEOF_LONG_LONG__	(sizeof(long long))
+#endif
+
 #endif /* _RTE_OS_H_ */