Skip to content

Commit c3aea91

Browse files
author
dave
committed
#10 critical ESP8266 fix
1 parent bb96ebf commit c3aea91

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/TaskPlatformDeps.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,24 @@ namespace tm_internal {
100100
interrupts();
101101
return ret;
102102
}
103+
104+
/**
105+
* Reads an atomic boolean value
106+
* @param pPtr the pointer to an atomic boolean value
107+
* @return the boolean value.
108+
*/
109+
inline bool atomicReadBool(TmAtomicBool *pPtr) {
110+
return atomic_load(pPtr);
111+
}
112+
113+
/**
114+
* Writes a boolean value atomically
115+
* @param pPtr the atomic ref
116+
* @param newVal the new value
117+
*/
118+
inline void atomicWriteBool(TmAtomicBool *pPtr, bool newVal) {
119+
atomic_store(pPtr, newVal);
120+
}
103121
#else
104122
typedef uint32_t TmAtomicBool; // to use CAS, the bool must be 32 bits wide
105123
inline bool atomicSwapBool(TmAtomicBool *ptr, bool expected, bool newValue) {
@@ -108,7 +126,7 @@ namespace tm_internal {
108126
uxPortCompareSet(ptr, exp32, &new32);
109127
return new32 == expected;
110128
}
111-
#endif
129+
112130
/**
113131
* Reads an atomic boolean value
114132
* @param pPtr the pointer to an atomic boolean value
@@ -126,6 +144,8 @@ namespace tm_internal {
126144
inline void atomicWriteBool(TmAtomicBool *pPtr, bool newVal) {
127145
*pPtr = newVal;
128146
}
147+
#endif
148+
129149

130150
/**
131151
* Dereferences and returns the value of the pointer at ptr type. On mbed boards this is already an atomic operation and

0 commit comments

Comments
 (0)