Ticket #11121: Reimplemented-atomic_get_and_set-in-C++.patch

File Reimplemented-atomic_get_and_set-in-C++.patch, 3.4 KB (added by arvindsraj, 10 years ago)
  • build/jam/board/beagle/BoardSetup

    From eaa470676a69c06fdf55aa6c13b715dbd2c1b929 Mon Sep 17 00:00:00 2001
    From: Arvind S Raj <sraj.arvind@gmail.com>
    Date: Fri, 15 Aug 2014 23:41:49 +0530
    Subject: [PATCH] Reimplemented atomic_get_and_set in C++.
    
    ---
     build/jam/board/beagle/BoardSetup                     |  2 +-
     src/system/kernel/lib/arch/arm/Jamfile                |  1 +
     src/system/libroot/os/arch/arm/Jamfile                |  1 +
     src/system/libroot/os/arch/arm/atomic.S               | 10 ----------
     src/system/libroot/os/arch/generic/generic_atomic.cpp | 19 +++++++++++++++++++
     5 files changed, 22 insertions(+), 11 deletions(-)
     create mode 100644 src/system/libroot/os/arch/generic/generic_atomic.cpp
    
    diff --git a/build/jam/board/beagle/BoardSetup b/build/jam/board/beagle/BoardSetup
    index 5ee0a11..ddf5442 100644
    a b HAIKU_CCFLAGS_$(HAIKU_PACKAGING_ARCH)  
    7373       -DHAIKU_BOARD_LOADER_STACK_BASE=$(HAIKU_BOARD_LOADER_STACK_BASE)
    7474       -DHAIKU_BOARD_LOADER_UIBASE=$(HAIKU_BOARD_LOADER_UIBASE) ;
    7575HAIKU_C++FLAGS_$(HAIKU_PACKAGING_ARCH)
    76     += -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard
     76    += -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard -std=c++11
    7777       -DHAIKU_BOARD_LOADER_STACK_BASE=$(HAIKU_BOARD_LOADER_STACK_BASE)
    7878       -DHAIKU_BOARD_LOADER_UIBASE=$(HAIKU_BOARD_LOADER_UIBASE) ;
  • src/system/kernel/lib/arch/arm/Jamfile

    diff --git a/src/system/kernel/lib/arch/arm/Jamfile b/src/system/kernel/lib/arch/arm/Jamfile
    index 1bdf0f1..12b8c50 100644
    a b KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o :  
    1212    atomic.S
    1313    byteorder.S
    1414
     15    generic_atomic.cpp
    1516    generic_system_time_nsecs.cpp
    1617
    1718    : $(TARGET_KERNEL_PIC_CCFLAGS)
  • src/system/libroot/os/arch/arm/Jamfile

    diff --git a/src/system/libroot/os/arch/arm/Jamfile b/src/system/libroot/os/arch/arm/Jamfile
    index bdfa8c6..87acdea 100644
    a b for architectureObject in [ MultiArchSubDirSetup arm ] {  
    2020            time.c
    2121            tls.c
    2222
     23            generic_atomic.cpp
    2324            generic_system_time_nsecs.cpp
    2425            ;
    2526    }
  • src/system/libroot/os/arch/arm/atomic.S

    diff --git a/src/system/libroot/os/arch/arm/atomic.S b/src/system/libroot/os/arch/arm/atomic.S
    index 5728e5c..56f1c2c 100644
    a b FUNCTION(atomic_set):  
    5454        bx  lr
    5555FUNCTION_END(atomic_set)
    5656
    57 /* int atomic_get_and_set(int *value, int setTo)
    58  */
    59 FUNCTION(atomic_get_and_set):
    60 miss4:      ldrex   r12, [r0]
    61             strex   r3, r1, [r0]
    62             teq     r3, #0
    63             bne     miss4
    64             bx  lr
    65 FUNCTION_END(atomic_get_and_set)
    66 
    6757/* int atomic_test_and_set(int *value, int setTo, int testValue)
    6858 */
    6959FUNCTION(atomic_test_and_set):
  • new file src/system/libroot/os/arch/generic/generic_atomic.cpp

    diff --git a/src/system/libroot/os/arch/generic/generic_atomic.cpp b/src/system/libroot/os/arch/generic/generic_atomic.cpp
    new file mode 100644
    index 0000000..73b5c56
    - +  
     1/*
     2 * Copyright 2014, Haiku, Inc.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 */
     6
     7#include <atomic>
     8#include <sys/types.h>
     9
     10#ifndef ATOMIC_FUNCS_ARE_SYSCALLS
     11
     12extern "C" int32_t
     13atomic_get_and_set(int32_t* ptr, int32_t value)
     14{
     15    auto& obj = *reinterpret_cast<std::atomic<int32_t>*>(ptr);
     16    return obj.exchange(value);
     17}
     18
     19#endif /* ATOMIC64_FUNCS_ARE_SYSCALLS */