Reimplemented atomic_get_and_set in C++.
Signed-off-by: Adrien Destugues <[email protected]> * C++ code written by pdziepak.
This commit is contained in:
committed by
Adrien Destugues
parent
e81d40a7c8
commit
7a402b996e
@@ -73,6 +73,6 @@ HAIKU_CCFLAGS_$(HAIKU_PACKAGING_ARCH)
|
|||||||
-DHAIKU_BOARD_LOADER_STACK_BASE=$(HAIKU_BOARD_LOADER_STACK_BASE)
|
-DHAIKU_BOARD_LOADER_STACK_BASE=$(HAIKU_BOARD_LOADER_STACK_BASE)
|
||||||
-DHAIKU_BOARD_LOADER_UIBASE=$(HAIKU_BOARD_LOADER_UIBASE) ;
|
-DHAIKU_BOARD_LOADER_UIBASE=$(HAIKU_BOARD_LOADER_UIBASE) ;
|
||||||
HAIKU_C++FLAGS_$(HAIKU_PACKAGING_ARCH)
|
HAIKU_C++FLAGS_$(HAIKU_PACKAGING_ARCH)
|
||||||
+= -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard
|
+= -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard -std=c++11
|
||||||
-DHAIKU_BOARD_LOADER_STACK_BASE=$(HAIKU_BOARD_LOADER_STACK_BASE)
|
-DHAIKU_BOARD_LOADER_STACK_BASE=$(HAIKU_BOARD_LOADER_STACK_BASE)
|
||||||
-DHAIKU_BOARD_LOADER_UIBASE=$(HAIKU_BOARD_LOADER_UIBASE) ;
|
-DHAIKU_BOARD_LOADER_UIBASE=$(HAIKU_BOARD_LOADER_UIBASE) ;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o :
|
|||||||
atomic.S
|
atomic.S
|
||||||
byteorder.S
|
byteorder.S
|
||||||
|
|
||||||
|
generic_atomic.cpp
|
||||||
generic_system_time_nsecs.cpp
|
generic_system_time_nsecs.cpp
|
||||||
|
|
||||||
: $(TARGET_KERNEL_PIC_CCFLAGS)
|
: $(TARGET_KERNEL_PIC_CCFLAGS)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ for architectureObject in [ MultiArchSubDirSetup arm ] {
|
|||||||
time.c
|
time.c
|
||||||
tls.c
|
tls.c
|
||||||
|
|
||||||
|
generic_atomic.cpp
|
||||||
generic_system_time_nsecs.cpp
|
generic_system_time_nsecs.cpp
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,16 +54,6 @@ FUNCTION(atomic_set):
|
|||||||
bx lr
|
bx lr
|
||||||
FUNCTION_END(atomic_set)
|
FUNCTION_END(atomic_set)
|
||||||
|
|
||||||
/* int atomic_get_and_set(int *value, int setTo)
|
|
||||||
*/
|
|
||||||
FUNCTION(atomic_get_and_set):
|
|
||||||
miss4: ldrex r12, [r0]
|
|
||||||
strex r3, r1, [r0]
|
|
||||||
teq r3, #0
|
|
||||||
bne miss4
|
|
||||||
bx lr
|
|
||||||
FUNCTION_END(atomic_get_and_set)
|
|
||||||
|
|
||||||
/* int atomic_test_and_set(int *value, int setTo, int testValue)
|
/* int atomic_test_and_set(int *value, int setTo, int testValue)
|
||||||
*/
|
*/
|
||||||
FUNCTION(atomic_test_and_set):
|
FUNCTION(atomic_test_and_set):
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014, Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#ifndef ATOMIC_FUNCS_ARE_SYSCALLS
|
||||||
|
|
||||||
|
extern "C" int32_t
|
||||||
|
atomic_get_and_set(int32_t* ptr, int32_t value)
|
||||||
|
{
|
||||||
|
auto& obj = *reinterpret_cast<std::atomic<int32_t>*>(ptr);
|
||||||
|
return obj.exchange(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ATOMIC64_FUNCS_ARE_SYSCALLS */
|
||||||
Reference in New Issue
Block a user