DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] lib/eal: fix macros for noinline and alwaysinline for MSVC
@ 2024-11-27 16:11 Andre Muezerie
  2024-11-27 19:39 ` [PATCH v2] " Andre Muezerie
  2025-01-22 16:24 ` [PATCH v3] eal: fix macros for MSVC: noinline, alwaysinline, hot Andre Muezerie
  0 siblings, 2 replies; 4+ messages in thread
From: Andre Muezerie @ 2024-11-27 16:11 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Andre Muezerie, Andre Muezerie

From: Andre Muezerie <andremue@ntdev.microsoft.com>

MSVC supports forcing code to be inlined or forcing code to not be
inlined, like other compilers.

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.

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

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 4d299f2b36..f97e52f869 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -408,7 +408,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
@@ -416,7 +416,11 @@ 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
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] lib/eal: fix macros for noinline and alwaysinline for MSVC
  2024-11-27 16:11 [PATCH] lib/eal: fix macros for noinline and alwaysinline for MSVC Andre Muezerie
@ 2024-11-27 19:39 ` Andre Muezerie
  2025-01-22 16:24 ` [PATCH v3] eal: fix macros for MSVC: noinline, alwaysinline, hot Andre Muezerie
  1 sibling, 0 replies; 4+ messages in thread
From: Andre Muezerie @ 2024-11-27 19:39 UTC (permalink / raw)
  To: andremue; +Cc: dev, roretzla

MSVC supports forcing code to be inlined or forcing code to not be
inlined, like other compilers.

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.

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

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 21bfd26b2b..ed6e2c7ffd 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -410,7 +410,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
@@ -418,7 +418,11 @@ 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
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3] eal: fix macros for MSVC: noinline, alwaysinline, hot
  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
  2025-01-22 17:10   ` Morten Brørup
  1 sibling, 1 reply; 4+ messages in thread
From: Andre Muezerie @ 2025-01-22 16:24 UTC (permalink / raw)
  To: andremue; +Cc: dev, roretzla

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v3] eal: fix macros for MSVC: noinline, alwaysinline, hot
  2025-01-22 16:24 ` [PATCH v3] eal: fix macros for MSVC: noinline, alwaysinline, hot Andre Muezerie
@ 2025-01-22 17:10   ` Morten Brørup
  0 siblings, 0 replies; 4+ messages in thread
From: Morten Brørup @ 2025-01-22 17:10 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, roretzla

> From: Andre Muezerie [mailto:andremue@linux.microsoft.com]
> Sent: Wednesday, 22 January 2025 17.24
> 
> 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>
> ---

Acked-by: Morten Brørup <mb@smartsharesystems.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-22 17:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v3] eal: fix macros for MSVC: noinline, alwaysinline, hot Andre Muezerie
2025-01-22 17:10   ` Morten Brørup

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).