fix(newlib): add missing __atomic_test_and_set for RISCV chips wo 'a' extension

Before the change described in
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631393.html it
appeared that inlining built-in GCC function __atomic_test_and_set() was
incorrect. It resulted in a non-atomic write.
After the change now present in GCC, the IDF should include the function
__atomic_test_and_set() to successfully link the final binary.

Closes https://github.com/espressif/esp-idf/issues/15167
This commit is contained in:
Alexey Lapshin
2025-01-13 12:49:52 +07:00
parent 90fbd41701
commit 793e394f5a
2 changed files with 24 additions and 3 deletions
+9 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -32,6 +32,14 @@ ATOMIC_FUNCTIONS(1, unsigned char)
ATOMIC_FUNCTIONS(2, short unsigned int)
ATOMIC_FUNCTIONS(4, unsigned int)
#ifndef __clang__
/* LLVM automatically replaces __atomic_test_and_set -> __atomic_exchange_1 call when compiling */
bool __atomic_test_and_set(volatile void *ptr, int memorder)
{
return __atomic_exchange_1(ptr, true, memorder);
}
#endif
#elif __riscv_atomic == 1
bool CLANG_ATOMIC_SUFFIX(__atomic_always_lock_free)(unsigned int size, const volatile void *)