Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit128bed9

Browse files
committed
Rewrite Solaris compiler tas() assembly routines, merge i386 and x86_64
assembler files, renamed as solaris_x86.s.Theo Schlossnagle
1 parent4ade4fe commit128bed9

File tree

6 files changed

+71
-157
lines changed

6 files changed

+71
-157
lines changed

‎src/backend/port/tas/solaris_i386.s

Lines changed: 0 additions & 33 deletions
This file was deleted.

‎src/backend/port/tas/solaris_sparc.s

Lines changed: 20 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,20 @@
1-
!!
2-
!!$PostgreSQL: pgsql/src/backend/port/tas/solaris_sparc.s,v1.22003/11/2919:51:54 pgsql Exp $
3-
!!
4-
!! this would be a piece of inlined assembler but it appears
5-
!! to be easier to just write the assembler than to try to
6-
!! figureout how to make sure thatin/out registers are kept
7-
!! straightin the asm's.
8-
!!
9-
.file"tas.c"
10-
.section".text"
11-
.align4
12-
.globaltas
13-
.type tas,#function
14-
.proc04
15-
tas:
16-
!!
17-
!! this is a leaf procedure- no need to save windowsand
18-
!! diddle the CWP.
19-
!!
20-
!#PROLOGUE#0
21-
!#PROLOGUE#1
22-
23-
!!
24-
!! write0xFFinto thelock address, saving the old valuein %o0.
25-
!! this is an atomic action, even on multiprocessors.
26-
!!
27-
ldstub[%o0],%o0
28-
29-
!!
30-
!! if it was already set when we set it, somebody else already
31-
!! owned thelock-- return1.
32-
!!
33-
cmp %o0,0
34-
bne .LL2
35-
mov1,%o0
36-
37-
!!
38-
!! otherwise, it was clearand we now own thelock-- return0.
39-
!!
40-
mov0,%o0
41-
.LL2:
42-
!!
43-
!! this is a leaf procedure- no need to restore windowsand
44-
!! diddle the CWP.
45-
!!
46-
retl
47-
nop
48-
.LLfe1:
49-
.size tas,.LLfe1-tas
50-
.ident"GCC: (GNU) 2.5.8"
1+
/=======================================================================
2+
/ solaris_sparc.s -- compare and swap for solaris_sparc
3+
/=======================================================================
4+
5+
#if defined(__sparcv9) || defined(__sparc)
6+
7+
.section".text"
8+
.align8
9+
.skip24
10+
.align4
11+
12+
.global pg_atomic_cas
13+
pg_atomic_cas:
14+
cas [%o0],%o2,%o1
15+
mov %o1,%o0
16+
retl
17+
nop
18+
.type pg_atomic_cas,2
19+
.size pg_atomic_cas,(.-pg_atomic_cas)
20+
#endif

‎src/backend/port/tas/solaris_x86.s

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/=======================================================================
2+
/ solaris_i386.s -- compare and swap for solaris_i386
3+
/=======================================================================
4+
5+
/ Fortunately the Sun compiler understands cpp conditionals
6+
7+
.file"tas.s"
8+
9+
#if defined(__amd64)
10+
.code64
11+
#endif
12+
13+
.globl pg_atomic_cas
14+
.type pg_atomic_cas,@function
15+
16+
.section.text,"ax"
17+
.align16
18+
19+
pg_atomic_cas:
20+
#if defined(__amd64)
21+
movl%edx,%eax
22+
lock
23+
cmpxchgl%esi,(%rdi)
24+
#else
25+
movl4(%esp),%edx
26+
movl8(%esp),%ecx
27+
movl12(%esp),%eax
28+
lock
29+
cmpxchgl%ecx, (%edx)
30+
#endif
31+
ret
32+
.size pg_atomic_cas, . - pg_atomic_cas

‎src/backend/port/tas/solaris_x86_64.s

Lines changed: 0 additions & 38 deletions
This file was deleted.

‎src/include/storage/s_lock.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
6767
* Portions Copyright (c) 1994, Regents of the University of California
6868
*
69-
* $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.149 2006/04/19 23:11:15 tgl Exp $
69+
* $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.150 2006/04/27 22:28:42 momjian Exp $
7070
*
7171
*-------------------------------------------------------------------------
7272
*/
@@ -763,23 +763,14 @@ typedef unsigned char slock_t;
763763
#endif
764764

765765

766-
#if defined(__sparc__)|| defined(__sparc)
766+
#if defined(__sun)&& (defined(__i386)|| defined(__x86_64__)|| defined(__sparc__)|| defined(__sparc))
767767
#defineHAS_TEST_AND_SET
768-
769768
typedefunsignedcharslock_t;
770-
#endif
771-
772-
773-
/* out-of-line assembler from src/backend/port/tas/foo.s */
774769

775-
/* i386/X86_64 using Sun compiler */
776-
#if defined(__sun)&& (defined(__i386)|| defined(__x86_64__))
777-
/*
778-
* Solaris/386 (we only get here for non-gcc case)
779-
*/
780-
#defineHAS_TEST_AND_SET
770+
externvolatileslock_tpg_atomic_cas(volatileslock_t*lock,slock_twith,
771+
slock_tcmp);
781772

782-
typedefunsignedcharslock_t;
773+
#defineTAS(a) (pg_atomic_cas((a), 1, 0) != 0)
783774
#endif
784775

785776

‎src/template/solaris

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,21 @@ if test "$GCC" != yes ; then
44
if test "$enable_debug" != yes; then
55
CFLAGS="$CFLAGS -O"# any optimization breaks debug
66
fi
7-
fi
8-
9-
# Pick right test-and-set (TAS) code. We need out-of-line assembler
10-
# when not using gcc.
11-
case $host in
12-
sparc-*-solaris*)
13-
if test "$GCC" != yes ; then
14-
need_tas=yes
15-
tas_file=solaris_sparc.s
16-
fi
7+
else
8+
# Pick the right test-and-set (TAS) code for the Sun compiler.
9+
# We would like to use in-line assembler, but the compiler
10+
# requires *.il files to be on every compile line, making
11+
# the build system too fragile.
12+
case $host in
13+
sparc-*-solaris*)
14+
need_tas=yes
15+
tas_file=solaris_sparc.s
1716
;;
18-
i?86-*-solaris*)
19-
if test "$GCC" != yes ; then
20-
if isainfo | grep amd64
21-
then
22-
need_tas=yes
23-
tas_file=solaris_x86_64.s
24-
else
25-
need_tas=yes
26-
tas_file=solaris_i386.s
27-
fi
28-
fi
17+
i?86-*-solaris*)
18+
need_tas=yes
19+
tas_file=solaris_x86.s
2920
;;
30-
esac
21+
esac
22+
fi
3123

3224
# -D_POSIX_PTHREAD_SEMANTICS enables 5-arg getpwuid_r, among other things

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp