MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / emscripten_atomic_cas_u8

Function emscripten_atomic_cas_u8

system/include/emscripten/atomic.h:43–47  ·  view source on GitHub ↗

CAS returns the *old* value that was in the memory location before the operation took place. That is, if the return value when calling this function equals to 'oldVal', then the operation succeeded, otherwise it was ignored.

Source from the content-addressed store, hash-verified

41// That is, if the return value when calling this function equals to 'oldVal',
42// then the operation succeeded, otherwise it was ignored.
43_EM_INLINE uint8_t emscripten_atomic_cas_u8(void /*uint8_t*/* _Nonnull addr, uint8_t oldVal, uint8_t newVal) {
44 uint8_t expected = oldVal;
45 __c11_atomic_compare_exchange_strong((_Atomic uint8_t*)addr, &expected, newVal, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
46 return expected;
47}
48_EM_INLINE uint16_t emscripten_atomic_cas_u16(void /*uint16_t*/* _Nonnull addr, uint16_t oldVal, uint16_t newVal) {
49 uint16_t expected = oldVal;
50 __c11_atomic_compare_exchange_strong((_Atomic uint16_t*)addr, &expected, newVal, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected