Assembly language implementation of PR_StackPush/Pop routines for Sparc/x86;
checkin for ppokorny@mindspring.com.
This commit is contained in:
Родитель
73a006aee8
Коммит
ad1084af52
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче