Select one of the symbols to view example projects that use it.
 
Outline
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "esp_stdatomic.h"
#include "freertos/FreeRTOS.h"
#include "sdkconfig.h"
s_atomic_lock
#define _ATOMIC_HW_STUB_OP_FUNCTION
#define _ATOMIC_HW_STUB_EXCHANGE
#define _ATOMIC_HW_STUB_STORE
#define _ATOMIC_HW_STUB_CMP_EXCHANGE
#define _ATOMIC_HW_STUB_LOAD
#define _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE
#define _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE
#define _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET
#define _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE
__atomic_compare_exchange_8(volatile void *, void *, unsigned long long, bool, int, int)
__atomic_store_8(volatile void *, unsigned long long, int)
__sync_bool_compare_and_swap_8_builtin(volatile void *, unsigned long long, unsigned long long)
__sync_lock_release_8_builtin(volatile void *)
__atomic_load_builtin(size_t, const volatile void *, void *, int)
__atomic_store_builtin(size_t, volatile void *, void *, int)
__atomic_compare_exchange_builtin(size_t, volatile void *, void *, void *, int, int)
Files
loading (1/5)...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/newlib/stdatomic.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ //replacement for gcc built-in functions #include <stdbool.h> #include <stdint.h> #include <string.h> #include "esp_stdatomic.h" #include "freertos/FreeRTOS.h" #include "sdkconfig.h"6 includes #if SOC_CPU_CORES_NUM > 1 #if !CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND _Static_assert(HAS_ATOMICS_32, "32-bit atomics should be supported if SOC_CPU_CORES_NUM > 1"); #endif // CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND // Only need to implement 64-bit atomics here. Use a single global portMUX_TYPE spinlock // to emulate the atomics. static portMUX_TYPE s_atomic_lock = portMUX_INITIALIZER_UNLOCKED;/* ... */ #endif #if !HAS_ATOMICS_32 _Static_assert(sizeof(unsigned char) == 1, "atomics require a 1-byte type"); _Static_assert(sizeof(short unsigned int) == 2, "atomics require a 2-bytes type"); _Static_assert(sizeof(unsigned int) == 4, "atomics require a 4-bytes type"); ATOMIC_FUNCTIONS(1, unsigned char) ATOMIC_FUNCTIONS(2, short unsigned int) ATOMIC_FUNCTIONS(4, unsigned int) /* ... */ #elif __riscv_atomic == 1 bool CLANG_ATOMIC_SUFFIX(__atomic_always_lock_free)(unsigned int size, const volatile void *) { return size <= sizeof(int); }{...} CLANG_DECLARE_ALIAS(__atomic_always_lock_free) bool CLANG_ATOMIC_SUFFIX(__atomic_is_lock_free)(unsigned int size, const volatile void *) { return size <= sizeof(int); }{...} CLANG_DECLARE_ALIAS(__atomic_is_lock_free) /* ... */ #endif // !HAS_ATOMICS_32 #if !HAS_ATOMICS_64 #if CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND #undef _ATOMIC_HW_STUB_OP_FUNCTION #undef _ATOMIC_HW_STUB_EXCHANGE #undef _ATOMIC_HW_STUB_STORE #undef _ATOMIC_HW_STUB_CMP_EXCHANGE #undef _ATOMIC_HW_STUB_LOAD #undef _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE #undef _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE #undef _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET #undef _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE #define _ATOMIC_HW_STUB_OP_FUNCTION(n, type, name_1, name_2) #define _ATOMIC_HW_STUB_EXCHANGE(n, type) #define _ATOMIC_HW_STUB_STORE(n, type) #define _ATOMIC_HW_STUB_CMP_EXCHANGE(n, type) #define _ATOMIC_HW_STUB_LOAD(n, type) #define _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE(n, type) #define _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE(n, type) #define _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET(n, type) #define _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE(n, type)9 defines /* ... */#endif // CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND _Static_assert(sizeof(long long unsigned int) == 8, "atomics require a 8-bytes type"); ATOMIC_FUNCTIONS(8, long long unsigned int) /* ... */ #endif // !HAS_ATOMICS_64 // Clang generates calls to the __atomic_load/__atomic_store functions for object size more then 4 bytes void CLANG_ATOMIC_SUFFIX(__atomic_load)(size_t size, const volatile void *src, void *dest, int model) { _ATOMIC_ENTER_CRITICAL(); memcpy(dest, (const void *)src, size); _ATOMIC_EXIT_CRITICAL(); }{...} CLANG_DECLARE_ALIAS(__atomic_load) void CLANG_ATOMIC_SUFFIX(__atomic_store)(size_t size, volatile void *dest, void *src, int model) { _ATOMIC_ENTER_CRITICAL(); memcpy((void *)dest, (const void *)src, size); _ATOMIC_EXIT_CRITICAL(); }{...} CLANG_DECLARE_ALIAS(__atomic_store) bool CLANG_ATOMIC_SUFFIX(__atomic_compare_exchange)(size_t size, volatile void *ptr, void *expected, void *desired, int success_memorder, int failure_memorder) { bool ret = false; _ATOMIC_ENTER_CRITICAL(); if (!memcmp((void *)ptr, expected, size)) { memcpy((void *)ptr, (const void *)desired, size); ret = true; }{...} else { memcpy((void *)expected, (const void *)ptr, size); }{...} _ATOMIC_EXIT_CRITICAL(); return ret; }{...} CLANG_DECLARE_ALIAS(__atomic_compare_exchange)
Details