summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pr/include/md/_solaris.h6
-rw-r--r--pr/src/md/unix/os_SunOS_x86.s79
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
+