summaryrefslogtreecommitdiffstats
path: root/src/backend/port/tas
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/backend/port/tas/dummy.s0
-rw-r--r--src/backend/port/tas/hpux_hppa.s28
-rw-r--r--src/backend/port/tas/sunstudio_sparc.s53
-rw-r--r--src/backend/port/tas/sunstudio_x86.s43
4 files changed, 124 insertions, 0 deletions
diff --git a/src/backend/port/tas/dummy.s b/src/backend/port/tas/dummy.s
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/backend/port/tas/dummy.s
diff --git a/src/backend/port/tas/hpux_hppa.s b/src/backend/port/tas/hpux_hppa.s
new file mode 100644
index 0000000..d978a7c
--- /dev/null
+++ b/src/backend/port/tas/hpux_hppa.s
@@ -0,0 +1,28 @@
+
+ .SPACE $TEXT$,SORT=8
+ .SUBSPA $CODE$,QUAD=0,ALIGN=4,ACCESS=44,CODE_ONLY,SORT=24
+tas
+ .PROC
+ .CALLINFO CALLER,FRAME=0,ENTRY_SR=3
+ .ENTRY
+ LDO 15(%r26),%r31 ;offset 0x0
+ DEPI 0,31,4,%r31 ;offset 0x4
+ LDCWX 0(0,%r31),%r23 ;offset 0x8
+ COMICLR,= 0,%r23,%r0 ;offset 0xc
+ DEP,TR %r0,31,32,%r28 ;offset 0x10
+$00000001
+ LDI 1,%r28 ;offset 0x14
+$L0
+ .EXIT
+ BV,N %r0(%r2) ;offset 0x18
+ .PROCEND ;in=26;out=28;
+
+
+ .SPACE $TEXT$
+ .SUBSPA $CODE$
+ .SPACE $PRIVATE$,SORT=16
+ .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31,SORT=16
+ .SPACE $TEXT$
+ .SUBSPA $CODE$
+ .EXPORT tas,ENTRY,PRIV_LEV=3,ARGW0=GR,RTNVAL=GR
+ .END
diff --git a/src/backend/port/tas/sunstudio_sparc.s b/src/backend/port/tas/sunstudio_sparc.s
new file mode 100644
index 0000000..da9ed35
--- /dev/null
+++ b/src/backend/port/tas/sunstudio_sparc.s
@@ -0,0 +1,53 @@
+!-------------------------------------------------------------------------
+!
+! sunstudio_sparc.s
+! compare and swap for Sun Studio on Sparc
+!
+! Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
+! Portions Copyright (c) 1994, Regents of the University of California
+!
+! IDENTIFICATION
+! src/backend/port/tas/sunstudio_sparc.s
+!
+!-------------------------------------------------------------------------
+
+! Fortunately the Sun compiler can process cpp conditionals with -P
+
+! '/' is the comment for x86, while '!' is the comment for Sparc
+
+#if defined(__sparcv9) || defined(__sparc)
+
+ .section ".text"
+ .align 8
+ .skip 24
+ .align 4
+
+ .global pg_atomic_cas
+pg_atomic_cas:
+
+ ! "cas" only works on sparcv9 and sparcv8plus chips, and
+ ! requires a compiler targeting these CPUs. It will fail
+ ! on a compiler targeting sparcv8, and of course will not
+ ! be understood by a sparcv8 CPU. gcc continues to use
+ ! "ldstub" because it targets sparcv7.
+ !
+ ! There is actually a trick for embedding "cas" in a
+ ! sparcv8-targeted compiler, but it can only be run
+ ! on a sparcv8plus/v9 cpus:
+ !
+ ! http://cvs.opensolaris.org/source/xref/on/usr/src/lib/libc/sparc/threads/sparc.il
+ !
+ ! NB: We're assuming we're running on a TSO system here - solaris
+ ! userland luckily always has done so.
+
+#if defined(__sparcv9) || defined(__sparcv8plus)
+ cas [%o0],%o2,%o1
+#else
+ ldstub [%o0],%o1
+#endif
+ mov %o1,%o0
+ retl
+ nop
+ .type pg_atomic_cas,2
+ .size pg_atomic_cas,(.-pg_atomic_cas)
+#endif
diff --git a/src/backend/port/tas/sunstudio_x86.s b/src/backend/port/tas/sunstudio_x86.s
new file mode 100644
index 0000000..808b207
--- /dev/null
+++ b/src/backend/port/tas/sunstudio_x86.s
@@ -0,0 +1,43 @@
+/-------------------------------------------------------------------------
+/
+/ sunstudio_x86.s
+/ compare and swap for Sun Studio on x86
+/
+/ Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
+/ Portions Copyright (c) 1994, Regents of the University of California
+/
+/ IDENTIFICATION
+/ src/backend/port/tas/sunstudio_x86.s
+/
+/-------------------------------------------------------------------------
+
+/ Fortunately the Sun compiler can process cpp conditionals with -P
+
+/ '/' is the comment for x86, while '!' is the comment for Sparc
+
+ .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