From f300ec1da250cc897adca37c352b9275bb38d037 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Tue, 13 Sep 2022 09:29:45 +0300 Subject: [PATCH] px4_platform_common/atomic.h: fetch_add/sub were really fetch_inc/dec fetch_add/sub were really inc/dec for the __atomic_always_lock_free == true branch. This fixes them so that the arg "num" is actually used. --- platforms/common/include/px4_platform_common/atomic.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platforms/common/include/px4_platform_common/atomic.h b/platforms/common/include/px4_platform_common/atomic.h index b2d828efdb..47b3fb6de8 100644 --- a/platforms/common/include/px4_platform_common/atomic.h +++ b/platforms/common/include/px4_platform_common/atomic.h @@ -128,7 +128,8 @@ public: if (!__atomic_always_lock_free(sizeof(T), 0)) { irqstate_t flags = enter_critical_section(); - T ret = _value++; + T ret = _value; + _value += num; leave_critical_section(flags); return ret; @@ -149,7 +150,8 @@ public: if (!__atomic_always_lock_free(sizeof(T), 0)) { irqstate_t flags = enter_critical_section(); - T ret = _value--; + T ret = _value; + _value -= num; leave_critical_section(flags); return ret;