mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-17 15:15:02 +00:00
fix(newlib): fix __atomic_test_and_set to ensure atomicity
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. For GCC toolchains which do not have such patch yet, this commit fixes __atomic_test_and_set to be atomic in IDF's builds.
This commit is contained in:
24
components/newlib/platform_include/stdatomic.h
Normal file
24
components/newlib/platform_include/stdatomic.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
#include_next "stdatomic.h"
|
||||
#ifndef __clang__
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline bool __atomic_test_and_set(volatile void *ptr, int memorder)
|
||||
{
|
||||
return __atomic_exchange_1((bool *)ptr, true, memorder);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user