mirror of https://github.com/postgres/postgres
assembler files, renamed as solaris_x86.s. Theo SchlossnagleREL8_2_STABLE
parent
4ade4fe422
commit
128bed948f
@ -1,33 +0,0 @@ |
||||
/============================================================================= |
||||
/ tas.s -- test and set lock for solaris_i386 |
||||
/============================================================================= |
||||
|
||||
.file "tas.s" |
||||
.text |
||||
.align 16
|
||||
.L1.text: |
||||
|
||||
.globl tas
|
||||
tas: |
||||
pushl %ebp /save prev base pointer |
||||
movl %esp,%ebp /new base pointer |
||||
pushl %ebx /save prev bx |
||||
movl 8(%ebp),%ebx /load bx with address of lock |
||||
movl $255,%eax /put something in ax |
||||
xchgb %al,(%ebx) /swap lock value with "0" |
||||
cmpb $0,%al /did we get the lock? |
||||
jne .Locked |
||||
subl %eax,%eax /yes, we got it -- return 0 |
||||
jmp .Finish |
||||
.align 4
|
||||
.Locked: |
||||
movl $1,%eax /no, we didn't get it - return 1 |
||||
.Finish: |
||||
popl %ebx /restore prev bx |
||||
movl %ebp,%esp /restore stack state |
||||
popl %ebp |
||||
ret /return |
||||
.align 4
|
||||
.type tas,@function
|
||||
.size tas,.-tas |
||||
|
||||
@ -1,50 +1,20 @@ |
||||
!! |
||||
!! $PostgreSQL: pgsql/src/backend/port/tas/solaris_sparc.s,v 1.2 2003/11/29 19:51:54 pgsql Exp $ |
||||
!! |
||||
!! this would be a piece of inlined assembler but it appears |
||||
!! to be easier to just write the assembler than to try to
|
||||
!! figure out how to make sure that in/out registers are kept |
||||
!! straight in the asm's. |
||||
!! |
||||
.file "tas.c" |
||||
.section ".text" |
||||
.align 4
|
||||
.global tas
|
||||
.type tas,#function |
||||
.proc 04
|
||||
tas: |
||||
!! |
||||
!! this is a leaf procedure - no need to save windows and
|
||||
!! diddle the CWP. |
||||
!! |
||||
!#PROLOGUE# 0 |
||||
!#PROLOGUE# 1 |
||||
|
||||
!! |
||||
!! write 0xFF into the lock address, saving the old value in %o0. |
||||
!! this is an atomic action, even on multiprocessors. |
||||
!! |
||||
ldstub [%o0],%o0 |
||||
|
||||
!! |
||||
!! if it was already set when we set it, somebody else already |
||||
!! owned the lock -- return 1. |
||||
!! |
||||
cmp %o0,0 |
||||
bne .LL2 |
||||
mov 1,%o0 |
||||
|
||||
!! |
||||
!! otherwise, it was clear and we now own the lock -- return 0. |
||||
!! |
||||
mov 0,%o0 |
||||
.LL2: |
||||
!! |
||||
!! this is a leaf procedure - no need to restore windows and
|
||||
!! diddle the CWP. |
||||
!! |
||||
retl |
||||
nop |
||||
.LLfe1: |
||||
.size tas,.LLfe1-tas |
||||
.ident "GCC: (GNU) 2.5.8" |
||||
/======================================================================= |
||||
/ solaris_sparc.s -- compare and swap for solaris_sparc |
||||
/======================================================================= |
||||
|
||||
#if defined(__sparcv9) || defined(__sparc) |
||||
|
||||
.section ".text" |
||||
.align 8
|
||||
.skip 24
|
||||
.align 4
|
||||
|
||||
.global pg_atomic_cas
|
||||
pg_atomic_cas: |
||||
cas [%o0],%o2,%o1 |
||||
mov %o1,%o0 |
||||
retl |
||||
nop |
||||
.type pg_atomic_cas,2 |
||||
.size pg_atomic_cas,(.-pg_atomic_cas) |
||||
#endif |
||||
|
||||
@ -0,0 +1,32 @@ |
||||
/======================================================================= |
||||
/ solaris_i386.s -- compare and swap for solaris_i386 |
||||
/======================================================================= |
||||
|
||||
/ Fortunately the Sun compiler understands cpp conditionals |
||||
|
||||
.file "tas.s" |
||||
|
||||
#if defined(__amd64) |
||||
.code64 |
||||
#endif |
||||
|
||||
.globl pg_atomic_cas
|
||||
.type pg_atomic_cas, @function
|
||||
|
||||
.section .text, "ax" |
||||
.align 16
|
||||
|
||||
pg_atomic_cas: |
||||
#if defined(__amd64) |
||||
movl %edx,%eax |
||||
lock |
||||
cmpxchgl %esi,(%rdi) |
||||
#else |
||||
movl 4(%esp), %edx |
||||
movl 8(%esp), %ecx |
||||
movl 12(%esp), %eax |
||||
lock |
||||
cmpxchgl %ecx, (%edx) |
||||
#endif |
||||
ret |
||||
.size pg_atomic_cas, . - pg_atomic_cas |
||||
@ -1,38 +0,0 @@ |
||||
/============================================================================= |
||||
/ tas.s -- test and set lock for solaris_i386 |
||||
/ based on i386 ASM with modifications outlined in: |
||||
/ http://www.x86-64.org/documentation/assembly. |
||||
/ This might require flags: -xtarget=opteron -xarch=amd64 |
||||
/ DB optimization documenation at: |
||||
/ http://developers.sun.com/solaris/articles/mysql_perf_tune.html |
||||
/============================================================================= |
||||
|
||||
.file "tas.s" |
||||
.text |
||||
.align 16
|
||||
.L1.text: |
||||
|
||||
.globl tas
|
||||
tas: |
||||
pushq %rbp /save prev base pointer |
||||
movq %rsp,%rbp /new base pointer |
||||
pushq %rbx /save prev bx |
||||
movq 8(%rbp),%rbx /load bx with address of lock |
||||
movq $255,%rax /put something in ax |
||||
xchgb %al,(%rbx) /swap lock value with "0" |
||||
cmpb $0,%al /did we get the lock? |
||||
jne .Locked |
||||
subq %rax,%rax /yes, we got it -- return 0 |
||||
jmp .Finish |
||||
.align 8
|
||||
.Locked: |
||||
movq $1,%rax /no, we didn't get it - return 1 |
||||
.Finish: |
||||
popq %rbx /restore prev bx |
||||
movq %rbp,%rsp /restore stack state |
||||
popq %rbp |
||||
ret /return |
||||
.align 8
|
||||
.type tas,@function
|
||||
.size tas,.-tas |
||||
|
||||
Loading…
Reference in new issue