os_Linux_x86.s (1977B)
1 // -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 // 3 // This Source Code Form is subject to the terms of the Mozilla Public 4 // License, v. 2.0. If a copy of the MPL was not distributed with this 5 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 // PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val) 8 // 9 // Atomically increment the integer pointed to by 'val' and return 10 // the result of the increment. 11 // 12 .text 13 .globl _PR_x86_AtomicIncrement 14 .align 4 15 _PR_x86_AtomicIncrement: 16 movl 4(%esp), %ecx 17 movl $1, %eax 18 lock 19 xaddl %eax, (%ecx) 20 incl %eax 21 ret 22 23 // PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val) 24 // 25 // Atomically decrement the integer pointed to by 'val' and return 26 // the result of the decrement. 27 // 28 .text 29 .globl _PR_x86_AtomicDecrement 30 .align 4 31 _PR_x86_AtomicDecrement: 32 movl 4(%esp), %ecx 33 movl $-1, %eax 34 lock 35 xaddl %eax, (%ecx) 36 decl %eax 37 ret 38 39 // PRInt32 _PR_x86_AtomicSet(PRInt32 *val, PRInt32 newval) 40 // 41 // Atomically set the integer pointed to by 'val' to the new 42 // value 'newval' and return the old value. 43 // 44 // An alternative implementation: 45 // .text 46 // .globl _PR_x86_AtomicSet 47 // .align 4 48 //_PR_x86_AtomicSet: 49 // movl 4(%esp), %ecx 50 // movl 8(%esp), %edx 51 // movl (%ecx), %eax 52 //retry: 53 // lock 54 // cmpxchgl %edx, (%ecx) 55 // jne retry 56 // ret 57 // 58 .text 59 .globl _PR_x86_AtomicSet 60 .align 4 61 _PR_x86_AtomicSet: 62 movl 4(%esp), %ecx 63 movl 8(%esp), %eax 64 xchgl %eax, (%ecx) 65 ret 66 67 // PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val) 68 // 69 // Atomically add 'val' to the integer pointed to by 'ptr' 70 // and return the result of the addition. 71 // 72 .text 73 .globl _PR_x86_AtomicAdd 74 .align 4 75 _PR_x86_AtomicAdd: 76 movl 4(%esp), %ecx 77 movl 8(%esp), %eax 78 movl %eax, %edx 79 lock 80 xaddl %eax, (%ecx) 81 addl %edx, %eax 82 ret 83 84 // Magic indicating no need for an executable stack 85 .section .note.GNU-stack, "", @progbits