Skip to contentSkip to conversation

remove __typeof__ from expansion of per lcore macros

PATCH Superseded Tyler Retzlaff 4 participants 16 messages Dec 19, 2023 – Feb 14, 2024 Crypto API

lore
Share & tools
lore
#0 lore raw

cover remove __typeof__ from expansion of per lcore macros

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

Tyler Retzlaff (2):
eal: provide type instead of expression to per lcore macro
eal: remove typeof from per lcore macros

 lib/eal/common/eal_common_errno.c | 2 +-
 lib/eal/include/rte_per_lcore.h   | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/2 eal: provide type instead of expression to per lcore macro

Adjust the use of per lcore macro to provide type as the first argument as to not require __typeof__ during expansion.

---
 lib/eal/common/eal_common_errno.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/eal/common/eal_common_errno.c +1 -1
index b30e2f0..fff8c1f 100644
@@ -28,7 +28,7 @@
 	static const char *sep = "";
 #endif
 #define RETVAL_SZ 256
-	static RTE_DEFINE_PER_LCORE(char[RETVAL_SZ], retval);
+	static RTE_DEFINE_PER_LCORE(char, retval[RETVAL_SZ]);
 	char *ret = RTE_PER_LCORE(retval);
 
 	/* since some implementations of strerror_r throw an error
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/2 eal: remove typeof from per lcore macros

In reply to Tyler Retzlaff

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

---
 lib/eal/include/rte_per_lcore.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/eal/include/rte_per_lcore.h +4 -4
index 41fe1f0..529995e 100644
@@ -24,10 +24,10 @@
 
 #ifdef RTE_TOOLCHAIN_MSVC
 #define RTE_DEFINE_PER_LCORE(type, name)			\
-	__declspec(thread) typeof(type) per_lcore_##name
+	__declspec(thread) type per_lcore_##name
 
 #define RTE_DECLARE_PER_LCORE(type, name)			\
-	extern __declspec(thread) typeof(type) per_lcore_##name
+	extern __declspec(thread) type per_lcore_##name
 #else
 /**
  * Macro to define a per lcore variable "var" of type "type", don't
@@ -35,13 +35,13 @@
  * whole macro.
  */
 #define RTE_DEFINE_PER_LCORE(type, name)			\
-	__thread __typeof__(type) per_lcore_##name
+	__thread type per_lcore_##name
 
 /**
  * Macro to declare an extern per lcore variable "var" of type "type"
  */
 #define RTE_DECLARE_PER_LCORE(type, name)			\
-	extern __thread __typeof__(type) per_lcore_##name
+	extern __thread type per_lcore_##name
 #endif
 
 /**
Signature · 1 line
1.8.3.1
#3 lore raw
In reply to Tyler Retzlaff
Quoted 6 lines · Tyler Retzlaff

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Quoted 7 lines

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

Tyler Retzlaff (2):
eal: provide type instead of expression to per lcore macro
eal: remove typeof from per lcore macros

#4 lore raw

v2 cover remove __typeof__ from expansion of per lcore macros

In reply to Tyler Retzlaff

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

v2:
* add additional patch to adjust usage for crypto/ipsec_mb

Tyler Retzlaff (3):
eal: provide type to per lcore macro crypto/ipsec_mb: provide type to per lcore macro
eal: remove typeof from per lcore macros

 drivers/crypto/ipsec_mb/pmd_aesni_gcm_priv.h | 2 +-
 lib/eal/common/eal_common_errno.c            | 2 +-
 lib/eal/include/rte_per_lcore.h              | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v2 1/3 eal: provide type to per lcore macro

Adjust the use of per lcore macro to provide type as the first argument as to not require __typeof__ during expansion.

---
 lib/eal/common/eal_common_errno.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/eal/common/eal_common_errno.c +1 -1
index b30e2f0..fff8c1f 100644
@@ -28,7 +28,7 @@
 	static const char *sep = "";
 #endif
 #define RETVAL_SZ 256
-	static RTE_DEFINE_PER_LCORE(char[RETVAL_SZ], retval);
+	static RTE_DEFINE_PER_LCORE(char, retval[RETVAL_SZ]);
 	char *ret = RTE_PER_LCORE(retval);
 
 	/* since some implementations of strerror_r throw an error
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH v2 2/3 crypto/ipsec_mb: provide type to per lcore macro

In reply to Tyler Retzlaff

Adjust the use of per lcore macro to provide type as the first argument as to not require __typeof__ during expansion.

---
 drivers/crypto/ipsec_mb/pmd_aesni_gcm_priv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ipsec_mb/pmd_aesni_gcm_priv.h +1 -1
index 55a0416..8a5a41f 100644
@@ -130,7 +130,7 @@ struct aesni_gcm_ops {
 	aesni_gmac_finalize_t gmac_finalize;
 };
 
-RTE_DEFINE_PER_LCORE(struct aesni_gcm_ops[GCM_NUM_KEY_TYPES], gcm_ops);
+RTE_DEFINE_PER_LCORE(struct aesni_gcm_ops, gcm_ops[GCM_NUM_KEY_TYPES]);
 
 struct aesni_gcm_qp_data {
 	struct gcm_context_data gcm_ctx_data;
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH v2 3/3 eal: remove typeof from per lcore macros

In reply to Tyler Retzlaff

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

---
 lib/eal/include/rte_per_lcore.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/eal/include/rte_per_lcore.h +4 -4
index 41fe1f0..529995e 100644
@@ -24,10 +24,10 @@
 
 #ifdef RTE_TOOLCHAIN_MSVC
 #define RTE_DEFINE_PER_LCORE(type, name)			\
-	__declspec(thread) typeof(type) per_lcore_##name
+	__declspec(thread) type per_lcore_##name
 
 #define RTE_DECLARE_PER_LCORE(type, name)			\
-	extern __declspec(thread) typeof(type) per_lcore_##name
+	extern __declspec(thread) type per_lcore_##name
 #else
 /**
  * Macro to define a per lcore variable "var" of type "type", don't
@@ -35,13 +35,13 @@
  * whole macro.
  */
 #define RTE_DEFINE_PER_LCORE(type, name)			\
-	__thread __typeof__(type) per_lcore_##name
+	__thread type per_lcore_##name
 
 /**
  * Macro to declare an extern per lcore variable "var" of type "type"
  */
 #define RTE_DECLARE_PER_LCORE(type, name)			\
-	extern __thread __typeof__(type) per_lcore_##name
+	extern __thread type per_lcore_##name
 #endif
 
 /**
Signature · 1 line
1.8.3.1
#8 lore raw
In reply to Tyler Retzlaff
Quoted 6 lines · Tyler Retzlaff

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Quoted 6 lines

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

v2:
* add additional patch to adjust usage for crypto/ipsec_mb

#9 lore raw
In reply to Tyler Retzlaff
Quoted 9 lines · Tyler Retzlaff

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

Please add a release note on this topic (I am fine with just a reply to this mail, I can fold this change when applying).

The rest lgtm.

Signature · 1 line
David Marchand
#10 lore raw

v3 cover remove __typeof__ from expansion of per lcore macros

In reply to Tyler Retzlaff

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

v3:
* provide notice in release_24_03.rst about change in macro expansion.
v2:
* add additional patch to adjust usage for crypto/ipsec_mb

Tyler Retzlaff (3):
eal: provide type to per lcore macro crypto/ipsec_mb: provide type to per lcore macro
eal: remove typeof from per lcore macros

 doc/guides/rel_notes/release_24_03.rst       | 5 +++++
 drivers/crypto/ipsec_mb/pmd_aesni_gcm_priv.h | 2 +-
 lib/eal/common/eal_common_errno.c            | 2 +-
 lib/eal/include/rte_per_lcore.h              | 8 ++++----
 4 files changed, 11 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.3.1
#11 lore raw

PATCH v3 1/3 eal: provide type to per lcore macro

Adjust the use of per lcore macro to provide type as the first argument as to not require __typeof__ during expansion.

---
 lib/eal/common/eal_common_errno.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/eal/common/eal_common_errno.c +1 -1
index b30e2f0..fff8c1f 100644
@@ -28,7 +28,7 @@
 	static const char *sep = "";
 #endif
 #define RETVAL_SZ 256
-	static RTE_DEFINE_PER_LCORE(char[RETVAL_SZ], retval);
+	static RTE_DEFINE_PER_LCORE(char, retval[RETVAL_SZ]);
 	char *ret = RTE_PER_LCORE(retval);
 
 	/* since some implementations of strerror_r throw an error
Signature · 1 line
1.8.3.1
#12 lore raw

PATCH v3 2/3 crypto/ipsec_mb: provide type to per lcore macro

In reply to Tyler Retzlaff

Adjust the use of per lcore macro to provide type as the first argument as to not require __typeof__ during expansion.

---
 drivers/crypto/ipsec_mb/pmd_aesni_gcm_priv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ipsec_mb/pmd_aesni_gcm_priv.h +1 -1
index 55a0416..8a5a41f 100644
@@ -130,7 +130,7 @@ struct aesni_gcm_ops {
 	aesni_gmac_finalize_t gmac_finalize;
 };
 
-RTE_DEFINE_PER_LCORE(struct aesni_gcm_ops[GCM_NUM_KEY_TYPES], gcm_ops);
+RTE_DEFINE_PER_LCORE(struct aesni_gcm_ops, gcm_ops[GCM_NUM_KEY_TYPES]);
 
 struct aesni_gcm_qp_data {
 	struct gcm_context_data gcm_ctx_data;
Signature · 1 line
1.8.3.1
#13 lore raw

PATCH v3 3/3 eal: remove typeof from per lcore macros

In reply to Tyler Retzlaff

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

---
 doc/guides/rel_notes/release_24_03.rst | 5 +++++
 lib/eal/include/rte_per_lcore.h        | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)
doc/guides/rel_notes/release_24_03.rst +5 -0
index 6741947..39088da 100644
@@ -89,6 +89,11 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* eal: Removed ``typeof(type)`` from the expansion of ``RTE_DEFINE_PER_LCORE``
+  and ``RTE_DECLARE_PER_LCORE`` macros aligning them with their intended design.
+  If use with an expression is desired applications can adapt by supplying
+  ``typeof(e)`` as an argument.
+
 * gso: ``rte_gso_segment`` now returns -ENOTSUP for unknown protocols.
 
 
lib/eal/include/rte_per_lcore.h +4 -4
index 41fe1f0..529995e 100644
@@ -24,10 +24,10 @@
 
 #ifdef RTE_TOOLCHAIN_MSVC
 #define RTE_DEFINE_PER_LCORE(type, name)			\
-	__declspec(thread) typeof(type) per_lcore_##name
+	__declspec(thread) type per_lcore_##name
 
 #define RTE_DECLARE_PER_LCORE(type, name)			\
-	extern __declspec(thread) typeof(type) per_lcore_##name
+	extern __declspec(thread) type per_lcore_##name
 #else
 /**
  * Macro to define a per lcore variable "var" of type "type", don't
@@ -35,13 +35,13 @@
  * whole macro.
  */
 #define RTE_DEFINE_PER_LCORE(type, name)			\
-	__thread __typeof__(type) per_lcore_##name
+	__thread type per_lcore_##name
 
 /**
  * Macro to declare an extern per lcore variable "var" of type "type"
  */
 #define RTE_DECLARE_PER_LCORE(type, name)			\
-	extern __thread __typeof__(type) per_lcore_##name
+	extern __thread type per_lcore_##name
 #endif
 
 /**
Signature · 1 line
1.8.3.1
#14 lore raw

RE: [PATCH v3 3/3] eal: remove typeof from per lcore macros

Quoted 9 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 13 February 2024 20.12

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Quoted 6 lines

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

---

#15 lore raw
In reply to Tyler Retzlaff
Quoted 21 lines · Tyler Retzlaff

The design of the macros requires a type to be provided to the macro.

By expanding the type parameter inside of typeof it also inadvertently allows an expression to be used which appears not to have been intended after evaluating the parameter name and existing macro use.

Technically this is an API break but only for applications that were using these macros outside of the original design intent.

v3:
* provide notice in release_24_03.rst about change in macro expansion.
v2:
* add additional patch to adjust usage for crypto/ipsec_mb

Tyler Retzlaff (3):
eal: provide type to per lcore macro crypto/ipsec_mb: provide type to per lcore macro
eal: remove typeof from per lcore macros

Quoted 5 lines
 doc/guides/rel_notes/release_24_03.rst       | 5 +++++
 drivers/crypto/ipsec_mb/pmd_aesni_gcm_priv.h | 2 +-
 lib/eal/common/eal_common_errno.c            | 2 +-
 lib/eal/include/rte_per_lcore.h              | 8 ++++----
 4 files changed, 11 insertions(+), 6 deletions(-)

Thanks Tyler.
Series applied.

Signature · 1 line
David Marchand