diff --git a/src/system/boot/Jamfile b/src/system/boot/Jamfile index 46aecb6823..4070d0ef75 100644 --- a/src/system/boot/Jamfile +++ b/src/system/boot/Jamfile @@ -11,9 +11,13 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) kernel lib ] ; UsePrivateHeaders [ FDirName libroot locale ] ; +local extraSources = ; +if $(TARGET_GCC_VERSION_$(TARGET_PACKAGING_ARCH)[1]) = 2 { + extraSources += atomic.S ; +} + BootMergeObject boot_libroot.o : abs.c - atomic.S ctype.cpp LocaleData.cpp qsort.c @@ -36,6 +40,7 @@ BootMergeObject boot_libroot.o : strchr.c strrchr.c strtol.c + $(extraSources) : -fno-pic ; diff --git a/src/system/kernel/lib/arch/arm/Jamfile b/src/system/kernel/lib/arch/arm/Jamfile index 12b8c503b4..2b7c1ccd70 100644 --- a/src/system/kernel/lib/arch/arm/Jamfile +++ b/src/system/kernel/lib/arch/arm/Jamfile @@ -9,7 +9,6 @@ SEARCH_SOURCE += [ FDirName $(librootSources) os arch $(TARGET_ARCH) ] ; SEARCH_SOURCE += [ FDirName $(librootSources) os arch generic ] ; KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o : - atomic.S byteorder.S generic_atomic.cpp diff --git a/src/system/kernel/lib/arch/x86_64/Jamfile b/src/system/kernel/lib/arch/x86_64/Jamfile index 259708b5f4..168f14cb28 100644 --- a/src/system/kernel/lib/arch/x86_64/Jamfile +++ b/src/system/kernel/lib/arch/x86_64/Jamfile @@ -10,13 +10,14 @@ local librootSources = [ FDirName $(HAIKU_TOP) src system libroot ] ; local posixSources = [ FDirName $(librootSources) posix ] ; SEARCH_SOURCE += [ FDirName $(librootSources) os arch $(TARGET_ARCH) ] ; +SEARCH_SOURCE += [ FDirName $(librootSources) os arch generic ] ; KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o : - atomic.S byteorder.S system_time_asm.S system_time.c + generic_atomic.cpp : $(TARGET_KERNEL_PIC_CCFLAGS) ; diff --git a/src/system/libroot/os/arch/arm/Jamfile b/src/system/libroot/os/arch/arm/Jamfile index 87acdeaf0f..d22221ba31 100644 --- a/src/system/libroot/os/arch/arm/Jamfile +++ b/src/system/libroot/os/arch/arm/Jamfile @@ -11,7 +11,6 @@ for architectureObject in [ MultiArchSubDirSetup arm ] { SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; MergeObject <$(architecture)>os_arch_$(TARGET_ARCH).o : - atomic.S byteorder.S system_time.c stack_frame.c diff --git a/src/system/libroot/os/arch/arm/atomic.S b/src/system/libroot/os/arch/arm/atomic.S deleted file mode 100644 index 56f1c2cd43..0000000000 --- a/src/system/libroot/os/arch/arm/atomic.S +++ /dev/null @@ -1,113 +0,0 @@ -/* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ - -#include -#include - - -.text - -#ifndef ATOMIC_FUNCS_ARE_SYSCALLS - -/* int atomic_add(int *value, int increment) - */ -FUNCTION(atomic_add): -miss1: ldrex r12, [r0] - add r2, r12, r1 - strex r3, r2, [r0] - teq r3, #0 - bne miss1 - mov r0, r12 - bx lr -FUNCTION_END(atomic_add) - -/* int atomic_and(int *value, int andValue) - */ -FUNCTION(atomic_and): -miss2: ldrex r12, [r0] - and r2, r12, r1 - strex r3, r2, [r0] - teq r3, #0 - bne miss2 - mov r0, r12 - bx lr -FUNCTION_END(atomic_and) - -/* int atomic_or(int *value, int orValue) - */ -FUNCTION(atomic_or): -miss3: ldrex r12, [r0] - eor r2, r12, r1 - strex r3, r2, [r0] - teq r3, #0 - bne miss3 - mov r0, r12 - bx lr -FUNCTION_END(atomic_or) - -/* void atomic_set(int *value, int setTo) - */ -FUNCTION(atomic_set): - str r1, [r0] - bx lr -FUNCTION_END(atomic_set) - -/* int atomic_test_and_set(int *value, int setTo, int testValue) - */ -FUNCTION(atomic_test_and_set): -miss5: ldrex r12, [r0] @ load from the address and mark it exclusive - cmp r12, r2 @ compare the value with the comperand(r2) - strexeq r3, r1, [r0] @ if they were equal, attempt to store the new value (r1) - bne differ @ if they were not equal jump to (differ) which clears the exclusive tag on the address and returns< - cmp r3, #1 @ check the status of the store (returned in r3) - beq miss5 @ go back to the start if it failed (0=success, 1=failure) - bne same @ if it succeeded, jump to (same) and return. there is no need to clrex if strex succeeded -differ: clrex @ clrex -same: mov r0, r12 - bx lr -FUNCTION_END(atomic_test_and_set) - -/* int atomic_get(int *value) - */ -FUNCTION(atomic_get): - ldr r0, [r0] - bx lr -FUNCTION_END(atomic_get) - -#endif /* ATOMIC_FUNCS_ARE_SYSCALLS */ - -#ifndef ATOMIC64_FUNCS_ARE_SYSCALLS - -/* int64 atomic_add64(vint64 *value, int64 addValue) */ -FUNCTION(atomic_add64): - bx lr -FUNCTION_END(atomic_add64) - -/* int64 atomic_and64(vint64 *value, int64 andValue) */ -FUNCTION(atomic_and64): - bx lr -FUNCTION_END(atomic_and64) - -/* int64 atomic_or64(vint64 *value, int64 orValue) */ -FUNCTION(atomic_or64): - bx lr -FUNCTION_END(atomic_or64) - -/* int64 atomic_set64(vint64 *value, int64 newValue) */ -FUNCTION(atomic_set64): - bx lr -FUNCTION_END(atomic_set64) - -/* int64 atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst) */ -FUNCTION(atomic_test_and_set64): - bx lr -FUNCTION_END(atomic_test_and_set64) - -/* int64 atomic_get64(vint64 *value) */ -FUNCTION(atomic_get64): - bx lr -FUNCTION_END(atomic_get64) - -#endif /* ATOMIC64_FUNCS_ARE_SYSCALLS */ diff --git a/src/system/libroot/os/arch/x86_64/Jamfile b/src/system/libroot/os/arch/x86_64/Jamfile index 26b8c27ddd..5aad0052ea 100644 --- a/src/system/libroot/os/arch/x86_64/Jamfile +++ b/src/system/libroot/os/arch/x86_64/Jamfile @@ -12,8 +12,9 @@ for architectureObject in [ MultiArchSubDirSetup x86_64 ] { # TODO in time.c! UsePrivateSystemHeaders ; + SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; + MergeObject <$(architecture)>os_arch_$(TARGET_ARCH).o : - atomic.S byteorder.S get_stack_frame.S system_info.cpp @@ -21,6 +22,8 @@ for architectureObject in [ MultiArchSubDirSetup x86_64 ] { thread.cpp time.cpp tls.cpp + + generic_atomic.cpp ; } } diff --git a/src/system/libroot/os/arch/x86_64/atomic.S b/src/system/libroot/os/arch/x86_64/atomic.S deleted file mode 100644 index b88af32987..0000000000 --- a/src/system/libroot/os/arch/x86_64/atomic.S +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2013, Paweł Dziepak, pdziepak@quarnos.org. - * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. - * Distributed under the terms of the MIT License. - */ - - -#include - - -.text - - -/* int32 atomic_set(int32* value, int32 newValue) */ -FUNCTION(atomic_set): - sfence - movl %esi, (%rdi) - ret -FUNCTION_END(atomic_set) - - -/* int32 atomic_get_and_set(int32* value, int32 newValue) */ -FUNCTION(atomic_get_and_set): - movl %esi, %eax - xchgl %eax, (%rdi) - ret -FUNCTION_END(atomic_get_and_set) - - -/* int32 atomic_test_and_set(int32* value, int32 newValue, int32 testAgainst) */ -FUNCTION(atomic_test_and_set): - movl %edx, %eax - lock - cmpxchgl %esi, (%rdi) - ret -FUNCTION_END(atomic_test_and_set) - - -/* int32 atomic_add(int32* value, int32 addValue) */ -FUNCTION(atomic_add): - movl %esi, %eax - lock - xaddl %eax, (%rdi) - ret -FUNCTION_END(atomic_add) - - -/* int32 atomic_and(int32* value, int32 andValue) */ -FUNCTION(atomic_and): - movl (%rdi), %eax -1: movl %eax, %edx - movl %eax, %ecx - andl %esi, %edx - lock - cmpxchgl %edx, (%rdi) - jnz 1b - movl %ecx, %eax - ret -FUNCTION_END(atomic_and) - - -/* int32 atomic_or(int32* value, int32 orValue) */ -FUNCTION(atomic_or): - movl (%rdi), %eax -1: movl %eax, %edx - movl %eax, %ecx - orl %esi, %edx - lock - cmpxchgl %edx, (%rdi) - jnz 1b - movl %ecx, %eax - ret -FUNCTION_END(atomic_or) - - -/* int32 atomic_get(int32* value) */ -FUNCTION(atomic_get): - movl (%rdi), %eax - lfence - ret -FUNCTION_END(atomic_get) - - -/* int64 atomic_set64(int64* value, int64 newValue) */ -FUNCTION(atomic_set64): - sfence - movq %rsi, (%rdi) - ret -FUNCTION_END(atomic_set64) - - -/* int64 atomic_get_and_set64(int64* value, int64 newValue) */ -FUNCTION(atomic_get_and_set64): - movq %rsi, %rax - xchgq %rax, (%rdi) - ret -FUNCTION_END(atomic_get_and_set64) - - -/* int64 atomic_test_and_set64(int64* value, int64 newValue, - int64 testAgainst) */ -FUNCTION(atomic_test_and_set64): - movq %rdx, %rax - lock - cmpxchgq %rsi, (%rdi) - ret -FUNCTION_END(atomic_test_and_set64) - - -/* int64 atomic_add64(int64* value, int64 addValue) */ -FUNCTION(atomic_add64): - movq %rsi, %rax - lock - xaddq %rax, (%rdi) - ret -FUNCTION_END(atomic_add64) - - -/* int64 atomic_and64(int64* value, int64 andValue) */ -FUNCTION(atomic_and64): - movq (%rdi), %rax -1: movq %rax, %rdx - movq %rax, %rcx - andq %rsi, %rdx - lock - cmpxchgq %rdx, (%rdi) - jnz 1b - movq %rcx, %rax - ret -FUNCTION_END(atomic_and64) - - -/* int64 atomic_or64(int64* value, int64 orValue) */ -FUNCTION(atomic_or64): - movq (%rdi), %rax -1: movq %rax, %rdx - movq %rax, %rcx - orq %rsi, %rdx - lock - cmpxchgq %rdx, (%rdi) - jnz 1b - movq %rcx, %rax - ret -FUNCTION_END(atomic_or64) - - -/* int64 atomic_get64(int64* value) */ -FUNCTION(atomic_get64): - movq (%rdi), %rax - lfence - ret -FUNCTION_END(atomic_get64) - diff --git a/src/system/runtime_loader/arch/arm/Jamfile b/src/system/runtime_loader/arch/arm/Jamfile index afc33d34ac..86d9d2b648 100644 --- a/src/system/runtime_loader/arch/arm/Jamfile +++ b/src/system/runtime_loader/arch/arm/Jamfile @@ -10,7 +10,6 @@ SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ; StaticLibrary libruntime_loader_$(TARGET_ARCH).a : arch_relocate.cpp : - atomic.o thread.o arch_string.o diff --git a/src/system/runtime_loader/arch/x86_64/Jamfile b/src/system/runtime_loader/arch/x86_64/Jamfile index b9baa7906e..42e72d4b75 100644 --- a/src/system/runtime_loader/arch/x86_64/Jamfile +++ b/src/system/runtime_loader/arch/x86_64/Jamfile @@ -10,7 +10,6 @@ SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ; StaticLibrary libruntime_loader_$(TARGET_ARCH).a : arch_relocate.cpp : - atomic.o thread.o arch_string.o ;