forked from Archive/PX4-Autopilot
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:
parent
ff196a7363
commit
f300ec1da2
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue