nsprpub/pr/src/md/unix/os_Linux_x86.s

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/src/md/unix/os_Linux_x86.s	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     1.4 +// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 +// 
     1.6 +// This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +// License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +// file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +// PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val)
    1.11 +//
    1.12 +// Atomically increment the integer pointed to by 'val' and return
    1.13 +// the result of the increment.
    1.14 +//
    1.15 +    .text
    1.16 +    .globl _PR_x86_AtomicIncrement
    1.17 +    .align 4
    1.18 +_PR_x86_AtomicIncrement:
    1.19 +    movl 4(%esp), %ecx
    1.20 +    movl $1, %eax
    1.21 +    lock
    1.22 +    xaddl %eax, (%ecx)
    1.23 +    incl %eax
    1.24 +    ret
    1.25 +
    1.26 +// PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val)
    1.27 +//
    1.28 +// Atomically decrement the integer pointed to by 'val' and return
    1.29 +// the result of the decrement.
    1.30 +//
    1.31 +    .text
    1.32 +    .globl _PR_x86_AtomicDecrement
    1.33 +    .align 4
    1.34 +_PR_x86_AtomicDecrement:
    1.35 +    movl 4(%esp), %ecx
    1.36 +    movl $-1, %eax
    1.37 +    lock
    1.38 +    xaddl %eax, (%ecx)
    1.39 +    decl %eax
    1.40 +    ret
    1.41 +
    1.42 +// PRInt32 _PR_x86_AtomicSet(PRInt32 *val, PRInt32 newval)
    1.43 +//
    1.44 +// Atomically set the integer pointed to by 'val' to the new
    1.45 +// value 'newval' and return the old value.
    1.46 +//
    1.47 +// An alternative implementation:
    1.48 +//   .text
    1.49 +//   .globl _PR_x86_AtomicSet
    1.50 +//   .align 4
    1.51 +//_PR_x86_AtomicSet:
    1.52 +//   movl 4(%esp), %ecx
    1.53 +//   movl 8(%esp), %edx
    1.54 +//   movl (%ecx), %eax
    1.55 +//retry:
    1.56 +//   lock
    1.57 +//   cmpxchgl %edx, (%ecx)
    1.58 +//   jne retry
    1.59 +//   ret
    1.60 +//
    1.61 +    .text
    1.62 +    .globl _PR_x86_AtomicSet
    1.63 +    .align 4
    1.64 +_PR_x86_AtomicSet:
    1.65 +    movl 4(%esp), %ecx
    1.66 +    movl 8(%esp), %eax
    1.67 +    xchgl %eax, (%ecx)
    1.68 +    ret
    1.69 +
    1.70 +// PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val)
    1.71 +//
    1.72 +// Atomically add 'val' to the integer pointed to by 'ptr'
    1.73 +// and return the result of the addition.
    1.74 +//
    1.75 +    .text
    1.76 +    .globl _PR_x86_AtomicAdd
    1.77 +    .align 4
    1.78 +_PR_x86_AtomicAdd:
    1.79 +    movl 4(%esp), %ecx
    1.80 +    movl 8(%esp), %eax
    1.81 +    movl %eax, %edx
    1.82 +    lock
    1.83 +    xaddl %eax, (%ecx)
    1.84 +    addl %edx, %eax
    1.85 +    ret
    1.86 +
    1.87 +// Magic indicating no need for an executable stack
    1.88 +.section .note.GNU-stack, "", @progbits ; .previous

mercurial