Bugzilla Bug 322287: the "lock" prefix is not required for the x86 "xchg" NSPRPUB_PRE_4_2_CLIENT_BRANCH
authorwtchang%redhat.com
Mon, 09 Jan 2006 18:00:14 +0000
branchNSPRPUB_PRE_4_2_CLIENT_BRANCH
changeset 3536 7c56d641e2fbf99c7274a35e43f26d050814e750
parent 3533 ffe08a7c5b8d379bd08a2d6b5a03bde6217a5a4c
child 3538 9e0d2e60afb0fdc656d953d0fff7f9666e609336
push idunknown
push userunknown
push dateunknown
bugs322287
Bugzilla Bug 322287: the "lock" prefix is not required for the x86 "xchg" instruction. r=mark.mentovai. Modified files: os2emx.s os2vacpp.asm os_Linux_x86.s os_Linux_x86_64.s os_SunOS_x86.s os_SunOS_x86_64.s ntmisc.c Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
pr/src/md/os2/os2emx.s
pr/src/md/os2/os2vacpp.asm
pr/src/md/unix/os_Linux_x86.s
pr/src/md/unix/os_Linux_x86_64.s
pr/src/md/unix/os_SunOS_x86.s
pr/src/md/unix/os_SunOS_x86_64.s
pr/src/md/windows/ntmisc.c
--- a/pr/src/md/os2/os2emx.s
+++ b/pr/src/md/os2/os2emx.s
@@ -84,17 +84,16 @@
 /   ret
 /
     .text
     .globl __PR_MD_ATOMIC_SET
     .align 4
 __PR_MD_ATOMIC_SET:
     movl 4(%esp), %ecx
     movl 8(%esp), %eax
-    lock
     xchgl %eax, (%ecx)
     ret
 
 / PRInt32 __PR_MD_ATOMIC_ADD(PRInt32 *ptr, PRInt32 val)
 /
 / Atomically add 'val' to the integer pointed to by 'ptr'
 / and return the result of the addition.
 /
--- a/pr/src/md/os2/os2vacpp.asm
+++ b/pr/src/md/os2/os2vacpp.asm
@@ -216,17 +216,17 @@ rel_post:
         ret
 SemReleasex86     ENDP
 
 ;;;---------------------------------------------------------------------
 ;;; PRInt32 _Optlink _PR_MD_ATOMIC_SET(PRInt32* val, PRInt32 newval)
 ;;;---------------------------------------------------------------------
         ALIGN   10H
 _PR_MD_ATOMIC_SET     proc
-   lock xchg    dword ptr [eax],edx
+        xchg    dword ptr [eax],edx
         mov eax, edx;
         ret
 _PR_MD_ATOMIC_SET     endp
 
 ;;;---------------------------------------------------------------------
 ;;; PRInt32 _Optlink _PR_MD_ATOMIC_ADD(PRInt32* ptr, PRInt32 val)
 ;;;---------------------------------------------------------------------
         ALIGN   10H
--- a/pr/src/md/unix/os_Linux_x86.s
+++ b/pr/src/md/unix/os_Linux_x86.s
@@ -84,17 +84,16 @@
 /   ret
 /
     .text
     .globl _PR_x86_AtomicSet
     .align 4
 _PR_x86_AtomicSet:
     movl 4(%esp), %ecx
     movl 8(%esp), %eax
-    lock
     xchgl %eax, (%ecx)
     ret
 
 / PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val)
 /
 / Atomically add 'val' to the integer pointed to by 'ptr'
 / and return the result of the addition.
 /
--- a/pr/src/md/unix/os_Linux_x86_64.s
+++ b/pr/src/md/unix/os_Linux_x86_64.s
@@ -67,17 +67,16 @@
 / Atomically set the integer pointed to by 'val' to the new
 / value 'newval' and return the old value.
 /
     .text
     .globl _PR_x86_64_AtomicSet
     .align 4
 _PR_x86_64_AtomicSet:
     movl %esi, %eax
-    lock
     xchgl %eax, (%rdi)
     ret
 
 / PRInt32 _PR_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val)
 /
 / Atomically add 'val' to the integer pointed to by 'ptr'
 / and return the result of the addition.
 /
--- a/pr/src/md/unix/os_SunOS_x86.s
+++ b/pr/src/md/unix/os_SunOS_x86.s
@@ -128,17 +128,16 @@ sol_curthread:
 /   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.
 /
--- a/pr/src/md/unix/os_SunOS_x86_64.s
+++ b/pr/src/md/unix/os_SunOS_x86_64.s
@@ -67,17 +67,16 @@
 / Atomically set the integer pointed to by 'val' to the new
 / value 'newval' and return the old value.
 /
     .text
     .globl _MD_AtomicSet
     .align 4
 _MD_AtomicSet:
     movl %esi, %eax
-    lock
     xchgl %eax, (%rdi)
     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.
 /
--- a/pr/src/md/windows/ntmisc.c
+++ b/pr/src/md/windows/ntmisc.c
@@ -769,17 +769,17 @@ PR_StackPush(PRStack *stack, PRStackElem
 #if defined(__GNUC__)
   void **tos = (void **) stack;
   void *tmp;
   
  retry:
   if (*tos == (void *) -1)
     goto retry;
   
-  __asm__("lock xchg %0,%1"
+  __asm__("xchg %0,%1"
           : "=r" (tmp), "=m"(*tos)
           : "0" (-1), "m"(*tos));
   
   if (tmp == (void *) -1)
     goto retry;
   
   *(void **)stack_elem = tmp;
   __asm__("" : : : "memory");
@@ -810,17 +810,17 @@ PR_StackPop(PRStack *stack)
 #if defined(__GNUC__)
   void **tos = (void **) stack;
   void *tmp;
   
  retry:
   if (*tos == (void *) -1)
     goto retry;
   
-  __asm__("lock xchg %0,%1"
+  __asm__("xchg %0,%1"
           : "=r" (tmp), "=m"(*tos)
           : "0" (-1), "m"(*tos));
 
   if (tmp == (void *) -1)
     goto retry;
   
   if (tmp != (void *) 0)
     {