[dpdk-dev] [RFC PATCH 7/9] eal/windows: fix rte_page_sizes with Clang on Windows
Dmitry Kozlyuk
dmitry.kozliuk at gmail.com
Mon Mar 30 06:10:24 CEST 2020
Clang on Windows follows MS ABI where enum values are signed 32-bit,
Enum rte_page_size has members valued beyond 2^32. EAL cannot use
-fno-ms-compatibility because its code is OS-dependent. The only option
is to define these values outside enum, but this prohibits using
-fstrict-enums. Another consequence is that enum rte_page_size cannot
be used to hold page size, because on Windows it won't be able to hold
all possible values.
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
---
lib/librte_eal/common/include/rte_memory.h | 6 ++++++
lib/librte_eal/meson.build | 1 +
2 files changed, 7 insertions(+)
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 1742fde9a..5b0e2d8b5 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -34,8 +34,14 @@ enum rte_page_sizes {
RTE_PGSIZE_256M = 1ULL << 28,
RTE_PGSIZE_512M = 1ULL << 29,
RTE_PGSIZE_1G = 1ULL << 30,
+/* Work around Clang on Windows being limited to 32-bit underlying type. */
+#if !defined(RTE_TOOLCHAIN_CLANG) || !defined(RTE_EXEC_ENV_WINDOWS)
RTE_PGSIZE_4G = 1ULL << 32,
RTE_PGSIZE_16G = 1ULL << 34,
+#else
+#define RTE_PGSIZE_4G (1ULL << 32)
+#define RTE_PGSIZE_16G (1ULL << 34)
+#endif
};
#define SOCKET_ID_ANY -1 /**< Any NUMA socket. */
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index 1730d603f..ec80bd6be 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -23,6 +23,7 @@ endif
if cc.has_header('getopt.h')
cflags += ['-DHAVE_GETOPT_H', '-DHAVE_GETOPT', '-DHAVE_GETOPT_LONG']
endif
+cflags += '-fno-strict-enums'
sources = common_sources + env_sources
objs = common_objs + env_objs
headers = common_headers + env_headers
--
2.25.1
More information about the dev
mailing list