[3/3] ethdev: import and export data variables for MSVC

Message ID 1710229908-31704-4-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series RFC fix import/export MSVC data variables |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation fail ninja build failure
ci/Intel-compilation fail Compilation issues
ci/github-robot: build fail github build: failed

Commit Message

Tyler Retzlaff March 12, 2024, 7:51 a.m. UTC
  MSVC requires that data variables be explicitly declared as either
imported or exported. Provide macros that allow dpdk to correctly
declare data variables as exported for itself and imported for
applications.

Use new per-library macro to declare variables exported or imported for
per-lcore data variables.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/ethdev/meson.build         |  1 +
 lib/ethdev/rte_ethdev_core.h   |  3 +++
 lib/ethdev/rte_ethdev_export.h | 23 +++++++++++++++++++++++
 lib/ethdev/version.map         |  2 +-
 4 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 lib/ethdev/rte_ethdev_export.h
  

Patch

diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build
index f1d2586..b270e02 100644
--- a/lib/ethdev/meson.build
+++ b/lib/ethdev/meson.build
@@ -23,6 +23,7 @@  sources = files(
 headers = files(
         'rte_cman.h',
         'rte_ethdev.h',
+        'rte_ethdev_export.h',
         'rte_ethdev_trace_fp.h',
         'rte_dev_info.h',
         'rte_flow.h',
diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
index e55fb42..4e7939f 100644
--- a/lib/ethdev/rte_ethdev_core.h
+++ b/lib/ethdev/rte_ethdev_core.h
@@ -16,6 +16,8 @@ 
  * Applications should not use these directly.
  */
 
+#include <rte_ethdev_export.h>
+
 struct rte_eth_dev_callback;
 /** @internal Structure to keep track of registered callbacks */
 RTE_TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
@@ -126,6 +128,7 @@  struct __rte_cache_aligned rte_eth_fp_ops {
 
 };
 
+__rte_ethdev_export
 extern struct rte_eth_fp_ops rte_eth_fp_ops[RTE_MAX_ETHPORTS];
 
 #endif /* _RTE_ETHDEV_CORE_H_ */
diff --git a/lib/ethdev/rte_ethdev_export.h b/lib/ethdev/rte_ethdev_export.h
new file mode 100644
index 0000000..7887bee
--- /dev/null
+++ b/lib/ethdev/rte_ethdev_export.h
@@ -0,0 +1,23 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 Microsoft Corporation
+ */
+
+#ifndef _RTE_ETHDEV_EXPORT_H_
+#define _RTE_ETHDEV_EXPORT_H_
+
+/**
+ * @file
+ *
+ * Import / Export macros for ethdev data variables.
+ */
+
+#include <rte_common.h>
+
+#ifndef __rte_ethdev_export
+#define __rte_ethdev_export __rte_declare_import
+#else
+#undef __rte_ethdev_export
+#define __rte_ethdev_export __rte_declare_export
+#endif
+
+#endif
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index 79f6f52..efe426f 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -83,7 +83,7 @@  DPDK_24 {
 	rte_eth_find_next_of;
 	rte_eth_find_next_owned_by;
 	rte_eth_find_next_sibling;
-	rte_eth_fp_ops;
+	rte_eth_fp_ops; # MSVC_NO_EXPORT
 	rte_eth_iterator_cleanup;
 	rte_eth_iterator_init;
 	rte_eth_iterator_next;