6#ifndef SIMPLECOLLECTIONS_SCTHREADINGSUPPORT_H
7#define SIMPLECOLLECTIONS_SCTHREADINGSUPPORT_H
14#if defined(BUILD_FOR_PICO_CMAKE)
15#include <pico/stdlib.h>
16#elif !defined(__MBED__)
33#if defined __has_include
34# if __has_include ("zio_local_definitions.h")
35# include "zio_local_definitions.h"
42#if defined(ARDUINO_PICO_REVISION) || defined(BUILD_FOR_PICO_CMAKE)
43typedef volatile uint32_t* position_ptr_t;
44typedef volatile uint32_t position_t;
45bool casAtomic(position_ptr_t ptr, position_t expected, position_t newVal);
46inline position_t readAtomic(position_ptr_t ptr) {
return *(ptr); }
47void atomicInitialisationSupport();
48#define SIMPLECOLLECTIONS_PICO_PHT_SUPPORT
49#elif defined(__MBED__) || defined(TMIOA_FORCE_ARDUINO_MBED)
50#include <mbed_atomic.h>
51typedef volatile uint32_t* position_ptr_t;
52typedef volatile uint32_t position_t;
53#define atomicInitialisationSupport()
54inline bool casAtomic(position_ptr_t ptr, position_t expected, position_t newVal) {
55 uint32_t exp = expected;
56 return core_util_atomic_cas_u32(ptr, &exp, newVal);
58inline uint32_t readAtomic(position_ptr_t ptr) {
return *(ptr); }
59#elif (defined(SC_USE_ARM_ASM_CAS) || defined(ARDUINO_ARCH_STM32)) && !defined(SC_NO_ARM_ASM_CAS)
60#define atomicInitialisationSupport()
63#define SIMPLE_COLLECTIONS_ARM_SUPPORT
64typedef volatile uint32_t* position_ptr_t;
65typedef volatile uint32_t position_t;
66bool casAtomic(position_ptr_t ptr, position_t expected, position_t newVal);
67inline uint32_t readAtomic(position_ptr_t ptr) {
return *(ptr); }
69typedef volatile uint32_t* position_ptr_t;
70typedef volatile uint32_t position_t;
71#define NEEDS_CAS_EMULATION
75typedef volatile uint32_t* position_ptr_t;
76typedef volatile uint32_t position_t;
77#define atomicInitialisationSupport()
78#define NEEDS_CAS_EMULATION
81typedef volatile uint32_t* position_ptr_t;
82typedef volatile uint32_t position_t;
83#define atomicInitialisationSupport()
84#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
85inline bool casAtomic(position_ptr_t ptr, position_t expected, position_t newVal) {
86 uint32_t exp32 = expected;
87 uint32_t new32 = newVal;
88 uxPortCompareSet(ptr, exp32, &new32);
89 return new32 == expected;
92inline bool casAtomic(position_ptr_t ptr, position_t expected, position_t newVal) {
94 return esp_cpu_compare_and_set(ptr, expected, newVal);
97inline uint16_t readAtomic(position_ptr_t ptr) {
return *(ptr); }
100#define atomicInitialisationSupport()
101typedef volatile uint16_t* position_ptr_t;
102typedef volatile uint16_t position_t;
103#define NEEDS_CAS_EMULATION
106#ifdef NEEDS_CAS_EMULATION
107bool casAtomic(position_ptr_t ptr, position_t expected, position_t newVal);
108inline uint16_t readAtomic(position_ptr_t ptr) {
return *ptr; }