xiaoxiang781216 commented on code in PR #14827: URL: https://github.com/apache/nuttx/pull/14827#discussion_r1866836255
########## include/nuttx/atomic.h: ########## @@ -81,16 +82,55 @@ extern "C++" # if !(__clang__) && defined(__cplusplus) # define _Atomic # endif -# include <stdbool.h> # include <stdatomic.h> -# ifndef ATOMIC_VAR_INIT -# define ATOMIC_VAR_INIT(value) (value) -# endif -# else -# include <nuttx/lib/stdatomic.h> +# define USE_STD_ATOMIC 1 # endif +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef __ATOMIC_RELAXED +# define __ATOMIC_RELAXED 0 +#endif + +#ifndef __ATOMIC_CONSUME +# define __ATOMIC_CONSUME 1 +#endif + +#ifndef __ATOMIC_ACQUIRE +# define __ATOMIC_ACQUIRE 2 +#endif + +#ifndef __ATOMIC_RELEASE +# define __ATOMIC_RELEASE 3 +#endif + +#ifndef __ATOMIC_ACQ_REL +# define __ATOMIC_ACQ_REL 4 +#endif + +#ifndef __ATOMIC_SEQ_CST +# define __ATOMIC_SEQ_CST 5 +#endif + +#ifdef USE_STD_ATOMIC +# define ATOMIC_FUNC(f, n) atomic_##f##_explicit #else -# include <nuttx/lib/stdatomic.h> +# define ATOMIC_FUNC(f, n) nx_atomic_##f##_##n +#endif + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#if __clang__ Review Comment: remove if/else, _Atomic is already handle at line 83 ########## include/nuttx/atomic.h: ########## @@ -27,13 +27,14 @@ * Included Files ****************************************************************************/ +#include <stdbool.h> + #ifdef __has_include # if defined(__cplusplus) && __has_include(<atomic>) extern "C++" { # include <atomic> - -# define ATOMIC_VAR_INIT(value) (value) +# define USE_STD_ATOMIC 1 using std::memory_order; Review Comment: remove the unused function and type ########## include/nuttx/atomic.h: ########## @@ -81,16 +82,55 @@ extern "C++" # if !(__clang__) && defined(__cplusplus) # define _Atomic # endif -# include <stdbool.h> # include <stdatomic.h> -# ifndef ATOMIC_VAR_INIT -# define ATOMIC_VAR_INIT(value) (value) -# endif -# else -# include <nuttx/lib/stdatomic.h> +# define USE_STD_ATOMIC 1 # endif +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef __ATOMIC_RELAXED +# define __ATOMIC_RELAXED 0 +#endif + +#ifndef __ATOMIC_CONSUME +# define __ATOMIC_CONSUME 1 +#endif + +#ifndef __ATOMIC_ACQUIRE +# define __ATOMIC_ACQUIRE 2 +#endif + +#ifndef __ATOMIC_RELEASE +# define __ATOMIC_RELEASE 3 +#endif + +#ifndef __ATOMIC_ACQ_REL +# define __ATOMIC_ACQ_REL 4 +#endif + +#ifndef __ATOMIC_SEQ_CST +# define __ATOMIC_SEQ_CST 5 +#endif + +#ifdef USE_STD_ATOMIC +# define ATOMIC_FUNC(f, n) atomic_##f##_explicit Review Comment: let's define ATOMIC_FUNC directly -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org