michael@0: # -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # michael@0: # Based on the programming examples in The PowerPC Architecture: michael@0: # A Specification for A New Family of RISC Processors, 2nd Ed., michael@0: # Book I, Section E.1, "Synchronization," pp. 249-256, May 1994. michael@0: # michael@0: michael@0: .section ".text" michael@0: michael@0: # michael@0: # PRInt32 _PR_ppc_AtomicIncrement(PRInt32 *val); michael@0: # michael@0: .align 2 michael@0: .globl _PR_ppc_AtomicIncrement michael@0: .type _PR_ppc_AtomicIncrement,@function michael@0: _PR_ppc_AtomicIncrement: michael@0: .Lfd1: lwarx 4,0,3 michael@0: addi 0,4,1 michael@0: stwcx. 0,0,3 michael@0: bne- .Lfd1 michael@0: mr 3,0 michael@0: blr michael@0: .Lfe1: .size _PR_ppc_AtomicIncrement,.Lfe1-_PR_ppc_AtomicIncrement michael@0: michael@0: # michael@0: # PRInt32 _PR_ppc_AtomicDecrement(PRInt32 *val); michael@0: # michael@0: .align 2 michael@0: .globl _PR_ppc_AtomicDecrement michael@0: .type _PR_ppc_AtomicDecrement,@function michael@0: _PR_ppc_AtomicDecrement: michael@0: .Lfd2: lwarx 4,0,3 michael@0: addi 0,4,-1 michael@0: stwcx. 0,0,3 michael@0: bne- .Lfd2 michael@0: mr 3,0 michael@0: blr michael@0: .Lfe2: .size _PR_ppc_AtomicDecrement,.Lfe2-_PR_ppc_AtomicDecrement michael@0: michael@0: # michael@0: # PRInt32 _PR_ppc_AtomicSet(PRInt32 *val, PRInt32 newval); michael@0: # michael@0: .align 2 michael@0: .globl _PR_ppc_AtomicSet michael@0: .type _PR_ppc_AtomicSet,@function michael@0: _PR_ppc_AtomicSet: michael@0: .Lfd3: lwarx 5,0,3 michael@0: stwcx. 4,0,3 michael@0: bne- .Lfd3 michael@0: mr 3,5 michael@0: blr michael@0: .Lfe3: .size _PR_ppc_AtomicSet,.Lfe3-_PR_ppc_AtomicSet michael@0: michael@0: # michael@0: # PRInt32 _PR_ppc_AtomicAdd(PRInt32 *ptr, PRInt32 val); michael@0: # michael@0: .align 2 michael@0: .globl _PR_ppc_AtomicAdd michael@0: .type _PR_ppc_AtomicAdd,@function michael@0: _PR_ppc_AtomicAdd: michael@0: .Lfd4: lwarx 5,0,3 michael@0: add 0,4,5 michael@0: stwcx. 0,0,3 michael@0: bne- .Lfd4 michael@0: mr 3,0 michael@0: blr michael@0: .Lfe4: .size _PR_ppc_AtomicAdd,.Lfe4-_PR_ppc_AtomicAdd michael@0: michael@0: # Magic indicating no need for an executable stack michael@0: .section .note.GNU-stack, "", @progbits ; .previous