OVMS3-idf/components/driver/cas.h
2019-06-11 13:06:32 +08:00

23 lines
No EOL
543 B
C

#ifndef __CAS_H__
#define __CAS_H__
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/portmacro.h"
#define __cas_temp_sync_compare_and_swap_test(ptr, expected, desired) ({\
bool ret = false;\
unsigned state = portENTER_CRITICAL_NESTED(); \
if (*ptr == expected) { \
*ptr = desired; \
ret = true;\
}\
portEXIT_CRITICAL_NESTED(state); \
ret; \
})
#define __sync_bool_compare_and_swap(ptr, expected, desired) __cas_temp_sync_compare_and_swap_test(ptr, expected, desired)
#endif