From 46d4d607916405e6b44ce95aabf7dab1681e827e Mon Sep 17 00:00:00 2001 From: Marcus Winter Date: Wed, 2 Nov 2016 20:48:56 +0100 Subject: [PATCH] linux fixes --- base_c/include/embb/base/c/atomic.h | 9 +++++++-- base_c/include/embb/base/c/internal/atomic/destroy.h | 1 + base_cpp/include/embb/base/internal/atomic/atomic_arithmetic.h | 4 ++-- base_cpp/include/embb/base/internal/atomic/atomic_integer.h | 12 ++++++------ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/base_c/include/embb/base/c/atomic.h b/base_c/include/embb/base/c/atomic.h index 1c3933e..b3a9d03 100644 --- a/base_c/include/embb/base/c/atomic.h +++ b/base_c/include/embb/base/c/atomic.h @@ -293,7 +293,9 @@ extern "C" { #endif #include + #ifdef EMBB_THREADING_ANALYSIS_MODE + #include #include @@ -322,8 +324,11 @@ void embb_mutex_destroy( #else -#define EMBB_ATOMIC_MUTEX_LOCK(mutex) -#define EMBB_ATOMIC_MUTEX_UNLOCK(mutex) +#define EMBB_ATOMIC_MUTEX_INIT(...) +#define EMBB_ATOMIC_MUTEX_LOCK(...) +#define EMBB_ATOMIC_MUTEX_UNLOCK(...) +#define EMBB_ATOMIC_MUTEX_DESTROY(...) +#define EMBB_ATOMIC_INIT_CHECK(...) #endif 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 33dfc94..4f4054a 100644 --- a/base_c/include/embb/base/c/internal/atomic/destroy.h +++ b/base_c/include/embb/base/c/internal/atomic/destroy.h @@ -42,6 +42,7 @@ #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_cpp/include/embb/base/internal/atomic/atomic_arithmetic.h b/base_cpp/include/embb/base/internal/atomic/atomic_arithmetic.h index e3deea2..9b50c20 100644 --- a/base_cpp/include/embb/base/internal/atomic/atomic_arithmetic.h +++ b/base_cpp/include/embb/base/internal/atomic/atomic_arithmetic.h @@ -117,10 +117,10 @@ FetchAndAdd(DifferenceType val) { NativeType native_desired; memcpy(&native_desired, &desired, sizeof(desired)); - EMBB_ATOMIC_MUTEX_LOCK(internal_mutex); + EMBB_ATOMIC_MUTEX_LOCK(this->internal_mutex); NativeType storage_value = fetch_and_add_implementation:: fetch_and_add(&this->AtomicValue, native_desired); - EMBB_ATOMIC_MUTEX_UNLOCK(internal_mutex); + EMBB_ATOMIC_MUTEX_UNLOCK(this->internal_mutex); memcpy(&return_value, &storage_value, sizeof(return_value)); return return_value; diff --git a/base_cpp/include/embb/base/internal/atomic/atomic_integer.h b/base_cpp/include/embb/base/internal/atomic/atomic_integer.h index 6da4c97..d426f49 100644 --- a/base_cpp/include/embb/base/internal/atomic/atomic_integer.h +++ b/base_cpp/include/embb/base/internal/atomic/atomic_integer.h @@ -93,10 +93,10 @@ inline void AtomicInteger::operator&=(BaseType val) { NativeType native_operand; memcpy(&native_operand, &val, sizeof(val)); - EMBB_ATOMIC_MUTEX_LOCK(internal_mutex); + EMBB_ATOMIC_MUTEX_LOCK(this->internal_mutex); and_assign_implementation:: and_assign(&this->AtomicValue, native_operand); - EMBB_ATOMIC_MUTEX_UNLOCK(internal_mutex); + EMBB_ATOMIC_MUTEX_UNLOCK(this->internal_mutex); } template @@ -104,10 +104,10 @@ inline void AtomicInteger::operator|=(BaseType val) { NativeType native_operand; memcpy(&native_operand, &val, sizeof(val)); - EMBB_ATOMIC_MUTEX_LOCK(internal_mutex); + EMBB_ATOMIC_MUTEX_LOCK(this->internal_mutex); or_assign_implementation:: or_assign(&this->AtomicValue, native_operand); - EMBB_ATOMIC_MUTEX_UNLOCK(internal_mutex); + EMBB_ATOMIC_MUTEX_UNLOCK(this->internal_mutex); } template @@ -115,10 +115,10 @@ inline void AtomicInteger::operator^=(BaseType val) { NativeType native_operand; memcpy(&native_operand, &val, sizeof(val)); - EMBB_ATOMIC_MUTEX_LOCK(internal_mutex); + EMBB_ATOMIC_MUTEX_LOCK(this->internal_mutex); xor_assign_implementation:: xor_assign(&this->AtomicValue, native_operand); - EMBB_ATOMIC_MUTEX_UNLOCK(internal_mutex); + EMBB_ATOMIC_MUTEX_UNLOCK(this->internal_mutex); } } // namespace atomic -- libgit2 0.26.0