diff --git a/base_c/include/embb/base/c/atomic.h b/base_c/include/embb/base/c/atomic.h index b3a9d03..c0868d9 100644 --- a/base_c/include/embb/base/c/atomic.h +++ b/base_c/include/embb/base/c/atomic.h @@ -321,6 +321,7 @@ void embb_mutex_destroy( #define EMBB_ATOMIC_MUTEX_UNLOCK(mutex) embb_mutex_unlock(&(mutex)) #define EMBB_ATOMIC_MUTEX_DESTROY(mutex) embb_mutex_destroy(&(mutex)) #define EMBB_ATOMIC_INIT_CHECK(variable) assert(variable->marker == 0x12345678) +#define EMBB_ATOMIC_INIT_MARKER(variable) variable->marker = 0x12345678 #else @@ -328,7 +329,8 @@ void embb_mutex_destroy( #define EMBB_ATOMIC_MUTEX_LOCK(...) #define EMBB_ATOMIC_MUTEX_UNLOCK(...) #define EMBB_ATOMIC_MUTEX_DESTROY(...) -#define EMBB_ATOMIC_INIT_CHECK(...) +#define EMBB_ATOMIC_INIT_CHECK(variable) (void)(variable) +#define EMBB_ATOMIC_INIT_MARKER(variable) (void)(variable) #endif diff --git a/base_c/include/embb/base/c/internal/atomic/atomic_variables.h b/base_c/include/embb/base/c/internal/atomic/atomic_variables.h index 8d9b19d..2e85f37 100644 --- a/base_c/include/embb/base/c/internal/atomic/atomic_variables.h +++ b/base_c/include/embb/base/c/internal/atomic/atomic_variables.h @@ -35,6 +35,8 @@ #include #endif +#ifdef EMBB_THREADING_ANALYSIS_MODE + #define EMBB_ATOMIC_INTERNAL_DEFINE_VARIABLE( \ EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, \ EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX) \ @@ -45,6 +47,18 @@ uint32_t marker; \ } EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX); +#else + +#define EMBB_ATOMIC_INTERNAL_DEFINE_VARIABLE( \ + EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, \ + EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX) \ + typedef struct \ +{ \ + volatile EMBB_ATOMIC_PARAMETER_TYPE_NATIVE internal_variable; \ +} EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX); + +#endif + EMBB_ATOMIC_INTERNAL_DEFINE_VARIABLE(char, char) EMBB_ATOMIC_INTERNAL_DEFINE_VARIABLE(short, short) EMBB_ATOMIC_INTERNAL_DEFINE_VARIABLE(unsigned short, unsigned_short) diff --git a/base_c/include/embb/base/c/internal/atomic/destroy.h b/base_c/include/embb/base/c/internal/atomic/destroy.h index 4f4054a..33dfc94 100644 --- a/base_c/include/embb/base/c/internal/atomic/destroy.h +++ b/base_c/include/embb/base/c/internal/atomic/destroy.h @@ -42,7 +42,6 @@ #define EMBB_ATOMIC_INTERNAL_DEFINE_DESTROY_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \ EMBB_PLATFORM_INLINE void EMBB_CAT2(embb_atomic_destroy_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable) { \ - (void)variable; \ EMBB_ATOMIC_INIT_CHECK(variable); \ EMBB_ATOMIC_MUTEX_DESTROY(variable->internal_mutex); \ } diff --git a/base_c/include/embb/base/c/internal/atomic/init.h b/base_c/include/embb/base/c/internal/atomic/init.h index a338eda..68f6ce4 100644 --- a/base_c/include/embb/base/c/internal/atomic/init.h +++ b/base_c/include/embb/base/c/internal/atomic/init.h @@ -43,7 +43,7 @@ EMBB_PLATFORM_INLINE void EMBB_CAT2(embb_atomic_init_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable) { \ EMBB_ATOMIC_MUTEX_INIT(variable->internal_mutex); \ - variable->marker = 0x12345678; \ + EMBB_ATOMIC_INIT_MARKER(variable); \ } #undef EMBB_ATOMIC_METHOD_TO_GENERATE