Repository navigation
arch/espressif: add stdatomic.h shim for ATOMIC_VAR_INIT - #20770
Merged
acassis merged 1 commit intoOct 18, 2026
Merged
Conversation
In C23 and GCC 15 (e.g., xtensa-esp-elf-gcc 15.2.0), ATOMIC_VAR_INIT was removed from <stdatomic.h> after being deprecated in C17. Third-party HAL components in esp-hal-3rdparty (such as esp_gpio_reserve.c) still utilize ATOMIC_VAR_INIT to initialize atomic masks (e.g., s_reserved_pin_mask), causing compilation errors under GCC 15 due to implicit function declarations and non-constant initializers. Provide a platform_include wrapper for <stdatomic.h> on both Xtensa and RISC-V Espressif architectures using #include_next that defines ATOMIC_VAR_INIT(value) when it is not provided by the toolchain. Fixes apache#20704 Signed-off-by: Swatantra Yadav <[email protected]>
xiaoxiang781216
approved these changes
Oct 18, 2026
acassis
approved these changes
Oct 18, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In C23 and GCC 15 toolchains (e.g.,
xtensa-esp-elf-gcc 15.2.0), the legacyATOMIC_VAR_INITmacro was completely removed from<stdatomic.h>after being deprecated in C17. Third-party HAL components inesp-hal-3rdparty(such ascomponents/esp_hw_support/esp_gpio_reserve.c) still useATOMIC_VAR_INITto initialize atomic masks (s_reserved_pin_mask), triggering-Wimplicit-function-declarationandinitializer element is not constanterrors during build.Adds a lightweight
platform_includewrapper for<stdatomic.h>under:arch/xtensa/src/common/espressif/platform_include/stdatomic.harch/risc-v/src/common/espressif/platform_include/stdatomic.hThe wrapper uses
#include_next <stdatomic.h>to include the toolchain's header first, and then conditionally definesATOMIC_VAR_INIT(value) (value)if not already provided.Fixes [BUG] esp32s3: esp-hal-3rdparty fails to build with GCC 15 (ATOMIC_VAR_INIT removed) #20704
Impact
#include_nextis evaluated first, older toolchains that already defineATOMIC_VAR_INITtake precedence and will not trigger macro redefinition warnings.esp-hal-3rdpartyrepository.Testing
#include_next <stdatomic.h>header interception and#ifndef ATOMIC_VAR_INITfallback logic.nxstyle(0 errors, 0 warnings).codespellandcvt2utf.tools/checkpatch.sh.