mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 10:26:52 +08:00
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:
@@ -128,7 +128,8 @@ public:
|
|||||||
|
|
||||||
if (!__atomic_always_lock_free(sizeof(T), 0)) {
|
if (!__atomic_always_lock_free(sizeof(T), 0)) {
|
||||||
irqstate_t flags = enter_critical_section();
|
irqstate_t flags = enter_critical_section();
|
||||||
T ret = _value++;
|
T ret = _value;
|
||||||
|
_value += num;
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -149,7 +150,8 @@ public:
|
|||||||
|
|
||||||
if (!__atomic_always_lock_free(sizeof(T), 0)) {
|
if (!__atomic_always_lock_free(sizeof(T), 0)) {
|
||||||
irqstate_t flags = enter_critical_section();
|
irqstate_t flags = enter_critical_section();
|
||||||
T ret = _value--;
|
T ret = _value;
|
||||||
|
_value -= num;
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user