зеркало из https://github.com/mozilla/gecko-dev.git
Bugzilla bug #39696: implemented the NSPR atomic routines in
assembly language for Solaris/x86. Modified files: _solaris.h, solaris.c, os_SunOS_x86.s
This commit is contained in:
Родитель
5839bd125c
Коммит
ca10d036fe
|
@ -45,6 +45,8 @@
|
|||
#define NEED_STRFTIME_LOCK
|
||||
|
||||
/*
|
||||
* Intel x86 has atomic instructions.
|
||||
*
|
||||
* Sparc v8 does not have instructions to efficiently implement
|
||||
* atomic increment/decrement operations. In the local threads
|
||||
* only and pthreads versions, we use the default atomic routine
|
||||
|
@ -53,7 +55,7 @@
|
|||
* in solaris.c, which is actually equivalent to the default
|
||||
* implementation.
|
||||
*/
|
||||
#ifdef _PR_GLOBAL_THREADS_ONLY
|
||||
#if defined(i386) || defined(_PR_GLOBAL_THREADS_ONLY)
|
||||
#define _PR_HAVE_ATOMIC_OPS
|
||||
#endif
|
||||
|
||||
|
|
|
@ -59,6 +59,84 @@ sol_curthread:
|
|||
movl %ecx, %eax
|
||||
ret
|
||||
|
||||
/ PRInt32 _MD_AtomicIncrement(PRInt32 *val)
|
||||
/
|
||||
/ Atomically increment the integer pointed to by 'val' and return
|
||||
/ the result of the increment.
|
||||
/
|
||||
.text
|
||||
.globl _MD_AtomicIncrement
|
||||
.align 4
|
||||
_MD_AtomicIncrement:
|
||||
movl 4(%esp), %ecx
|
||||
movl $1, %eax
|
||||
lock
|
||||
xaddl %eax, (%ecx)
|
||||
incl %eax
|
||||
ret
|
||||
|
||||
/ PRInt32 _MD_AtomicDecrement(PRInt32 *val)
|
||||
/
|
||||
/ Atomically decrement the integer pointed to by 'val' and return
|
||||
/ the result of the decrement.
|
||||
/
|
||||
.text
|
||||
.globl _MD_AtomicDecrement
|
||||
.align 4
|
||||
_MD_AtomicDecrement:
|
||||
movl 4(%esp), %ecx
|
||||
movl $-1, %eax
|
||||
lock
|
||||
xaddl %eax, (%ecx)
|
||||
decl %eax
|
||||
ret
|
||||
|
||||
/ PRInt32 _MD_AtomicSet(PRInt32 *val, PRInt32 newval)
|
||||
/
|
||||
/ Atomically set the integer pointed to by 'val' to the new
|
||||
/ value 'newval' and return the old value.
|
||||
/
|
||||
/ An alternative implementation:
|
||||
/ .text
|
||||
/ .globl _MD_AtomicSet
|
||||
/ .align 4
|
||||
/_MD_AtomicSet:
|
||||
/ movl 4(%esp), %ecx
|
||||
/ movl 8(%esp), %edx
|
||||
/ movl (%ecx), %eax
|
||||
/retry:
|
||||
/ lock
|
||||
/ cmpxchgl %edx, (%ecx)
|
||||
/ jne retry
|
||||
/ ret
|
||||
/
|
||||
.text
|
||||
.globl _MD_AtomicSet
|
||||
.align 4
|
||||
_MD_AtomicSet:
|
||||
movl 4(%esp), %ecx
|
||||
movl 8(%esp), %eax
|
||||
lock
|
||||
xchgl %eax, (%ecx)
|
||||
ret
|
||||
|
||||
/ PRInt32 _MD_AtomicAdd(PRInt32 *ptr, PRInt32 val)
|
||||
/
|
||||
/ Atomically add 'val' to the integer pointed to by 'ptr'
|
||||
/ and return the result of the addition.
|
||||
/
|
||||
.text
|
||||
.globl _MD_AtomicAdd
|
||||
.align 4
|
||||
_MD_AtomicAdd:
|
||||
movl 4(%esp), %ecx
|
||||
movl 8(%esp), %eax
|
||||
movl %eax, %edx
|
||||
lock
|
||||
xaddl %eax, (%ecx)
|
||||
addl %edx, %eax
|
||||
ret
|
||||
|
||||
/
|
||||
/ PR_StackPush(listp, elementp)
|
||||
/
|
||||
|
|
|
@ -69,6 +69,7 @@ PRWord *_MD_HomeGCRegisters(PRThread *t, PRIntn isCurrent, PRIntn *np)
|
|||
}
|
||||
#endif /* _PR_PTHREADS */
|
||||
|
||||
#if !defined(i386)
|
||||
#if defined(_PR_HAVE_ATOMIC_OPS)
|
||||
/* NOTE:
|
||||
* SPARC v9 (Ultras) do have an atomic test-and-set operation. But
|
||||
|
@ -147,6 +148,7 @@ _MD_AtomicSet(PRInt32 *val, PRInt32 newval)
|
|||
return rv;
|
||||
}
|
||||
#endif /* _PR_HAVE_ATOMIC_OPS */
|
||||
#endif /* !defined(i386) */
|
||||
|
||||
#if defined(_PR_GLOBAL_THREADS_ONLY)
|
||||
#include <signal.h>
|
||||
|
|
Загрузка…
Ссылка в новой задаче