diff options
| author | Bernard Xiong <[email protected]> | 2023-05-20 23:41:29 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-20 23:41:29 +0800 |
| commit | 4b4c3c85f2ac82f12d5527ef1a6794b2189a9eee (patch) | |
| tree | 8703fb21033f143017b17c83b00aef1b425a8e2a /include/rtdef.h | |
| parent | 1e5dc5509e0fbc325df926c8911fdc2780e7cf4c (diff) | |
[atomic] add stdc atomic detection. (#7536)
Diffstat (limited to 'include/rtdef.h')
| -rw-r--r-- | include/rtdef.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/include/rtdef.h b/include/rtdef.h index 1c3b1a5027..e70a9cac98 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -48,6 +48,7 @@ * 2022-09-12 Meco Man define rt_ssize_t * 2022-12-20 Meco Man add const name for rt_object * 2023-04-01 Chushicheng change version number to v5.0.1 + * 2023-05-20 Bernard add stdc atomic detection. */ #ifndef __RT_DEF_H__ @@ -126,12 +127,24 @@ typedef rt_base_t rt_flag_t; /**< Type for flags */ typedef rt_ubase_t rt_dev_t; /**< Type for device */ typedef rt_base_t rt_off_t; /**< Type for offset */ +#if !defined(__cplusplus) #if defined(RT_USING_STDC_ATOMIC) -#include <stdatomic.h> -typedef atomic_size_t rt_atomic_t; + #include <stdatomic.h> + typedef atomic_size_t rt_atomic_t; +#elif defined(RT_USING_HW_ATOMIC) + typedef volatile rt_base_t rt_atomic_t; #else -typedef volatile rt_base_t rt_atomic_t; -#endif + + /* To detect std atomic */ + #if defined(RT_USING_LIBC) && defined(__GNUC__) && !defined(__STDC_NO_ATOMICS__) + #include <stdatomic.h> + typedef atomic_size_t rt_atomic_t; + #else + typedef volatile rt_base_t rt_atomic_t; + #endif /* __GNUC__ && !__STDC_NO_ATOMICS__ */ + +#endif /* RT_USING_STDC_ATOMIC */ +#endif /* __cplusplus */ /* boolean type definitions */ #define RT_TRUE 1 /**< boolean true */ |
