Boost-Graph

 view release on metacpan or  search on metacpan

include/boost/detail/sp_counted_base_cw_ppc.hpp  view on Meta::CPAN

#ifndef BOOST_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED
#define BOOST_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED

// MS compatible compilers support #pragma once

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif

//
//  detail/sp_counted_base_cw_ppc.hpp - CodeWarrior on PowerPC
//
//  Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
//  Copyright 2004-2005 Peter Dimov
//
//  Distributed under the Boost Software License, Version 1.0. (See
//  accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//
//
//  Lock-free algorithm by Alexander Terekhov
//
//  Thanks to Ben Hitchings for the #weak + (#shared != 0)
//  formulation
//

#include <typeinfo>

namespace boost
{

namespace detail
{

inline void atomic_increment( register long * pw )
{
    asm
    {
loop:

    lwarx   r4, 0, r3
    addi    r4, r4, 1
    stwcx.  r4, 0, r3
    bne-    loop
    }
}

inline long atomic_decrement( register long * pw )
{
    asm
    {
    sync

loop:

    lwarx   r4, 0, r3
    addi    r4, r4, -1
    stwcx.  r4, 0, r3
    bne-    loop

    mr      r3, r4

    isync
    }
}

inline long atomic_conditional_increment( register long * pw )
{
    asm
    {
loop:

    lwarx   r4, 0, r3
    cmpwi   r4, 0
    beq     store

    addi    r4, r4, 1

store:

    stwcx.  r4, 0, r3
    bne-    loop

    mr      r3, r4



( run in 0.515 second using v1.01-cache-2.11-cpan-39bf76dae61 )