Commit 46d4d607 by Marcus Winter

linux fixes

parent 965cefbd
...@@ -293,7 +293,9 @@ extern "C" { ...@@ -293,7 +293,9 @@ extern "C" {
#endif #endif
#include <embb/base/c/internal/cmake_config.h> #include <embb/base/c/internal/cmake_config.h>
#ifdef EMBB_THREADING_ANALYSIS_MODE #ifdef EMBB_THREADING_ANALYSIS_MODE
#include <embb/base/c/internal/platform.h> #include <embb/base/c/internal/platform.h>
#include <assert.h> #include <assert.h>
...@@ -322,8 +324,11 @@ void embb_mutex_destroy( ...@@ -322,8 +324,11 @@ void embb_mutex_destroy(
#else #else
#define EMBB_ATOMIC_MUTEX_LOCK(mutex) #define EMBB_ATOMIC_MUTEX_INIT(...)
#define EMBB_ATOMIC_MUTEX_UNLOCK(mutex) #define EMBB_ATOMIC_MUTEX_LOCK(...)
#define EMBB_ATOMIC_MUTEX_UNLOCK(...)
#define EMBB_ATOMIC_MUTEX_DESTROY(...)
#define EMBB_ATOMIC_INIT_CHECK(...)
#endif #endif
......
...@@ -42,6 +42,7 @@ ...@@ -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) \ #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_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) { \ EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable) { \
(void)variable; \
EMBB_ATOMIC_INIT_CHECK(variable); \ EMBB_ATOMIC_INIT_CHECK(variable); \
EMBB_ATOMIC_MUTEX_DESTROY(variable->internal_mutex); \ EMBB_ATOMIC_MUTEX_DESTROY(variable->internal_mutex); \
} }
......
...@@ -117,10 +117,10 @@ FetchAndAdd(DifferenceType val) { ...@@ -117,10 +117,10 @@ FetchAndAdd(DifferenceType val) {
NativeType native_desired; NativeType native_desired;
memcpy(&native_desired, &desired, sizeof(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<NativeType>:: NativeType storage_value = fetch_and_add_implementation<NativeType>::
fetch_and_add(&this->AtomicValue, native_desired); 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)); memcpy(&return_value, &storage_value, sizeof(return_value));
return return_value; return return_value;
......
...@@ -93,10 +93,10 @@ inline void AtomicInteger<BaseType>::operator&=(BaseType val) { ...@@ -93,10 +93,10 @@ inline void AtomicInteger<BaseType>::operator&=(BaseType val) {
NativeType native_operand; NativeType native_operand;
memcpy(&native_operand, &val, sizeof(val)); memcpy(&native_operand, &val, sizeof(val));
EMBB_ATOMIC_MUTEX_LOCK(internal_mutex); EMBB_ATOMIC_MUTEX_LOCK(this->internal_mutex);
and_assign_implementation<NativeType>:: and_assign_implementation<NativeType>::
and_assign(&this->AtomicValue, native_operand); and_assign(&this->AtomicValue, native_operand);
EMBB_ATOMIC_MUTEX_UNLOCK(internal_mutex); EMBB_ATOMIC_MUTEX_UNLOCK(this->internal_mutex);
} }
template<typename BaseType> template<typename BaseType>
...@@ -104,10 +104,10 @@ inline void AtomicInteger<BaseType>::operator|=(BaseType val) { ...@@ -104,10 +104,10 @@ inline void AtomicInteger<BaseType>::operator|=(BaseType val) {
NativeType native_operand; NativeType native_operand;
memcpy(&native_operand, &val, sizeof(val)); memcpy(&native_operand, &val, sizeof(val));
EMBB_ATOMIC_MUTEX_LOCK(internal_mutex); EMBB_ATOMIC_MUTEX_LOCK(this->internal_mutex);
or_assign_implementation<NativeType>:: or_assign_implementation<NativeType>::
or_assign(&this->AtomicValue, native_operand); or_assign(&this->AtomicValue, native_operand);
EMBB_ATOMIC_MUTEX_UNLOCK(internal_mutex); EMBB_ATOMIC_MUTEX_UNLOCK(this->internal_mutex);
} }
template<typename BaseType> template<typename BaseType>
...@@ -115,10 +115,10 @@ inline void AtomicInteger<BaseType>::operator^=(BaseType val) { ...@@ -115,10 +115,10 @@ inline void AtomicInteger<BaseType>::operator^=(BaseType val) {
NativeType native_operand; NativeType native_operand;
memcpy(&native_operand, &val, sizeof(val)); memcpy(&native_operand, &val, sizeof(val));
EMBB_ATOMIC_MUTEX_LOCK(internal_mutex); EMBB_ATOMIC_MUTEX_LOCK(this->internal_mutex);
xor_assign_implementation<NativeType>:: xor_assign_implementation<NativeType>::
xor_assign(&this->AtomicValue, native_operand); xor_assign(&this->AtomicValue, native_operand);
EMBB_ATOMIC_MUTEX_UNLOCK(internal_mutex); EMBB_ATOMIC_MUTEX_UNLOCK(this->internal_mutex);
} }
} // namespace atomic } // namespace atomic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment