diff options
author | srinivas%netscape.com <devnull@localhost> | 1999-07-27 14:40:44 +0000 |
---|---|---|
committer | srinivas%netscape.com <devnull@localhost> | 1999-07-27 14:40:44 +0000 |
commit | 32236378cebc6b126c31360a7ec877f0994c55a8 (patch) | |
tree | 724d88d9abca864cca618890efbd67522b45cfc8 | |
parent | 53fa0c0811a874c35c2ce85f976deb496f6d2ce1 (diff) | |
download | nspr-hg-32236378cebc6b126c31360a7ec877f0994c55a8.tar.gz |
Assembly language implementation of PR_StackPush/Pop routines for Sparc/x86;PRE_NECKO_LANDING_M9_MidLifeCrisis_19990728_BASE
checkin for ppokorny@mindspring.com.
-rw-r--r-- | pr/include/md/_solaris.h | 6 | ||||
-rw-r--r-- | pr/src/md/unix/os_SunOS_x86.s | 79 |
2 files changed, 79 insertions, 6 deletions
diff --git a/pr/include/md/_solaris.h b/pr/include/md/_solaris.h index 9b92add8..467607ce 100644 --- a/pr/include/md/_solaris.h +++ b/pr/include/md/_solaris.h @@ -48,14 +48,8 @@ #undef _PR_HAVE_ATOMIC_OPS #else #define _PR_HAVE_ATOMIC_OPS -/* - * We have assembly language implementation of atomic - * stacks for the sparc architecture only. - */ -#ifdef sparc #define _PR_HAVE_ATOMIC_CAS #endif -#endif #define _PR_POLL_AVAILABLE #define _PR_USE_POLL diff --git a/pr/src/md/unix/os_SunOS_x86.s b/pr/src/md/unix/os_SunOS_x86.s index 83537a62..0d609340 100644 --- a/pr/src/md/unix/os_SunOS_x86.s +++ b/pr/src/md/unix/os_SunOS_x86.s @@ -58,3 +58,82 @@ sol_getsp: sol_curthread: movl %ecx, %eax ret + +/ +/ PR_StackPush(listp, elementp) +/ +/ Atomically push ElementP onto linked list ListP. +/ + .text + .globl PR_StackPush + .align 4 +PR_StackPush: + movl 4(%esp), %ecx + movl $-1,%eax +pulock: +/ Already locked? + cmpl %eax,(%ecx) + je pulock + +/ Attempt to lock it + lock + xchgl %eax, (%ecx) + +/ Did we set the lock? + cmpl $-1, %eax + je pulock + +/ We now have the lock. Update pointers + movl 8(%esp), %edx + movl %eax, (%edx) + movl %edx, (%ecx) + +/ Done + ret + + +/ +/ elementp = PR_StackPop(listp) +/ +/ Atomically pop ElementP off linked list ListP +/ + .text + .globl PR_StackPop + .align 4 +PR_StackPop: + movl 4(%esp), %ecx + movl $-1, %eax +polock: +/ Already locked? + cmpl %eax, (%ecx) + je polock + +/ Attempt to lock it + lock + xchgl %eax, (%ecx) + +/ Did we set the lock? + cmpl $-1, %eax + je polock + +/ We set the lock so now update pointers + +/ Was it empty? + movl $0, %edx + cmpl %eax,%edx + je empty + +/ Get element "next" pointer + movl (%eax), %edx + +/ Write NULL to the element "next" pointer + movl $0, (%eax) + +empty: +/ Put elements previous "next" value into listp +/ NOTE: This also unlocks the listp + movl %edx, (%ecx) + +/ Return previous listp value (already in eax) + ret + |