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
19db52cd
authored
Oct 07, 2014
by
Tobias Schuele
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of
https://github.com/siemens/embb
into development
parents
334832ca
c8ca25f2
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
77 additions
and
79 deletions
+77
-79
base_c/include/embb/base/c/internal/atomic/and_assign.h
+10
-9
base_c/include/embb/base/c/internal/atomic/compare_and_swap.h
+19
-21
base_c/include/embb/base/c/internal/atomic/fetch_and_add.h
+12
-11
base_c/include/embb/base/c/internal/atomic/load.h
+6
-7
base_c/include/embb/base/c/internal/atomic/or_assign.h
+7
-8
base_c/include/embb/base/c/internal/atomic/store.h
+6
-2
base_c/include/embb/base/c/internal/atomic/swap.h
+7
-10
base_c/include/embb/base/c/internal/atomic/xor_assign.h
+8
-9
base_cpp/test/atomic_test.cc
+2
-2
No files found.
base_c/include/embb/base/c/internal/atomic/and_assign.h
View file @
19db52cd
...
...
@@ -101,22 +101,23 @@ EMBB_DEFINE_AND_ASSIGN(8, "q")
volatile* pointer_to_value, \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
value) { \
register \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
t
1, t2, t3
; \
t
mp, result
; \
__asm__ __volatile__ ( \
"dmb\n\t" \
"loop_%=:\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
2, %0
\n\t" \
"and %
3, %2, %1
\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
4, %3, %0
\n\t" \
"teq %
4
, #0\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
0, [%2]
\n\t" \
"and %
0, %0, %3
\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
1, %0, [%2]
\n\t" \
"teq %
1
, #0\n\t" \
"bne loop_%=\n\t" \
"isb" \
: "
+m" (*pointer_to_value), "+r" (value), "=r" (t1), "=r" (t2), "=r" (t3
) \
:
\
: "memory", "cc" );
\
: "
=&r" (result), "=&r" (tmp
) \
:
"r" (pointer_to_value), "Ir" (value)
\
: "memory", "cc" ); \
}
/* __sync_fetch_and_and(pointer_to_value, value); \
}*/
#else
#error "No atomic fetch and store implementation found"
#endif
...
...
base_c/include/embb/base/c/internal/atomic/compare_and_swap.h
View file @
19db52cd
...
...
@@ -95,29 +95,27 @@ EMBB_DEFINE_COMPARE_AND_SWAP(8, "q")
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) { \
register \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
result, t1, t2; \
oldval, res; \
__asm__ __volatile__ ("dmb" : : : "memory"); \
do { \
__asm__ __volatile__ ( \
"dmb\n\t" \
"ldr %4, %1\n\t" \
"loop_%=:\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %3, %0\n\t" \
"mov %2, #1\n\t" \
"cmp %3, %4\n\t" \
"bne fail_%=\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %2, %5, %0\n\t" \
"teq %2, #0\n\t" \
"bne loop_%=\n\t" \
"fail_%=:\n\t" \
"str %3, %1\n\t" \
"eor %2, %2, #1\n\t" \
"isb" \
: "+m" (*pointer_to_value), "+m" (*expected), \
"=r" (result), "=r" (t1), "=r" (t2), "+r" (desired) \
: \
: "memory", "cc" ); \
return result; \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %1, [%2]\n\t" \
"mov %0, #0\n\t" \
"teq %1, %3\n\t" \
"it eq\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX "eq %0, %4, [%2]\n\t" \
: "=&r" (res), "=&r" (oldval) \
: "r" (pointer_to_value), "Ir" (*expected), "r" (desired) \
: "cc" ); \
} while (res); \
__asm__ __volatile__ ("isb" : : : "memory"); \
if (oldval == *expected) { \
return 1; \
} else { \
*expected = oldval; \
return 0; \
} \
}
#else
#error "No atomic fetch and store implementation found"
...
...
base_c/include/embb/base/c/internal/atomic/fetch_and_add.h
View file @
19db52cd
...
...
@@ -91,24 +91,25 @@ EMBB_DEFINE_FETCH_AND_ADD(8, "q")
volatile* pointer_to_value, \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
new_value) { \
register \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
t
1, t2, t3
; \
t
mp, result
; \
__asm__ __volatile__ ( \
"dmb\n\t" \
"loop_%=:\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
2, %0
\n\t" \
"add %
3, %2, %1
\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
4, %3, %0
\n\t" \
"teq %
4
, #0\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
0, [%2]
\n\t" \
"add %
1, %0, %3
\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
1, %1, [%2]
\n\t" \
"teq %
1
, #0\n\t" \
"bne loop_%=\n\t" \
"mov %1, %2\n\t" \
"isb" \
: "
+m" (*pointer_to_value), "+r" (new_value), "=r" (t1), "=r" (t2), "=r" (t3
) \
:
\
: "memory", "cc" );
\
return
new_value
; \
: "
=&r" (result), "=&r" (tmp
) \
:
"r" (pointer_to_value), "r" (new_value)
\
: "memory", "cc" ); \
return
result
; \
}
/* return __sync_fetch_and_add( \
pointer_to_value, new_value); \
}*/
#else
#error "No atomic fetch and store implementation found"
#endif
...
...
base_c/include/embb/base/c/internal/atomic/load.h
View file @
19db52cd
...
...
@@ -90,17 +90,16 @@ EMBB_DEFINE_LOAD(8, "q")
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 */
\
register EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
result; \
__asm__ __volatile__(\
"dmb\n\t" \
"ldr" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %0,
%1\n\t"
\
"ldr" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %0,
[%1]\n\t"
\
"dmb" \
: "=
r" (result)
\
: "
m" (*pointer_to_value)
\
: "memory");
\
return result;
\
: "=
&r" (result)
\
: "
r" (pointer_to_value)
\
: "memory"); \
return result; \
}
#else
#error "No atomic fetch and store implementation found"
...
...
base_c/include/embb/base/c/internal/atomic/or_assign.h
View file @
19db52cd
...
...
@@ -88,20 +88,19 @@ EMBB_DEFINE_OR_ASSIGN(8, "q")
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) { \
register \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
t1, t2, t3
; \
result, tmp
; \
__asm__ __volatile__ ( \
"dmb\n\t" \
"loop_%=:\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
2, %0
\n\t" \
"orr %
3, %2, %1
\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
4, %3, %0
\n\t" \
"teq %
4
, #0\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
0, [%2]
\n\t" \
"orr %
0, %0, %3
\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
1, %0, [%2]
\n\t" \
"teq %
1
, #0\n\t" \
"bne loop_%=\n\t" \
"isb" \
: "
+m" (*pointer_to_value), "+r" (value), "=r" (t1), "=r" (t2), "=r" (t3
) \
:
\
: "
=&r" (result), "=&r" (tmp
) \
:
"r" (pointer_to_value), "Ir" (value)
\
: "memory", "cc" ); \
}
#else
...
...
base_c/include/embb/base/c/internal/atomic/store.h
View file @
19db52cd
...
...
@@ -89,11 +89,15 @@ EMBB_DEFINE_STORE(8, "q")
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) {\
__asm__ __volatile__( \
"dmb\n\t" \
"str" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %1, %0" \
: "+m" (*pointer_to_value), "+r" (new_value) \
"str" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %1, [%0]" \
: \
: "r" (pointer_to_value), "r" (new_value) \
: "memory"); \
}
/* __sync_synchronize(); \
*pointer_to_value = new_value; \
__sync_synchronize(); \
}*/
#else
#error "No atomic fetch and store implementation found"
#endif
...
...
base_c/include/embb/base/c/internal/atomic/swap.h
View file @
19db52cd
...
...
@@ -91,23 +91,20 @@ EMBB_DEFINE_SWAP(8, "q")
volatile* pointer_to_value, \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value)\
{ \
register \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
t
1, t2
; \
t
mp, result
; \
__asm__ __volatile__ ( \
"dmb\n\t" \
"loop_%=:\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
2, %0
\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
3, %1, %0
\n\t" \
"teq %
3
, #0\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
0, [%3]
\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
1, %2, [%3]
\n\t" \
"teq %
1
, #0\n\t" \
"bne loop_%=\n\t" \
"mov %1, %2\n\t" \
"isb" \
: "+m" (*pointer_to_value), \
"+r" (new_value), "=r" (t1), "=r" (t2) \
: \
: "=&r" (result), "=&r" (tmp) \
: "r" (new_value), "r" (pointer_to_value) \
: "memory", "cc" ); \
return
new_value
; \
return
result
; \
}
#else
#error "No atomic fetch and store implementation found"
...
...
base_c/include/embb/base/c/internal/atomic/xor_assign.h
View file @
19db52cd
...
...
@@ -89,21 +89,20 @@ EMBB_DEFINE_XOR_ASSIGN(8, "q")
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) { \
register \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \
t1, t2, t3
; \
result, tmp
; \
__asm__ __volatile__ ( \
"dmb\n\t" \
"loop_%=:\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
2, %0
\n\t" \
"eor %
3, %2, %1
\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
4, %3, %0
\n\t" \
"teq %
4
, #0\n\t" \
"ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
0, [%2]
\n\t" \
"eor %
0, %0, %3
\n\t" \
"strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %
1, %0, [%2]
\n\t" \
"teq %
1
, #0\n\t" \
"bne loop_%=\n\t" \
"isb" \
: "
+m" (*pointer_to_value), "+r" (value), "=r" (t1), "=r" (t2), "=r" (t3
) \
:
\
: "memory", "cc" );
\
: "
=&r" (result), "=&r" (tmp
) \
:
"r" (pointer_to_value), "Ir" (value)
\
: "memory", "cc" ); \
}
#else
#error "No atomic or assign implementation found"
...
...
base_cpp/test/atomic_test.cc
View file @
19db52cd
...
...
@@ -284,14 +284,14 @@ AtomicTest::AtomicTest() {
typedef
enum
{
RED
,
GREEN
,
BLUE
}
colors_t
;
void
AtomicTest
::
BasicTests
()
{
//
embb::base::Atomic<bool> b; // Boolean
embb
::
base
::
Atomic
<
bool
>
b
;
// Boolean
embb
::
base
::
Atomic
<
colors_t
>
c
;
// Enumeration
embb
::
base
::
Atomic
<
void
*>
v
;
// Void pointer
embb
::
base
::
Atomic
<
int
>
i
;
// Integer
embb
::
base
::
Atomic
<
int
*>
n
;
// Non-void pointer
//template specializations
//
PT_EXPECT(!b.IsArithmetic() && !b.IsInteger() && !b.IsPointer());
PT_EXPECT
(
!
b
.
IsArithmetic
()
&&
!
b
.
IsInteger
()
&&
!
b
.
IsPointer
());
PT_EXPECT
(
!
c
.
IsArithmetic
()
&&
!
c
.
IsInteger
()
&&
!
c
.
IsPointer
());
PT_EXPECT
(
!
v
.
IsArithmetic
()
&&
!
v
.
IsInteger
()
&&
!
v
.
IsPointer
());
PT_EXPECT
(
i
.
IsArithmetic
()
&&
i
.
IsInteger
()
&&
!
i
.
IsPointer
());
...
...
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