DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org
Cc: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Bruce Richardson <bruce.richardson@intel.com>,
	David Marchand <david.marchand@redhat.com>,
	Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH 2/3] eal: import and export data variables for MSVC
Date: Tue, 12 Mar 2024 00:51:47 -0700	[thread overview]
Message-ID: <1710229908-31704-3-git-send-email-roretzla@linux.microsoft.com> (raw)
In-Reply-To: <1710229908-31704-1-git-send-email-roretzla@linux.microsoft.com>

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/eal/include/meson.build      |  1 +
 lib/eal/include/rte_common.h     |  8 ++++++++
 lib/eal/include/rte_eal.h        |  2 ++
 lib/eal/include/rte_eal_export.h | 23 +++++++++++++++++++++++
 lib/eal/include/rte_errno.h      |  2 ++
 lib/eal/version.map              |  6 +++---
 lib/meson.build                  |  2 ++
 7 files changed, 41 insertions(+), 3 deletions(-)
 create mode 100644 lib/eal/include/rte_eal_export.h

diff --git a/lib/eal/include/meson.build b/lib/eal/include/meson.build
index e94b056..376ae81 100644
--- a/lib/eal/include/meson.build
+++ b/lib/eal/include/meson.build
@@ -16,6 +16,7 @@ headers += files(
         'rte_dev.h',
         'rte_devargs.h',
         'rte_eal.h',
+        'rte_eal_export.h',
         'rte_eal_memconfig.h',
         'rte_eal_trace.h',
         'rte_errno.h',
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 298a5c6..ad80122 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -26,6 +26,14 @@
 /* OS specific include */
 #include <rte_os.h>
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_declare_import __declspec(dllimport)
+#define __rte_declare_export __declspec(dllexport)
+#else
+#define __rte_declare_import
+#define __rte_declare_export
+#endif
+
 #ifndef RTE_TOOLCHAIN_MSVC
 #ifndef typeof
 #define typeof __typeof__
diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h
index c2256f8..d0dc91b 100644
--- a/lib/eal/include/rte_eal.h
+++ b/lib/eal/include/rte_eal.h
@@ -16,6 +16,7 @@
 
 #include <rte_config.h>
 #include <rte_compat.h>
+#include <rte_eal_export.h>
 #include <rte_per_lcore.h>
 #include <rte_uuid.h>
 
@@ -426,6 +427,7 @@ typedef int (*rte_mp_async_reply_t)(const struct rte_mp_msg *request,
  */
 int rte_sys_gettid(void);
 
+__rte_eal_export
 RTE_DECLARE_PER_LCORE(int, _thread_id);
 
 /**
diff --git a/lib/eal/include/rte_eal_export.h b/lib/eal/include/rte_eal_export.h
new file mode 100644
index 0000000..3901760
--- /dev/null
+++ b/lib/eal/include/rte_eal_export.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 Microsoft Corporation
+ */
+
+#ifndef _RTE_EAL_EXPORT_H_
+#define _RTE_EAL_EXPORT_H_
+
+/**
+ * @file
+ *
+ * Import / Export macros for eal data variables.
+ */
+
+#include <rte_common.h>
+
+#ifndef __rte_eal_export
+#define __rte_eal_export __rte_declare_import
+#else
+#undef __rte_eal_export
+#define __rte_eal_export __rte_declare_export
+#endif
+
+#endif
diff --git a/lib/eal/include/rte_errno.h b/lib/eal/include/rte_errno.h
index ba45591..311732f 100644
--- a/lib/eal/include/rte_errno.h
+++ b/lib/eal/include/rte_errno.h
@@ -15,8 +15,10 @@
 extern "C" {
 #endif
 
+#include <rte_eal_export.h>
 #include <rte_per_lcore.h>
 
+__rte_eal_export
 RTE_DECLARE_PER_LCORE(int, _rte_errno); /**< Per core error number. */
 
 /**
diff --git a/lib/eal/version.map b/lib/eal/version.map
index c06ceaa..62914d2 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -4,9 +4,9 @@ DPDK_24 {
 	__rte_panic;
 	eal_parse_sysfs_value; # WINDOWS_NO_EXPORT
 	eal_timer_source; # WINDOWS_NO_EXPORT
-	per_lcore__lcore_id;
-	per_lcore__rte_errno;
-	per_lcore__thread_id;
+	per_lcore__lcore_id; # MSVC_NO_EXPORT
+	per_lcore__rte_errno; # MSVC_NO_EXPORT
+	per_lcore__thread_id; # MSVC_NO_EXPORT
 	rte_bus_dump;
 	rte_bus_find;
 	rte_bus_find_by_device;
diff --git a/lib/meson.build b/lib/meson.build
index f8836a4..f8d88d2 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -235,6 +235,8 @@ foreach l:libraries
         cflags += '-Wthread-safety'
     endif
 
+    cflags += '-D__rte_@0@_export'.format(name)
+
     # first build static lib
     static_lib = static_library(libname,
             sources,
-- 
1.8.3.1


  parent reply	other threads:[~2024-03-12  7:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12  7:51 [PATCH 0/3] RFC fix import/export MSVC data variables Tyler Retzlaff
2024-03-12  7:51 ` [PATCH 1/3] buildtools: ignore exports for MSVC Tyler Retzlaff
2024-03-12  7:51 ` Tyler Retzlaff [this message]
2024-03-12  7:51 ` [PATCH 3/3] ethdev: import and export data variables " Tyler Retzlaff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1710229908-31704-3-git-send-email-roretzla@linux.microsoft.com \
    --to=roretzla@linux.microsoft.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).