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