[PATCH 19.11 2/4] eal: fix C++ include

Bruce Richardson bruce.richardson at intel.com
Tue Mar 1 15:08:36 CET 2022


C++ files could not include some headers because "new" is a keyword in
C++, so can't be a variable name

Fixes: 184104fc6121 ("ticketlock: introduce fair ticket based locking")
Cc: stable at dpdk.org

(This is a backport of patch 59144f6edd from mainline)

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
 .../common/include/generic/rte_ticketlock.h        | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/librte_eal/common/include/generic/rte_ticketlock.h b/lib/librte_eal/common/include/generic/rte_ticketlock.h
index d9bec87692..5f432cfbe8 100644
--- a/lib/librte_eal/common/include/generic/rte_ticketlock.h
+++ b/lib/librte_eal/common/include/generic/rte_ticketlock.h
@@ -96,13 +96,13 @@ __rte_experimental
 static inline int
 rte_ticketlock_trylock(rte_ticketlock_t *tl)
 {
-	rte_ticketlock_t old, new;
-	old.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
-	new.tickets = old.tickets;
-	new.s.next++;
-	if (old.s.next == old.s.current) {
-		if (__atomic_compare_exchange_n(&tl->tickets, &old.tickets,
-		    new.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
+	rte_ticketlock_t oldl, newl;
+	oldl.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
+	newl.tickets = oldl.tickets;
+	newl.s.next++;
+	if (oldl.s.next == oldl.s.current) {
+		if (__atomic_compare_exchange_n(&tl->tickets, &oldl.tickets,
+		    newl.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
 			return 1;
 	}
 
-- 
2.32.0



More information about the stable mailing list