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.
This commit is contained in:
Ville Juven 2022-09-13 09:29:45 +03:00 committed by Daniel Agar
parent ff196a7363
commit f300ec1da2
1 changed files with 4 additions and 2 deletions

View File

@ -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;