andre@0: // -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- andre@0: // andre@0: // This Source Code Form is subject to the terms of the Mozilla Public andre@0: // License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: // file, You can obtain one at http://mozilla.org/MPL/2.0/. andre@0: andre@0: // PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val) andre@0: // andre@0: // Atomically increment the integer pointed to by 'val' and return andre@0: // the result of the increment. andre@0: // andre@0: .text andre@0: .globl _PR_x86_AtomicIncrement andre@0: .align 4 andre@0: _PR_x86_AtomicIncrement: andre@0: movl 4(%esp), %ecx andre@0: movl $1, %eax andre@0: lock andre@0: xaddl %eax, (%ecx) andre@0: incl %eax andre@0: ret andre@0: andre@0: // PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val) andre@0: // andre@0: // Atomically decrement the integer pointed to by 'val' and return andre@0: // the result of the decrement. andre@0: // andre@0: .text andre@0: .globl _PR_x86_AtomicDecrement andre@0: .align 4 andre@0: _PR_x86_AtomicDecrement: andre@0: movl 4(%esp), %ecx andre@0: movl $-1, %eax andre@0: lock andre@0: xaddl %eax, (%ecx) andre@0: decl %eax andre@0: ret andre@0: andre@0: // PRInt32 _PR_x86_AtomicSet(PRInt32 *val, PRInt32 newval) andre@0: // andre@0: // Atomically set the integer pointed to by 'val' to the new andre@0: // value 'newval' and return the old value. andre@0: // andre@0: // An alternative implementation: andre@0: // .text andre@0: // .globl _PR_x86_AtomicSet andre@0: // .align 4 andre@0: //_PR_x86_AtomicSet: andre@0: // movl 4(%esp), %ecx andre@0: // movl 8(%esp), %edx andre@0: // movl (%ecx), %eax andre@0: //retry: andre@0: // lock andre@0: // cmpxchgl %edx, (%ecx) andre@0: // jne retry andre@0: // ret andre@0: // andre@0: .text andre@0: .globl _PR_x86_AtomicSet andre@0: .align 4 andre@0: _PR_x86_AtomicSet: andre@0: movl 4(%esp), %ecx andre@0: movl 8(%esp), %eax andre@0: xchgl %eax, (%ecx) andre@0: ret andre@0: andre@0: // PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val) andre@0: // andre@0: // Atomically add 'val' to the integer pointed to by 'ptr' andre@0: // and return the result of the addition. andre@0: // andre@0: .text andre@0: .globl _PR_x86_AtomicAdd andre@0: .align 4 andre@0: _PR_x86_AtomicAdd: andre@0: movl 4(%esp), %ecx andre@0: movl 8(%esp), %eax andre@0: movl %eax, %edx andre@0: lock andre@0: xaddl %eax, (%ecx) andre@0: addl %edx, %eax andre@0: ret andre@0: andre@0: // Magic indicating no need for an executable stack andre@0: .section .note.GNU-stack, "", @progbits ; .previous