From ed30c5531249d1b3e909b2d62b354c1024eac43a Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 30 Mar 2023 09:05:18 -0400 Subject: [PATCH] MT#56447 fix LOCK __COUNTER__ expansion We need two levels of CPP macros so that __COUNTER__ is expanded before being concatenated. Change-Id: I04d871a3bb841080eb8992bb8261551b5bd22832 --- lib/auxlib.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/auxlib.h b/lib/auxlib.h index f96cb665d..e2d40c69d 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -227,13 +227,15 @@ INLINE void rtpe_auto_cleanup_rwlock_w(rwlock_t **m) { rwlock_unlock_w(*m); } -#define LOCK(m) AUTO_CLEANUP(mutex_t *__auto_lock_## __COUNTER__, rtpe_auto_cleanup_mutex) \ +#define CONCAT2(a, b) a ## b +#define CONCAT(a, b) CONCAT2(a, b) +#define LOCK(m) AUTO_CLEANUP(mutex_t *CONCAT(__auto_lock_, __COUNTER__), rtpe_auto_cleanup_mutex) \ __attribute__((unused)) = m; \ mutex_lock(m) -#define RWLOCK_R(m) AUTO_CLEANUP(rwlock_t *__auto_lock_## __COUNTER__, rtpe_auto_cleanup_rwlock_r) \ +#define RWLOCK_R(m) AUTO_CLEANUP(rwlock_t *CONCAT(__auto_lock_, __COUNTER__), rtpe_auto_cleanup_rwlock_r) \ __attribute__((unused)) = m; \ rwlock_lock_r(m) -#define RWLOCK_W(m) AUTO_CLEANUP(rwlock_t *__auto_lock_## __COUNTER__, rtpe_auto_cleanup_rwlock_w) \ +#define RWLOCK_W(m) AUTO_CLEANUP(rwlock_t *CONCAT(__auto_lock_, __COUNTER__), rtpe_auto_cleanup_rwlock_w) \ __attribute__((unused)) = m; \ rwlock_lock_w(m)