DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andre Muezerie <andremue@linux.microsoft.com>
To: andremue@linux.microsoft.com
Cc: dev@dpdk.org, roretzla@linux.microsoft.com
Subject: [PATCH v3] eal: fix macros for MSVC: noinline, alwaysinline, hot
Date: Wed, 22 Jan 2025 08:24:25 -0800	[thread overview]
Message-ID: <1737563065-18741-1-git-send-email-andremue@linux.microsoft.com> (raw)
In-Reply-To: <1732723879-23806-1-git-send-email-andremue@linux.microsoft.com>

MSVC supports forcing code to be inlined or forcing code to not be
inlined, like other compilers. It does not support the "hot" hint
though.

This patch fixes existing macros __rte_noinline and
__rte_always_inline so that they also do what is expected from them
when used with MSVC. __rte_hot is updated to become a noop when
MSCS is used.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/eal/include/rte_common.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 40592f71b1..f344d54fce 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -427,7 +427,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
  * Force a function to be inlined
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_always_inline
+#define __rte_always_inline __forceinline
 #else
 #define __rte_always_inline inline __attribute__((always_inline))
 #endif
@@ -435,12 +435,20 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /**
  * Force a function to be noinlined
  */
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_noinline __declspec(noinline)
+#else
 #define __rte_noinline __attribute__((noinline))
+#endif
 
 /**
  * Hint function in the hot path
  */
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_hot
+#else
 #define __rte_hot __attribute__((hot))
+#endif
 
 /**
  * Hint function in the cold path
-- 
2.47.2.vfs.0.1


  parent reply	other threads:[~2025-01-22 16:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-27 16:11 [PATCH] lib/eal: fix macros for noinline and alwaysinline for MSVC Andre Muezerie
2024-11-27 19:39 ` [PATCH v2] " Andre Muezerie
2025-01-22 16:24 ` Andre Muezerie [this message]
2025-01-22 17:10   ` [PATCH v3] eal: fix macros for MSVC: noinline, alwaysinline, hot Morten Brørup

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=1737563065-18741-1-git-send-email-andremue@linux.microsoft.com \
    --to=andremue@linux.microsoft.com \
    --cc=dev@dpdk.org \
    --cc=roretzla@linux.microsoft.com \
    /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).