J. Nick Koston 22ed9b3c1e [scheduler] Replace volatile with __atomic_{load,store}_n on NO_ATOMICS
Copilot review on #15947 flagged that `volatile uint32_t` is not a
well-defined concurrent access in the C++ memory model — it prevents
the compiler caching/eliding the read, but does not turn a plain
cross-thread read/write pair into a defined access. Technically still
a formal data race even though aligned 32-bit LDR/STR on ARMv5TE is
atomic at the hardware level.

Switch the NO_ATOMICS counter reads and writes to GCC's atomic
builtins with __ATOMIC_RELAXED:

  - Readers: __atomic_load_n(&counter, __ATOMIC_RELAXED)
  - Writers (under lock_): __atomic_store_n(&counter, new_value,
                                             __ATOMIC_RELAXED)
  - Increment/decrement (under lock_): explicit load + compute +
    __atomic_store_n. Lock_ serialises the load-modify-store against
    other writers; the atomic ops make the write visible to concurrent
    readers in the memory model.

On ARMv5TE these builtins compile to plain LDR/STR — same codegen as
the previous volatile approach, and no libatomic dependency (only RMW
builtins like __atomic_fetch_add would need the lib). ATOMICS and
SINGLE paths are unchanged.
2026-04-23 06:06:02 -05:00
2023-06-12 17:00:34 +12:00
2022-09-06 15:48:01 +12:00
2025-12-21 09:26:03 -05:00
2024-03-28 10:20:51 +13:00
2025-07-17 22:40:28 +12:00
2025-12-08 14:37:45 -05:00
2026-04-09 11:28:48 +12:00
2025-07-17 22:40:28 +12:00
S
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme Multiple Licenses
601 MiB
Languages
C++ 55.8%
Python 43.6%
C 0.3%
JavaScript 0.2%