Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
650dec9d
authored
Feb 02, 2015
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
portability: renamend all platform specific defines to EMBB_PLATFORM_*
parent
9f2daa72
Show whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
201 additions
and
200 deletions
+201
-200
base_c/CMakeLists.txt
+5
-5
base_c/include/embb/base/c/atomic.h
+9
-9
base_c/include/embb/base/c/internal/atomic/and_assign.h
+9
-9
base_c/include/embb/base/c/internal/atomic/atomic_variables.h
+1
-1
base_c/include/embb/base/c/internal/atomic/compare_and_swap.h
+9
-9
base_c/include/embb/base/c/internal/atomic/fetch_and_add.h
+9
-9
base_c/include/embb/base/c/internal/atomic/load.h
+9
-9
base_c/include/embb/base/c/internal/atomic/memory_barrier.h
+8
-8
base_c/include/embb/base/c/internal/atomic/or_assign.h
+9
-9
base_c/include/embb/base/c/internal/atomic/store.h
+9
-9
base_c/include/embb/base/c/internal/atomic/swap.h
+9
-9
base_c/include/embb/base/c/internal/atomic/xor_assign.h
+9
-9
base_c/include/embb/base/c/internal/bitset.h
+8
-8
base_c/include/embb/base/c/internal/cmake_config.h.in
+5
-4
base_c/include/embb/base/c/internal/config.h
+21
-21
base_c/include/embb/base/c/internal/platform.h
+5
-5
base_c/src/condition_variable.c
+4
-4
base_c/src/core_set.c
+8
-8
base_c/src/log.c
+2
-2
base_c/src/memory_allocation.c
+5
-5
base_c/src/mutex.c
+4
-4
base_c/src/thread.c
+10
-10
base_c/src/time.c
+4
-4
base_c/test/alloc_test.cc
+1
-1
base_cpp/include/embb/base/atomic.h
+1
-1
base_cpp/include/embb/base/exceptions.h
+3
-3
base_cpp/include/embb/base/internal/config.h
+1
-1
base_cpp/include/embb/base/internal/duration-inl.h
+2
-2
base_cpp/include/embb/base/internal/platform.h
+3
-3
base_cpp/src/thread.cc
+5
-5
base_cpp/test/memory_allocation_test.cc
+6
-6
containers_cpp/include/embb/containers/internal/hazard_pointer.h
+1
-1
containers_cpp/include/embb/containers/internal/lock_free_mpmc_queue-inl.h
+2
-2
containers_cpp/include/embb/containers/internal/lock_free_stack-inl.h
+2
-2
containers_cpp/test/hazard_pointer_test.cc
+2
-2
mtapi_c/src/mtapi_status_t.h
+1
-1
No files found.
base_c/CMakeLists.txt
View file @
650dec9d
...
...
@@ -77,14 +77,14 @@ endif()
# Check headers and create configure file with preprocessor defines
include
(
CheckIncludeFiles
)
# Includes module to perform checks
include
(
CheckSymbolExists
)
# Includes module to perform symbol checks
check_include_files
(
"sys/sysinfo.h"
EMBB_HAS_HEADER_SYSINFO
)
check_include_files
(
"sys/types.h;sys/sysctl.h"
EMBB_HAS_HEADER_SYSCTL
)
check_include_files
(
"sys/param.h;sys/cpuset.h"
EMBB_HAS_HEADER_CPUSET
)
check_include_files
(
"sys/sysinfo.h"
EMBB_
PLATFORM_
HAS_HEADER_SYSINFO
)
check_include_files
(
"sys/types.h;sys/sysctl.h"
EMBB_
PLATFORM_
HAS_HEADER_SYSCTL
)
check_include_files
(
"sys/param.h;sys/cpuset.h"
EMBB_
PLATFORM_
HAS_HEADER_CPUSET
)
link_libraries
(
${
link_libraries
}
${
gnu_libs
}
)
set
(
CMAKE_EXTRA_INCLUDE_FILES sched.h
)
check_type_size
(
cpu_set_t EMBB_HAS_GLIB_CPU
)
check_type_size
(
cpu_set_t EMBB_
PLATFORM_
HAS_GLIB_CPU
)
set
(
CMAKE_EXTRA_INCLUDE_FILES
)
if
(
DEFINED EMBB_HAS_GLIB_CPU
)
if
(
DEFINED EMBB_
PLATFORM_
HAS_GLIB_CPU
)
add_definitions
(
-D_GNU_SOURCE
)
# Needed to activate CPU_ macros
endif
()
...
...
base_c/include/embb/base/c/atomic.h
View file @
650dec9d
...
...
@@ -95,7 +95,7 @@
* \ingroup C_BASE_ATOMIC
* \waitfree
*/
EMBB_INLINE
void
embb_atomic_and_assign_TYPE
(
EMBB_
PLATFORM_
INLINE
void
embb_atomic_and_assign_TYPE
(
embb_atomic_TYPE
*
variable
,
/**< [IN,OUT] Pointer to atomic variable which serves as left-hand side for
the "and" operation and is used to store the result. */
...
...
@@ -120,7 +120,7 @@ EMBB_INLINE void embb_atomic_and_assign_TYPE(
* \ingroup C_BASE_ATOMIC
* \waitfree
*/
EMBB_INLINE
int
embb_atomic_compare_and_swap_TYPE
(
EMBB_
PLATFORM_
INLINE
int
embb_atomic_compare_and_swap_TYPE
(
embb_atomic_TYPE
*
variable
,
/**< [IN,OUT] Pointer to atomic variable */
TYPE
*
expected
,
...
...
@@ -140,7 +140,7 @@ EMBB_INLINE int embb_atomic_compare_and_swap_TYPE(
* \ingroup C_BASE_ATOMIC
* \waitfree
*/
EMBB_INLINE
TYPE
embb_atomic_fetch_and_add_TYPE
(
EMBB_
PLATFORM_
INLINE
TYPE
embb_atomic_fetch_and_add_TYPE
(
embb_atomic_TYPE
*
variable
,
/**< [IN,OUT] Pointer to atomic variable*/
TYPE
value
...
...
@@ -158,7 +158,7 @@ EMBB_INLINE TYPE embb_atomic_fetch_and_add_TYPE(
* \ingroup C_BASE_ATOMIC
* \waitfree
*/
EMBB_INLINE
TYPE
embb_atomic_load_TYPE
(
EMBB_
PLATFORM_
INLINE
TYPE
embb_atomic_load_TYPE
(
const
embb_atomic_TYPE
*
variable
/**< [IN] Pointer to atomic variable */
);
...
...
@@ -169,7 +169,7 @@ EMBB_INLINE TYPE embb_atomic_load_TYPE(
* \ingroup C_BASE_ATOMIC
* \waitfree
*/
EMBB_INLINE
void
embb_atomic_memory_barrier
();
EMBB_
PLATFORM_
INLINE
void
embb_atomic_memory_barrier
();
/**
* Computes the logical "or" of the value stored in \p variable and \c value.
...
...
@@ -182,7 +182,7 @@ EMBB_INLINE void embb_atomic_memory_barrier();
* \ingroup C_BASE_ATOMIC
* \waitfree
*/
EMBB_INLINE
void
embb_atomic_or_assign_TYPE
(
EMBB_
PLATFORM_
INLINE
void
embb_atomic_or_assign_TYPE
(
embb_atomic_TYPE
*
variable
,
/**< [IN,OUT] Pointer to atomic variable which serves as left-hand side for
the "or" operation and is used to store the result. */
...
...
@@ -199,7 +199,7 @@ EMBB_INLINE void embb_atomic_or_assign_TYPE(
* \ingroup C_BASE_ATOMIC
* \waitfree
*/
EMBB_INLINE
void
embb_atomic_store_TYPE
(
EMBB_
PLATFORM_
INLINE
void
embb_atomic_store_TYPE
(
embb_atomic_TYPE
*
variable
,
/**< [IN,OUT] Pointer to atomic variable */
int
value
...
...
@@ -217,7 +217,7 @@ EMBB_INLINE void embb_atomic_store_TYPE(
* \ingroup C_BASE_ATOMIC
* \waitfree
*/
EMBB_INLINE
TYPE
embb_atomic_swap_TYPE
(
EMBB_
PLATFORM_
INLINE
TYPE
embb_atomic_swap_TYPE
(
embb_atomic_TYPE
*
variable
,
/**< [IN,OUT] Pointer to atomic variable whose value is swapped */
TYPE
value
...
...
@@ -235,7 +235,7 @@ EMBB_INLINE TYPE embb_atomic_swap_TYPE(
* \ingroup C_BASE_ATOMIC
* \waitfree
*/
EMBB_INLINE
void
embb_atomic_xor_assign_TYPE
(
EMBB_
PLATFORM_
INLINE
void
embb_atomic_xor_assign_TYPE
(
embb_atomic_TYPE
*
variable
,
/**< [IN,OUT] Pointer to atomic variable which serves as left-hand side for
the "xor" operation and is used to store the result. */
...
...
base_c/include/embb/base/c/internal/atomic/and_assign.h
View file @
650dec9d
...
...
@@ -53,21 +53,21 @@
* BYTE_SIZE is the number of bytes passed to the macro.
*
*/
#ifdef EMBB_ARCH_X86
#ifdef EMBB_
PLATFORM_
ARCH_X86
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#define EMBB_DEFINE_AND_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
extern void __fastcall EMBB_CAT2(embb_internal__atomic_and_assign_, EMBB_PARAMETER_SIZE_BYTE)_asm( \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value); \
EMBB_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_and_assign_, EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \
EMBB_
PLATFORM_
INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_and_assign_, EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \
_ReadWriteBarrier(); \
EMBB_CAT2(embb_internal__atomic_and_assign_, EMBB_PARAMETER_SIZE_BYTE)_asm(pointer_to_value, value); \
_ReadWriteBarrier(); \
}
#elif defined(EMBB_COMPILER_GNUC)
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_AND_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX)\
EMBB_INLINE void EMBB_CAT2(embb_internal__atomic_and_assign_, \
EMBB_
PLATFORM_
INLINE void EMBB_CAT2(embb_internal__atomic_and_assign_, \
EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \
__asm__ __volatile__("lock and" EMBB_ATOMIC_X86_SIZE_SUFFIX " %1, %0" \
: "+m" (*pointer_to_value), "+q" (value) \
...
...
@@ -89,12 +89,12 @@ EMBB_DEFINE_AND_ASSIGN(4, "l")
EMBB_DEFINE_AND_ASSIGN
(
8
,
"q"
)
#endif
#elif defined(EMBB_ARCH_ARM)
#elif defined(EMBB_
PLATFORM_
ARCH_ARM)
#if defined(EMBB_COMPILER_GNUC)
#if defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_AND_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, \
EMBB_ATOMIC_ARM_SIZE_SUFFIX) \
EMBB_INLINE \
EMBB_
PLATFORM_
INLINE \
void EMBB_CAT2(embb_internal__atomic_and_assign_, \
EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
...
...
@@ -148,7 +148,7 @@ EMBB_DEFINE_AND_ASSIGN(4, "")
* This generated function is supposed to be called by the user of the lib.
*/
#define EMBB_ATOMIC_INTERNAL_DEFINE_AND_ASSIGN_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \
EMBB_INLINE void EMBB_CAT2(embb_atomic_and_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_
PLATFORM_
INLINE void EMBB_CAT2(embb_atomic_and_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun;\
memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE));\
...
...
base_c/include/embb/base/c/internal/atomic/atomic_variables.h
View file @
650dec9d
...
...
@@ -30,7 +30,7 @@
#include <stddef.h>
#include <embb/base/c/internal/macro_helper.h>
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#include <intrin.h>
#endif
...
...
base_c/include/embb/base/c/internal/atomic/compare_and_swap.h
View file @
650dec9d
...
...
@@ -39,13 +39,13 @@
* See file and_assign.h for a detailed (and operation independent) description
* of the following macro.
*/
#ifdef EMBB_ARCH_X86
#ifdef EMBB_
PLATFORM_
ARCH_X86
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#define EMBB_DEFINE_COMPARE_AND_SWAP(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
extern int __fastcall EMBB_CAT2(embb_internal__atomic_compare_and_swap_, EMBB_PARAMETER_SIZE_BYTE)_asm( \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* expected, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) desired); \
EMBB_INLINE int __fastcall EMBB_CAT2(embb_internal__atomic_compare_and_swap_, EMBB_PARAMETER_SIZE_BYTE)( \
EMBB_
PLATFORM_
INLINE int __fastcall EMBB_CAT2(embb_internal__atomic_compare_and_swap_, EMBB_PARAMETER_SIZE_BYTE)( \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* expected, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) desired) { \
int result; \
_ReadWriteBarrier(); \
...
...
@@ -53,9 +53,9 @@
_ReadWriteBarrier(); \
return result; \
}
#elif defined(EMBB_COMPILER_GNUC)
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_COMPARE_AND_SWAP(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
EMBB_INLINE int EMBB_CAT2(embb_internal__atomic_compare_and_swap_, \
EMBB_
PLATFORM_
INLINE int EMBB_CAT2(embb_internal__atomic_compare_and_swap_, \
EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* expected, \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) desired) { \
char result; \
...
...
@@ -82,12 +82,12 @@ EMBB_DEFINE_COMPARE_AND_SWAP(4, "l")
EMBB_DEFINE_COMPARE_AND_SWAP
(
8
,
"q"
)
#endif
#elif defined(EMBB_ARCH_ARM)
#elif defined(EMBB_
PLATFORM_
ARCH_ARM)
#if defined(EMBB_COMPILER_GNUC)
#if defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_COMPARE_AND_SWAP(EMBB_PARAMETER_SIZE_BYTE, \
EMBB_ATOMIC_ARM_SIZE_SUFFIX) \
EMBB_INLINE \
EMBB_
PLATFORM_
INLINE \
int EMBB_CAT2(embb_internal__atomic_compare_and_swap_, \
EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
...
...
@@ -134,7 +134,7 @@ EMBB_DEFINE_COMPARE_AND_SWAP(4, "")
* of the following macro.
*/
#define EMBB_ATOMIC_INTERNAL_DEFINE_COMPARE_AND_SWAP_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \
EMBB_INLINE int EMBB_CAT2(embb_atomic_compare_and_swap_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_
PLATFORM_
INLINE int EMBB_CAT2(embb_atomic_compare_and_swap_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE* expected, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE desired) {\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) desired_pun;\
memcpy(&desired_pun, &desired, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE));\
...
...
base_c/include/embb/base/c/internal/atomic/fetch_and_add.h
View file @
650dec9d
...
...
@@ -38,13 +38,13 @@
* See file and_assign.h for a detailed (and operation independent) description
* of the following macro.
*/
#ifdef EMBB_ARCH_X86
#ifdef EMBB_
PLATFORM_
ARCH_X86
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#define EMBB_DEFINE_FETCH_AND_ADD(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
extern EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_fetch_and_add_, EMBB_PARAMETER_SIZE_BYTE)_asm( \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value); \
EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_fetch_and_add_, EMBB_PARAMETER_SIZE_BYTE) (\
EMBB_
PLATFORM_
INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_fetch_and_add_, EMBB_PARAMETER_SIZE_BYTE) (\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) {\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) result; \
_ReadWriteBarrier(); \
...
...
@@ -53,9 +53,9 @@
_ReadWriteBarrier(); \
return result; \
}
#elif defined(EMBB_COMPILER_GNUC)
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_FETCH_AND_ADD(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) EMBB_CAT2(embb_internal__atomic_fetch_and_add_, EMBB_PARAMETER_SIZE_BYTE) \
EMBB_
PLATFORM_
INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) EMBB_CAT2(embb_internal__atomic_fetch_and_add_, EMBB_PARAMETER_SIZE_BYTE) \
(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) { \
__asm__ __volatile__ ("lock xadd" EMBB_ATOMIC_X86_SIZE_SUFFIX " %1, %0" \
: "+m" (*pointer_to_value), "+q" (new_value) \
...
...
@@ -78,12 +78,12 @@ EMBB_DEFINE_FETCH_AND_ADD(4, "l")
EMBB_DEFINE_FETCH_AND_ADD
(
8
,
"q"
)
#endif
#elif defined(EMBB_ARCH_ARM)
#elif defined(EMBB_
PLATFORM_
ARCH_ARM)
#if defined(EMBB_COMPILER_GNUC)
#if defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_FETCH_AND_ADD(EMBB_PARAMETER_SIZE_BYTE, \
EMBB_ATOMIC_ARM_SIZE_SUFFIX) \
EMBB_INLINE \
EMBB_
PLATFORM_
INLINE \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
EMBB_CAT2(embb_internal__atomic_fetch_and_add_, \
EMBB_PARAMETER_SIZE_BYTE)(\
...
...
@@ -127,7 +127,7 @@ EMBB_DEFINE_FETCH_AND_ADD(4, "")
* of the following macro.
*/
#define EMBB_ATOMIC_INTERNAL_DEFINE_FETCH_AND_ADD_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \
EMBB_INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_fetch_and_add_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_
PLATFORM_
INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_fetch_and_add_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun; \
memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE)); \
...
...
base_c/include/embb/base/c/internal/atomic/load.h
View file @
650dec9d
...
...
@@ -39,13 +39,13 @@
* See file and_assign.h for a detailed (and operation independent) description
* of the following macro.
*/
#ifdef EMBB_ARCH_X86
#ifdef EMBB_
PLATFORM_
ARCH_X86
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#define EMBB_DEFINE_LOAD(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
extern EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_load_, EMBB_PARAMETER_SIZE_BYTE)_asm( \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value); \
EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_load_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_
PLATFORM_
INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_load_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value) { \
register EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) result; \
_ReadWriteBarrier(); \
...
...
@@ -54,9 +54,9 @@
_ReadWriteBarrier(); \
return result; \
}
#elif defined(EMBB_COMPILER_GNUC)
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_LOAD(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
EMBB_
PLATFORM_
INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
EMBB_CAT2(embb_internal__atomic_load_, EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value) { \
/* no fence required for loads */
\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) result; \
...
...
@@ -81,11 +81,11 @@ EMBB_DEFINE_LOAD(4, "l")
EMBB_DEFINE_LOAD
(
8
,
"q"
)
#endif
#elif defined(EMBB_ARCH_ARM)
#elif defined(EMBB_
PLATFORM_
ARCH_ARM)
#if defined(EMBB_COMPILER_GNUC)
#if defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_LOAD(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_ARM_SIZE_SUFFIX) \
EMBB_INLINE \
EMBB_
PLATFORM_
INLINE \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
EMBB_CAT2(embb_internal__atomic_load_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
...
...
@@ -118,7 +118,7 @@ EMBB_DEFINE_LOAD(4, "")
* of the following macro.
*/
#define EMBB_ATOMIC_INTERNAL_DEFINE_LOAD_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \
EMBB_INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_load_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_
PLATFORM_
INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_load_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
const EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable) { \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \
return_val = (EMBB_CAT2(embb_internal__atomic_load_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE)(\
...
...
base_c/include/embb/base/c/internal/atomic/memory_barrier.h
View file @
650dec9d
...
...
@@ -31,32 +31,32 @@
#ifndef DOXYGEN
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#include <intrin.h>
#endif
#ifdef EMBB_ARCH_X86
#ifdef EMBB_
PLATFORM_
ARCH_X86
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
extern
void
__fastcall
embb_internal__atomic_memory_barrier_asm
();
// Read/write barrier
EMBB_INLINE
void
__fastcall
embb_atomic_memory_barrier
()
{
EMBB_
PLATFORM_
INLINE
void
__fastcall
embb_atomic_memory_barrier
()
{
_ReadWriteBarrier
();
embb_internal__atomic_memory_barrier_asm
();
_ReadWriteBarrier
();
}
#elif defined(EMBB_COMPILER_GNUC)
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
// Read/write barrier
EMBB_INLINE
void
embb_atomic_memory_barrier
()
{
EMBB_
PLATFORM_
INLINE
void
embb_atomic_memory_barrier
()
{
__asm__
__volatile__
(
"mfence"
:
:
:
"memory"
);
}
#else
#error "No atomic fetch and store implementation found"
#endif
#elif defined(EMBB_ARCH_ARM)
#elif defined(EMBB_
PLATFORM_
ARCH_ARM)
EMBB_INLINE
void
embb_atomic_memory_barrier
()
{
EMBB_
PLATFORM_
INLINE
void
embb_atomic_memory_barrier
()
{
__asm__
__volatile__
(
"dmb"
:
:
:
"memory"
);
}
...
...
base_c/include/embb/base/c/internal/atomic/or_assign.h
View file @
650dec9d
...
...
@@ -39,22 +39,22 @@
* See file and_assign.h for a detailed (and operation independent) description
* of the following macro.
*/
#ifdef EMBB_ARCH_X86
#ifdef EMBB_
PLATFORM_
ARCH_X86
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#define EMBB_DEFINE_OR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
extern void __fastcall EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)_asm(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value); \
EMBB_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_
PLATFORM_
INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \
_ReadWriteBarrier(); \
EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)_asm(pointer_to_value, value); \
_ReadWriteBarrier(); \
}
#elif defined(EMBB_COMPILER_GNUC)
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_OR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
EMBB_INLINE void EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_
PLATFORM_
INLINE void EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \
__asm__ __volatile__("lock or" EMBB_ATOMIC_X86_SIZE_SUFFIX " %1, %0" \
: "+m" (*pointer_to_value), "+q" (value) \
...
...
@@ -77,12 +77,12 @@ EMBB_DEFINE_OR_ASSIGN(4, "l")
EMBB_DEFINE_OR_ASSIGN
(
8
,
"q"
)
#endif
#elif defined(EMBB_ARCH_ARM)
#elif defined(EMBB_
PLATFORM_
ARCH_ARM)
#if defined(EMBB_COMPILER_GNUC)
#if defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_OR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, \
EMBB_ATOMIC_ARM_SIZE_SUFFIX) \
EMBB_INLINE \
EMBB_
PLATFORM_
INLINE \
void EMBB_CAT2(embb_internal__atomic_or_assign_, \
EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
...
...
@@ -120,7 +120,7 @@ EMBB_DEFINE_OR_ASSIGN(4, "")
* of the following macro.
*/
#define EMBB_ATOMIC_INTERNAL_DEFINE_OR_ASSIGN_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \
EMBB_INLINE void EMBB_CAT2(embb_atomic_or_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \
EMBB_
PLATFORM_
INLINE void EMBB_CAT2(embb_atomic_or_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun;\
memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE));\
EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE)((EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) volatile *)\
...
...
base_c/include/embb/base/c/internal/atomic/store.h
View file @
650dec9d
...
...
@@ -39,13 +39,13 @@
* See file and_assign.h for a detailed (and operation independent) description
* of the following macro.
*/
#ifdef EMBB_ARCH_X86
#ifdef EMBB_
PLATFORM_
ARCH_X86
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#define EMBB_DEFINE_STORE(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX)\
extern void __fastcall EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)_asm( \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value); \
EMBB_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_
PLATFORM_
INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) \
{ \
_ReadWriteBarrier(); \
...
...
@@ -53,9 +53,9 @@
EMBB_PARAMETER_SIZE_BYTE)_asm(pointer_to_value, new_value); \
_ReadWriteBarrier(); \
}
#elif defined(EMBB_COMPILER_GNUC)
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_STORE(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX)\
EMBB_INLINE void EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \
EMBB_
PLATFORM_
INLINE void EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) {\
/*the lock prefix is implicit for xchg*/
\
__asm__ __volatile__("xchg" EMBB_ATOMIC_X86_SIZE_SUFFIX " %1, %0" \
...
...
@@ -78,11 +78,11 @@ EMBB_DEFINE_STORE(4, "l")
EMBB_DEFINE_STORE
(
8
,
"q"
)
#endif
#elif defined(EMBB_ARCH_ARM)
#elif defined(EMBB_
PLATFORM_
ARCH_ARM)
#if defined(EMBB_COMPILER_GNUC)
#if defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_STORE(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_ARM_SIZE_SUFFIX)\
EMBB_INLINE \
EMBB_
PLATFORM_
INLINE \
void EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* \
pointer_to_value, \
...
...
@@ -115,7 +115,7 @@ EMBB_DEFINE_STORE(4, "")
* of the following macro.
*/
#define EMBB_ATOMIC_INTERNAL_DEFINE_STORE_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \
EMBB_INLINE void EMBB_CAT2(embb_atomic_store_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \
EMBB_
PLATFORM_
INLINE void EMBB_CAT2(embb_atomic_store_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun; \
memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE)); \
EMBB_CAT2(embb_internal__atomic_store_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE)((EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) volatile *)\
...
...
base_c/include/embb/base/c/internal/atomic/swap.h
View file @
650dec9d
...
...
@@ -39,13 +39,13 @@
* See file and_assign.h for a detailed (and operation independent) description
* of the following macro.
*/
#ifdef EMBB_ARCH_X86
#ifdef EMBB_
PLATFORM_
ARCH_X86
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#define EMBB_DEFINE_SWAP(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
extern EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2 (embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)_asm(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value); \
EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2 (embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_
PLATFORM_
INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2 (embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) { \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) result; \
_ReadWriteBarrier(); \
...
...
@@ -53,9 +53,9 @@
_ReadWriteBarrier(); \
return result; \
}
#elif defined(EMBB_COMPILER_GNUC)
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_SWAP(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) EMBB_CAT2(embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_
PLATFORM_
INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) EMBB_CAT2(embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value)\
{ \
/*the lock prefix is implicit for xchg*/
\
...
...
@@ -80,11 +80,11 @@ EMBB_DEFINE_SWAP(4, "l")
EMBB_DEFINE_SWAP
(
8
,
"q"
)
#endif
#elif defined(EMBB_ARCH_ARM)
#elif defined(EMBB_
PLATFORM_
ARCH_ARM)
#if defined(EMBB_COMPILER_GNUC)
#if defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_SWAP(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_ARM_SIZE_SUFFIX) \
EMBB_INLINE \
EMBB_
PLATFORM_
INLINE \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) EMBB_CAT2 \
(embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
...
...
@@ -123,7 +123,7 @@ EMBB_DEFINE_SWAP(4, "")
* of the following macro.
*/
#define EMBB_ATOMIC_INTERNAL_DEFINE_SWAP_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \
EMBB_INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_swap_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_
PLATFORM_
INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_swap_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun; \
memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE)); \
...
...
base_c/include/embb/base/c/internal/atomic/xor_assign.h
View file @
650dec9d
...
...
@@ -39,22 +39,22 @@
* See file and_assign.h for a detailed (and operation independent) description
* of the following macro.
*/
#ifdef EMBB_ARCH_X86
#ifdef EMBB_
PLATFORM_
ARCH_X86
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#define EMBB_DEFINE_XOR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
extern void __fastcall EMBB_CAT2(embb_internal__atomic_xor_assign_, EMBB_PARAMETER_SIZE_BYTE)_asm(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value); \
EMBB_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_xor_assign_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_
PLATFORM_
INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_xor_assign_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \
_ReadWriteBarrier(); \
EMBB_CAT2(embb_internal__atomic_xor_assign_, \
EMBB_PARAMETER_SIZE_BYTE)_asm(pointer_to_value, value); \
_ReadWriteBarrier(); \
}
#elif defined(EMBB_COMPILER_GNUC)
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_XOR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \
EMBB_INLINE void EMBB_CAT2(embb_internal__atomic_xor_assign_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_
PLATFORM_
INLINE void EMBB_CAT2(embb_internal__atomic_xor_assign_, EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \
__asm__ __volatile__("lock xor" EMBB_ATOMIC_X86_SIZE_SUFFIX " %1, %0" \
...
...
@@ -78,12 +78,12 @@ EMBB_DEFINE_XOR_ASSIGN(4, "l")
EMBB_DEFINE_XOR_ASSIGN
(
8
,
"q"
)
#endif
#elif defined(EMBB_ARCH_ARM)
#elif defined(EMBB_
PLATFORM_
ARCH_ARM)
#if defined(EMBB_COMPILER_GNUC)
#if defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_DEFINE_XOR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, \
EMBB_ATOMIC_ARM_SIZE_SUFFIX) \
EMBB_INLINE \
EMBB_
PLATFORM_
INLINE \
void EMBB_CAT2(embb_internal__atomic_xor_assign_, \
EMBB_PARAMETER_SIZE_BYTE)(\
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
...
...
@@ -121,7 +121,7 @@ EMBB_DEFINE_XOR_ASSIGN(4, "")
* of the following macro.
*/
#define EMBB_ATOMIC_INTERNAL_DEFINE_XOR_ASSIGN_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \
EMBB_INLINE void EMBB_CAT2(embb_atomic_xor_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_
PLATFORM_
INLINE void EMBB_CAT2(embb_atomic_xor_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\
EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun;\
memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE));\
...
...
base_c/include/embb/base/c/internal/bitset.h
View file @
650dec9d
...
...
@@ -33,7 +33,7 @@
#include <embb/base/c/internal/config.h>
EMBB_INLINE
void
embb_bitset_set
(
EMBB_
PLATFORM_
INLINE
void
embb_bitset_set
(
uint64_t
*
that
,
unsigned
int
bit
)
{
...
...
@@ -42,7 +42,7 @@ EMBB_INLINE void embb_bitset_set(
*
that
|=
(
1ull
<<
bit
);
}
EMBB_INLINE
void
embb_bitset_set_n
(
EMBB_
PLATFORM_
INLINE
void
embb_bitset_set_n
(
uint64_t
*
that
,
unsigned
int
count
)
{
assert
(
NULL
!=
that
);
...
...
@@ -55,7 +55,7 @@ EMBB_INLINE void embb_bitset_set_n(
}
}
EMBB_INLINE
void
embb_bitset_clear
(
EMBB_
PLATFORM_
INLINE
void
embb_bitset_clear
(
uint64_t
*
that
,
unsigned
int
bit
)
{
...
...
@@ -64,21 +64,21 @@ EMBB_INLINE void embb_bitset_clear(
*
that
&=
~
(
1ull
<<
bit
);
}
EMBB_INLINE
void
embb_bitset_clear_all
(
EMBB_
PLATFORM_
INLINE
void
embb_bitset_clear_all
(
uint64_t
*
that
)
{
assert
(
NULL
!=
that
);
*
that
=
0ull
;
}
EMBB_INLINE
unsigned
int
embb_bitset_is_set
(
EMBB_
PLATFORM_
INLINE
unsigned
int
embb_bitset_is_set
(
uint64_t
const
*
that
,
unsigned
int
bit
)
{
return
(
unsigned
int
)((
*
that
&
(
1ull
<<
bit
))
?
1
:
0
);
}
EMBB_INLINE
void
embb_bitset_intersect
(
EMBB_
PLATFORM_
INLINE
void
embb_bitset_intersect
(
uint64_t
*
that
,
uint64_t
mask
)
{
...
...
@@ -86,7 +86,7 @@ EMBB_INLINE void embb_bitset_intersect(
*
that
&=
mask
;
}
EMBB_INLINE
void
embb_bitset_union
(
EMBB_
PLATFORM_
INLINE
void
embb_bitset_union
(
uint64_t
*
that
,
uint64_t
mask
)
{
...
...
@@ -94,7 +94,7 @@ EMBB_INLINE void embb_bitset_union(
*
that
|=
mask
;
}
EMBB_INLINE
unsigned
int
embb_bitset_count
(
EMBB_
PLATFORM_
INLINE
unsigned
int
embb_bitset_count
(
uint64_t
const
*
that
)
{
unsigned
int
count
=
0
;
...
...
base_c/include/embb/base/c/internal/cmake_config.h.in
View file @
650dec9d
...
...
@@ -36,21 +36,21 @@
/**
* Is used to get the number of cores on certain systems.
*/
#cmakedefine EMBB_HAS_HEADER_SYSINFO
#cmakedefine EMBB_
PLATFORM_
HAS_HEADER_SYSINFO
/**
* Is used to get the number of cores on certain systems.
*/
#cmakedefine EMBB_HAS_HEADER_SYSCTL
#cmakedefine EMBB_
PLATFORM_
HAS_HEADER_SYSCTL
/**
* Is used to set thread affinities on certain systems.
*/
#cmakedefine EMBB_HAS_HEADER_CPUSET
#cmakedefine EMBB_
PLATFORM_
HAS_HEADER_CPUSET
/**
* Is used for Linux thread affinities.
*/
#cmakedefine EMBB_HAS_GLIB_CPU
#cmakedefine EMBB_
PLATFORM_
HAS_GLIB_CPU
#endif /* EMBB_BASE_INTERNAL_CMAKE_CONFIG_H_ */
\ No newline at end of file
base_c/include/embb/base/c/internal/config.h
View file @
650dec9d
...
...
@@ -45,9 +45,9 @@
* which has 128 bytes.
*/
#if defined(_M_IA64) || defined(_IA64)
#define EMBB_CACHE_LINE_SIZE 128
#define EMBB_
PLATFORM_
CACHE_LINE_SIZE 128
#else
#define EMBB_CACHE_LINE_SIZE 64
#define EMBB_
PLATFORM_
CACHE_LINE_SIZE 64
#endif
/* For MSVC, if _DEBUG is set, set also EMBB_DEBUG.
...
...
@@ -59,41 +59,41 @@
#endif
#ifdef __GNUC__
#define EMBB_ALIGN(size) __attribute__ ((aligned(size)))
#define EMBB_
PLATFORM_
ALIGN(size) __attribute__ ((aligned(size)))
#elif defined _MSC_VER || defined __INTEL_COMPILER
#define EMBB_ALIGN(size) __declspec(align(size))
#define EMBB_
PLATFORM_
ALIGN(size) __declspec(align(size))
#else
#error "Unsupported compiler"
#endif
#if __GNUC__
#define EMBB_INLINE static inline
#define EMBB_COMPILER_GNUC
#define EMBB_
PLATFORM_
INLINE static inline
#define EMBB_
PLATFORM_
COMPILER_GNUC
#elif _MSC_VER
#define EMBB_INLINE __inline
#define EMBB_COMPILER_MSVC
#define EMBB_
PLATFORM_
INLINE __inline
#define EMBB_
PLATFORM_
COMPILER_MSVC
#else
#define EMBB_INLINE inline
#define EMBB_COMPILER_UNKNOWN
#define EMBB_
PLATFORM_
INLINE inline
#define EMBB_
PLATFORM_
COMPILER_UNKNOWN
#endif
#if defined(__x86_64__) || defined(_M_X64)
#define EMBB_ARCH_X86_64
#define EMBB_ARCH_X86
#define EMBB_HAS_CAS_64
#define EMBB_
PLATFORM_
ARCH_X86_64
#define EMBB_
PLATFORM_
ARCH_X86
#define EMBB_
PLATFORM_
HAS_CAS_64
#elif defined(__i386) || defined(_M_IX86)
#define EMBB_ARCH_X86_32
#define EMBB_ARCH_X86
#define EMBB_
PLATFORM_
ARCH_X86_32
#define EMBB_
PLATFORM_
ARCH_X86
#elif defined(__arm__)
#define EMBB_ARCH_ARM
#define EMBB_
PLATFORM_
ARCH_ARM
#else
#define EMBB_ARCH_UNKNOWN
#define EMBB_
PLATFORM_
ARCH_UNKNOWN
#endif
#if defined(EMBB_COMPILER_MSVC)
#define EMBB_THREADING_WINTHREADS
#elif defined(EMBB_COMPILER_GNUC)
#define EMBB_THREADING_POSIXTHREADS
#if defined(EMBB_
PLATFORM_
COMPILER_MSVC)
#define EMBB_
PLATFORM_
THREADING_WINTHREADS
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
#define EMBB_
PLATFORM_
THREADING_POSIXTHREADS
#else
#error "No thread implementation could be determined"
#endif
...
...
base_c/include/embb/base/c/internal/platform.h
View file @
650dec9d
...
...
@@ -37,9 +37,9 @@ extern "C" {
#define EMBB_TIME_MAX_SECONDS ULLONG_MAX
#define EMBB_DURATION_MAX_SECONDS 60 * 60 * 24 * 7
#ifdef EMBB_THREADING_WINTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_WINTHREADS
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
// Suppress virtual functions but non-virtual constructor warning
// in windows headers
#pragma warning(push)
...
...
@@ -49,7 +49,7 @@ extern "C" {
#define NOMINMAX
#include <windows.h>
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#pragma warning(pop) // Reset warning 4640
#endif
...
...
@@ -71,7 +71,7 @@ typedef CONDITION_VARIABLE embb_condition_t;
#define EMBB_THREAD_SPECIFIC static __declspec(thread)
#elif defined EMBB_
THREADING_POSIXTHREADS
/* EMBB
_THREADING_WINTHREADS */
#elif defined EMBB_
PLATFORM_THREADING_POSIXTHREADS
/* EMBB_PLATFORM
_THREADING_WINTHREADS */
#include <pthread.h>
#include <errno.h>
...
...
@@ -95,7 +95,7 @@ typedef pthread_cond_t embb_condition_t;
#define EMBB_THREAD_SPECIFIC __thread
#else
/* EMBB_THREADING_POSIXTHREADS */
#else
/* EMBB_
PLATFORM_
THREADING_POSIXTHREADS */
#error "No threading platform defined!"
...
...
base_c/src/condition_variable.c
View file @
650dec9d
...
...
@@ -43,7 +43,7 @@ int embb_condition_wait_for(embb_condition_t* condition_var,
return
embb_condition_wait_until
(
condition_var
,
mutex
,
&
time
);
}
#ifdef EMBB_THREADING_WINTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_WINTHREADS
int
embb_condition_init
(
embb_condition_t
*
condition_var
)
{
assert
(
condition_var
!=
NULL
);
...
...
@@ -108,9 +108,9 @@ int embb_condition_destroy(embb_condition_t* condition_var) {
return
EMBB_SUCCESS
;
}
#endif
/* EMBB_THREADING_WINTHREADS */
#endif
/* EMBB_
PLATFORM_
THREADING_WINTHREADS */
#ifdef EMBB_THREADING_POSIXTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_POSIXTHREADS
int
embb_condition_init
(
embb_condition_t
*
condition_var
)
{
assert
(
condition_var
!=
NULL
);
...
...
@@ -165,4 +165,4 @@ int embb_condition_destroy(embb_condition_t* condition_var) {
return
EMBB_SUCCESS
;
}
#endif
/* EMBB_THREADING_POSIXTHREADS */
#endif
/* EMBB_
PLATFORM_
THREADING_POSIXTHREADS */
base_c/src/core_set.c
View file @
650dec9d
...
...
@@ -31,7 +31,7 @@
#include <limits.h>
#include <assert.h>
#ifdef EMBB_THREADING_WINTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_WINTHREADS
/**
* For handling of more than 64 logical processors on Windows.
...
...
@@ -87,21 +87,21 @@ void embb_core_set_init(embb_core_set_t* core_set, int initializer) {
}
}
#endif
/* EMBB_THREADING_WINTHREADS */
#endif
/* EMBB_
PLATFORM_
THREADING_WINTHREADS */
#ifdef EMBB_THREADING_POSIXTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_POSIXTHREADS
#ifdef EMBB_HAS_HEADER_SYSINFO
#ifdef EMBB_
PLATFORM_
HAS_HEADER_SYSINFO
#include <sys/sysinfo.h>
#elif defined EMBB_HAS_HEADER_SYSCTL
#elif defined EMBB_
PLATFORM_
HAS_HEADER_SYSCTL
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
unsigned
int
embb_core_count_available
()
{
#ifdef EMBB_HAS_HEADER_SYSINFO
#ifdef EMBB_
PLATFORM_
HAS_HEADER_SYSINFO
return
get_nprocs
();
#elif defined EMBB_HAS_HEADER_SYSCTL
#elif defined EMBB_
PLATFORM_
HAS_HEADER_SYSCTL
const
size_t
kBufferSize
=
sizeof
(
unsigned
int
);
char
buf
[
kBufferSize
];
size_t
len
=
kBufferSize
;
...
...
@@ -123,7 +123,7 @@ void embb_core_set_init(embb_core_set_t* core_set, int initializer) {
}
}
#endif
/* EMBB_THREADING_POSIXTHREADS */
#endif
/* EMBB_
PLATFORM_
THREADING_POSIXTHREADS */
void
embb_core_set_add
(
embb_core_set_t
*
core_set
,
unsigned
int
core_number
)
{
assert
(
core_set
!=
NULL
);
...
...
base_c/src/log.c
View file @
650dec9d
...
...
@@ -91,14 +91,14 @@ static void embb_log_write_internal(
log_level_str
=
" "
;
break
;
}
#if defined(EMBB_COMPILER_MSVC)
#if defined(EMBB_
PLATFORM_
COMPILER_MSVC)
char
msg_buffer
[
400
];
char
buffer
[
500
];
vsprintf_s
(
msg_buffer
,
sizeof
(
msg_buffer
),
message
,
argp
);
sprintf_s
(
buffer
,
sizeof
(
buffer
),
"[%s] - [%s] %s"
,
channel_str
,
log_level_str
,
msg_buffer
);
embb_log_global_log_function
(
log_context
,
buffer
);
#elif defined(EMBB_COMPILER_GNUC)
#elif defined(EMBB_
PLATFORM_
COMPILER_GNUC)
char
msg_buffer
[
400
];
char
buffer
[
500
];
vsnprintf
(
msg_buffer
,
sizeof
(
msg_buffer
),
message
,
argp
);
...
...
base_c/src/memory_allocation.c
View file @
650dec9d
...
...
@@ -166,7 +166,7 @@ void embb_free(void * ptr) {
void
*
embb_alloc_aligned
(
size_t
alignment
,
size_t
size
)
{
void
*
malloc_addr
=
NULL
;
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
/*
* From the Documentation:
* Allocates memory on a specified alignment boundary.
...
...
@@ -176,7 +176,7 @@ void *embb_alloc_aligned(size_t alignment, size_t size) {
* failed. The pointer is a multiple of alignment.
*/
malloc_addr
=
_aligned_malloc
(
size
,
alignment
);
#elif defined EMBB_COMPILER_GNUC
#elif defined EMBB_
PLATFORM_
COMPILER_GNUC
/*
* From the Documentation:
* The posix_memalign() function shall allocate size bytes aligned on a
...
...
@@ -193,10 +193,10 @@ void *embb_alloc_aligned(size_t alignment, size_t size) {
}
void
embb_free_aligned
(
void
*
ptr
)
{
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
_aligned_free
(
ptr
);
#else
#ifdef EMBB_COMPILER_GNUC
#ifdef EMBB_
PLATFORM_
COMPILER_GNUC
free
(
ptr
);
#else
#error Unsupported compiler
...
...
@@ -211,5 +211,5 @@ size_t embb_get_bytes_allocated() {
#endif
void
*
embb_alloc_cache_aligned
(
size_t
size
)
{
return
embb_alloc_aligned
(
EMBB_CACHE_LINE_SIZE
,
size
);
return
embb_alloc_aligned
(
EMBB_
PLATFORM_
CACHE_LINE_SIZE
,
size
);
}
base_c/src/mutex.c
View file @
650dec9d
...
...
@@ -29,7 +29,7 @@
#include <embb/base/c/internal/unused.h>
#ifdef EMBB_THREADING_WINTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_WINTHREADS
int
embb_mutex_init
(
embb_mutex_t
*
mutex
,
int
type
)
{
/* Critical sections in Windows are always recursive */
...
...
@@ -59,9 +59,9 @@ void embb_mutex_destroy(embb_mutex_t* mutex) {
DeleteCriticalSection
(
mutex
);
}
#endif
/* EMBB_THREADING_WINTHREADS */
#endif
/* EMBB_
PLATFORM_
THREADING_WINTHREADS */
#ifdef EMBB_THREADING_POSIXTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_POSIXTHREADS
int
embb_mutex_init
(
embb_mutex_t
*
mutex
,
int
type
)
{
if
(
type
==
EMBB_MUTEX_PLAIN
)
{
...
...
@@ -114,4 +114,4 @@ void embb_mutex_destroy(embb_mutex_t* mutex) {
pthread_mutex_destroy
(
mutex
);
}
#endif
/* EMBB_THREADING_POSIXTHREADS */
#endif
/* EMBB_
PLATFORM_
THREADING_POSIXTHREADS */
base_c/src/thread.c
View file @
650dec9d
...
...
@@ -40,7 +40,7 @@ void embb_thread_set_max_count(unsigned int max) {
embb_internal_thread_index_set_max
(
max
);
}
#ifdef EMBB_THREADING_WINTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_WINTHREADS
/**
* Used to wrap client thread start function and argument when calling internal
...
...
@@ -151,21 +151,21 @@ int embb_thread_equal(const embb_thread_t* lhs, const embb_thread_t* rhs) {
return
0
;
}
#endif
/* EMBB_THREADING_WINTHREADS */
#endif
/* EMBB_
PLATFORM_
THREADING_WINTHREADS */
#ifdef EMBB_THREADING_POSIXTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_POSIXTHREADS
#ifdef EMBB_HAS_GLIB_CPU
#ifdef EMBB_
PLATFORM_
HAS_GLIB_CPU
#include <sched.h>
#elif defined EMBB_HAS_HEADER_CPUSET
#elif defined EMBB_
PLATFORM_
HAS_HEADER_CPUSET
#include <pthread_np.h>
#include <sys/param.h>
#include <sys/cpuset.h>
#endif
#ifdef EMBB_HAS_HEADER_SYSINFO
#ifdef EMBB_
PLATFORM_
HAS_HEADER_SYSINFO
#include <sys/sysinfo.h>
/* Used to get number of processors */
#endif
/* EMBB_HAS_HEADER_SYSINFO */
#endif
/* EMBB_
PLATFORM_
HAS_HEADER_SYSINFO */
/**
* Used to wrap client thread start function and argument when calling internal
...
...
@@ -207,10 +207,10 @@ int embb_thread_create(embb_thread_t* thread, const embb_core_set_t* core_set,
int
status
=
pthread_attr_init
(
&
attr
);
if
(
status
!=
0
)
return
EMBB_ERROR
;
if
(
core_set
!=
NULL
)
{
#if defined(EMBB_
HAS_GLIB_CPU) || defined(EMBB
_HAS_HEADER_CPUSET)
#if defined(EMBB_
PLATFORM_HAS_GLIB_CPU) || defined(EMBB_PLATFORM
_HAS_HEADER_CPUSET)
assert
(
embb_core_count_available
()
<
CPU_SETSIZE
&&
"Core sets are only supported up to CPU_SETSIZE processors!"
);
#ifdef EMBB_HAS_GLIB_CPU
#ifdef EMBB_
PLATFORM_
HAS_GLIB_CPU
cpu_set_t
cpuset
;
#else
cpuset_t
cpuset
;
...
...
@@ -265,4 +265,4 @@ int embb_thread_equal(const embb_thread_t* lhs, const embb_thread_t* rhs) {
return
pthread_equal
(
lhs
->
embb_internal_handle
,
rhs
->
embb_internal_handle
);
}
#endif
/* EMBB_THREADING_POSIXTHREADS */
#endif
/* EMBB_
PLATFORM_
THREADING_POSIXTHREADS */
base_c/src/time.c
View file @
650dec9d
...
...
@@ -53,7 +53,7 @@ int embb_time_compare(const embb_time_t* lhs, const embb_time_t* rhs) {
}
#ifdef EMBB_THREADING_WINTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_WINTHREADS
int
embb_time_in
(
embb_time_t
*
time
,
const
embb_duration_t
*
duration
)
{
assert
(
time
!=
NULL
);
...
...
@@ -81,10 +81,10 @@ int embb_time_in(embb_time_t* time, const embb_duration_t* duration) {
return
EMBB_SUCCESS
;
}
#endif
/* EMBB_THREADING_WINTHREADS */
#endif
/* EMBB_
PLATFORM_
THREADING_WINTHREADS */
#ifdef EMBB_THREADING_POSIXTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_POSIXTHREADS
int
embb_time_in
(
embb_time_t
*
time
,
const
embb_duration_t
*
duration
)
{
assert
(
time
!=
NULL
);
...
...
@@ -102,5 +102,5 @@ int embb_time_in(embb_time_t* time, const embb_duration_t* duration) {
return
EMBB_SUCCESS
;
}
#endif
/* EMBB_THREADING_POSIXTHREADS */
#endif
/* EMBB_
PLATFORM_
THREADING_POSIXTHREADS */
base_c/test/alloc_test.cc
View file @
650dec9d
...
...
@@ -174,7 +174,7 @@ void AllocTest::TestMixedAllocs() {
PT_EXPECT_NE
(
cache_aligned
,
static_cast
<
void
*>
(
NULL
));
allocated
=
embb_get_bytes_allocated
();
#ifdef EMBB_DEBUG
expected
+=
(
1
+
1
)
*
EMBB_CACHE_LINE_SIZE
+
3
*
sizeof
(
size_t
)
-
1
;
expected
+=
(
1
+
1
)
*
EMBB_
PLATFORM_
CACHE_LINE_SIZE
+
3
*
sizeof
(
size_t
)
-
1
;
#endif // else EMBB_DEBUG
PT_EXPECT_EQ
(
allocated
,
expected
);
...
...
base_cpp/include/embb/base/atomic.h
View file @
650dec9d
...
...
@@ -531,7 +531,7 @@ __EMBB_ATOMIC_INTEGER_SPECIALIZATION(unsigned short);
__EMBB_ATOMIC_INTEGER_SPECIALIZATION
(
signed
int
);
__EMBB_ATOMIC_INTEGER_SPECIALIZATION
(
unsigned
int
);
#ifdef EMBB_ARCH_X86_64
#ifdef EMBB_
PLATFORM_
ARCH_X86_64
__EMBB_ATOMIC_INTEGER_SPECIALIZATION
(
size_t
);
#endif
...
...
base_cpp/include/embb/base/exceptions.h
View file @
650dec9d
...
...
@@ -27,16 +27,16 @@
#ifndef EMBB_BASE_EXCEPTIONS_H_
#define EMBB_BASE_EXCEPTIONS_H_
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#pragma warning(push)
// Disable warning that exceptions are disabled but try/catch is used.
#pragma warning(disable : 4530)
#endif // EMBB_COMPILER_MSVC
#endif // EMBB_
PLATFORM_
COMPILER_MSVC
#include <string>
#include <exception>
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#pragma warning(pop)
#endif
...
...
base_cpp/include/embb/base/internal/config.h
View file @
650dec9d
...
...
@@ -31,7 +31,7 @@
#include <embb/base/c/internal/config.h>
/* Disable exceptions in STL of MSVC. Leads to errors when used like this!!! */
/*#if defined(EMBB_COMPILER_MSVC) && !defined(EMBB_USE_EXCEPTIONS)
/*#if defined(EMBB_
PLATFORM_
COMPILER_MSVC) && !defined(EMBB_USE_EXCEPTIONS)
#define _HAS_EXCEPTIONS 0
#endif*/
...
...
base_cpp/include/embb/base/internal/duration-inl.h
View file @
650dec9d
...
...
@@ -38,7 +38,7 @@ const Duration<Tick>& Duration<Tick>::Zero() {
return
zero
;
}
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
// Suppress non-thread-safe static initialization warning
// in Max() and Min()
#pragma warning(push)
...
...
@@ -57,7 +57,7 @@ const Duration<Tick>& Duration<Tick>::Min() {
return
minimum
;
}
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#pragma warning(pop) // Reset warning 4640
#endif
...
...
base_cpp/include/embb/base/internal/platform.h
View file @
650dec9d
...
...
@@ -34,7 +34,7 @@
#include <embb/base/internal/config.h>
#include <embb/base/c/internal/platform.h>
#ifdef EMBB_THREADING_WINTHREADS
#ifdef EMBB_
PLATFORM_
THREADING_WINTHREADS
namespace
embb
{
namespace
base
{
...
...
@@ -49,7 +49,7 @@ typedef embb_condition_t ConditionVariableType;
}
// namespace base
}
// namespace embb
#elif defined EMBB_
THREADING_POSIXTHREADS // EMBB
_THREADING_WINTHREADS
#elif defined EMBB_
PLATFORM_THREADING_POSIXTHREADS // EMBB_PLATFORM
_THREADING_WINTHREADS
namespace
embb
{
namespace
base
{
...
...
@@ -64,7 +64,7 @@ typedef embb_condition_t ConditionVariableType;
}
// namespace base
}
// namespace embb
#else // EMBB_THREADING_POSIXTHREADS
#else // EMBB_
PLATFORM_
THREADING_POSIXTHREADS
#error "No threading platform defined!"
...
...
base_cpp/src/thread.cc
View file @
650dec9d
...
...
@@ -41,7 +41,7 @@ void Thread::SetThreadsMaxCount(unsigned int max_count) {
}
Thread
::
ID
Thread
::
CurrentGetID
()
{
#if defined EMBB_THREADING_WINTHREADS
#if defined EMBB_
PLATFORM_
THREADING_WINTHREADS
return
Thread
::
ID
(
GetCurrentThreadId
());
#else
return
Thread
::
ID
(
embb_thread_current
().
embb_internal_handle
);
...
...
@@ -59,15 +59,15 @@ void Thread::Join() {
}
Thread
::
ID
Thread
::
GetID
()
{
#if defined EMBB_THREADING_WINTHREADS
#if defined EMBB_
PLATFORM_
THREADING_WINTHREADS
return
Thread
::
ID
(
GetCurrentThreadId
());
#elif defined EMBB_THREADING_POSIXTHREADS
#elif defined EMBB_
PLATFORM_
THREADING_POSIXTHREADS
return
Thread
::
ID
(
rep_
.
embb_internal_handle
);
#endif
}
bool
operator
==
(
Thread
::
ID
lhs
,
Thread
::
ID
rhs
)
{
#if defined EMBB_THREADING_WINTHREADS
#if defined EMBB_
PLATFORM_
THREADING_WINTHREADS
return
lhs
.
id_
==
rhs
.
id_
;
#else
return
pthread_equal
(
lhs
.
id_
,
rhs
.
id_
)
!=
0
;
...
...
@@ -75,7 +75,7 @@ bool operator==(Thread::ID lhs, Thread::ID rhs) {
}
bool
operator
!=
(
Thread
::
ID
lhs
,
Thread
::
ID
rhs
)
{
#if defined EMBB_THREADING_WINTHREADS
#if defined EMBB_
PLATFORM_
THREADING_WINTHREADS
return
lhs
.
id_
!=
rhs
.
id_
;
#else
return
pthread_equal
(
lhs
.
id_
,
rhs
.
id_
)
==
0
;
...
...
base_cpp/test/memory_allocation_test.cc
View file @
650dec9d
...
...
@@ -84,12 +84,12 @@ void MemoryAllocationTest::ClassAllocationTest() {
aligned_allocs
[
i
]
->
b
=
0xF000
|
i
;
#ifdef EMBB_DEBUG
size_t
n
=
(
sizeof
(
DummyClassForAlignedAllocation
)
+
(
EMBB_
CACHE_LINE_SIZE
-
1
))
/
EMBB
_CACHE_LINE_SIZE
;
expected
+=
(
n
+
1
)
*
EMBB_CACHE_LINE_SIZE
+
(
sizeof
(
size_t
)
*
3
-
1
);
+
(
EMBB_
PLATFORM_CACHE_LINE_SIZE
-
1
))
/
EMBB_PLATFORM
_CACHE_LINE_SIZE
;
expected
+=
(
n
+
1
)
*
EMBB_
PLATFORM_
CACHE_LINE_SIZE
+
(
sizeof
(
size_t
)
*
3
-
1
);
#endif // else EMBB_DEBUG
//check that the memory is aligned!
PT_ASSERT_EQ
((
uintptr_t
)
aligned_allocs
[
i
]
%
EMBB_CACHE_LINE_SIZE
,
PT_ASSERT_EQ
((
uintptr_t
)
aligned_allocs
[
i
]
%
EMBB_
PLATFORM_
CACHE_LINE_SIZE
,
(
uintptr_t
)
0
);
}
...
...
@@ -135,15 +135,15 @@ void MemoryAllocationTest::ClassAllocationTest() {
new
DummyClassForAlignedAllocation
[
alloc_iterations
];
#ifdef EMBB_DEBUG
size_t
n
=
(
sizeof
(
DummyClassForAlignedAllocation
)
*
alloc_iterations
+
(
EMBB_
CACHE_LINE_SIZE
-
1
))
/
EMBB
_CACHE_LINE_SIZE
;
expected
+=
(
n
+
1
)
*
EMBB_CACHE_LINE_SIZE
+
(
sizeof
(
size_t
)
*
3
-
1
);
+
(
EMBB_
PLATFORM_CACHE_LINE_SIZE
-
1
))
/
EMBB_PLATFORM
_CACHE_LINE_SIZE
;
expected
+=
(
n
+
1
)
*
EMBB_
PLATFORM_
CACHE_LINE_SIZE
+
(
sizeof
(
size_t
)
*
3
-
1
);
#endif // else EMBB_DEBUG
// This assert does _not_ hold, but is left for documentation.
// It is not guaranteed that the pointer to the array is aligned.
// See the documentation of the overloaded new[] operator in
// class MemoryAllocation.
// PT_ASSERT_EQ((uintptr_t)aligned_allocated % EMBB_CACHE_LINE_SIZE, 0);
// PT_ASSERT_EQ((uintptr_t)aligned_allocated % EMBB_
PLATFORM_
CACHE_LINE_SIZE, 0);
//delete!
expected
=
0
;
...
...
containers_cpp/include/embb/containers/internal/hazard_pointer.h
View file @
650dec9d
...
...
@@ -34,7 +34,7 @@
#include <embb/base/function.h>
#include <algorithm>
#if defined(EMBB_COMPILER_MSVC)
#if defined(EMBB_
PLATFORM_
COMPILER_MSVC)
#define EMBB_CONTAINERS_CPP_DEPENDANT_TYPENAME
#else
#define EMBB_CONTAINERS_CPP_DEPENDANT_TYPENAME typename
...
...
containers_cpp/include/embb/containers/internal/lock_free_mpmc_queue-inl.h
View file @
650dec9d
...
...
@@ -80,13 +80,13 @@ LockFreeMPMCQueue<Type, ValuePool>::LockFreeMPMCQueue(size_t capacity) :
capacity
(
capacity
),
// Disable "this is used in base member initializer" warning.
// We explicitly want this.
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable:4355)
#endif
delete_pointer_callback
(
*
this
,
&
LockFreeMPMCQueue
<
Type
>::
DeletePointerCallback
),
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#pragma warning(pop)
#endif
hazardPointer
(
delete_pointer_callback
,
NULL
,
2
),
...
...
containers_cpp/include/embb/containers/internal/lock_free_stack-inl.h
View file @
650dec9d
...
...
@@ -72,13 +72,13 @@ LockFreeStack< Type, ValuePool >::LockFreeStack(size_t capacity) :
capacity
(
capacity
),
// Disable "this is used in base member initializer" warning.
// We explicitly want this.
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable:4355)
#endif
delete_pointer_callback
(
*
this
,
&
LockFreeStack
<
Type
>::
DeletePointerCallback
),
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#pragma warning(pop)
#endif
hazardPointer
(
delete_pointer_callback
,
NULL
,
1
),
...
...
containers_cpp/test/hazard_pointer_test.cc
View file @
650dec9d
...
...
@@ -32,12 +32,12 @@ namespace embb {
namespace
containers
{
namespace
test
{
HazardPointerTest
::
HazardPointerTest
()
:
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable:4355)
#endif
delete_pointer_callback
(
*
this
,
&
HazardPointerTest
::
DeletePointerCallback
),
#ifdef EMBB_COMPILER_MSVC
#ifdef EMBB_
PLATFORM_
COMPILER_MSVC
#pragma warning(pop)
#endif
object_pool
(
NULL
),
...
...
mtapi_c/src/mtapi_status_t.h
View file @
650dec9d
...
...
@@ -30,7 +30,7 @@
#include <embb/mtapi/c/mtapi.h>
#include <embb/base/c/internal/config.h>
EMBB_INLINE
void
mtapi_status_set
(
EMBB_
PLATFORM_
INLINE
void
mtapi_status_set
(
mtapi_status_t
*
status
,
mtapi_status_t
value
)
{
if
(
MTAPI_NULL
!=
status
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment