Index: src/backend/port/tas/solaris_sparc.s
===================================================================
RCS file: /cvsroot/pgsql/src/backend/port/tas/solaris_sparc.s,v
retrieving revision 1.2
diff -c -c -r1.2 solaris_sparc.s
*** src/backend/port/tas/solaris_sparc.s	29 Nov 2003 19:51:54 -0000	1.2
--- src/backend/port/tas/solaris_sparc.s	27 Apr 2006 21:56:32 -0000
***************
*** 1,50 ****
! 	!!
! 	!! $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"
--- 1,20 ----
! /=======================================================================
! / 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
Index: src/include/storage/s_lock.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/storage/s_lock.h,v
retrieving revision 1.149
diff -c -c -r1.149 s_lock.h
*** src/include/storage/s_lock.h	19 Apr 2006 23:11:15 -0000	1.149
--- src/include/storage/s_lock.h	27 Apr 2006 21:56:37 -0000
***************
*** 763,785 ****
  #endif
  
  
! #if defined(__sparc__) || defined(__sparc)
  #define HAS_TEST_AND_SET
- 
  typedef unsigned char slock_t;
- #endif
- 
- 
- /* out-of-line assembler from src/backend/port/tas/foo.s */
  
! /* i386/X86_64 using Sun compiler */
! #if defined(__sun) && (defined(__i386) || defined(__x86_64__)) 
! /*
!  * Solaris/386 (we only get here for non-gcc case)
!  */
! #define HAS_TEST_AND_SET
  
! typedef unsigned char slock_t;
  #endif
  
  
--- 763,776 ----
  #endif
  
  
! #if defined(__sun) && (defined(__i386) || defined(__x86_64__) || defined(__sparc__) || defined(__sparc))
  #define HAS_TEST_AND_SET
  typedef unsigned char slock_t;
  
! extern volatile slock_t pg_atomic_cas(volatile slock_t *lock, slock_t with,
! 									  slock_t cmp);
  
! #define TAS(a) (pg_atomic_cas((a), 1, 0) != 0)
  #endif
  
  
Index: src/template/solaris
===================================================================
RCS file: /cvsroot/pgsql/src/template/solaris,v
retrieving revision 1.25
diff -c -c -r1.25 solaris
*** src/template/solaris	2 Jan 2006 03:30:41 -0000	1.25
--- src/template/solaris	27 Apr 2006 21:56:38 -0000
***************
*** 4,32 ****
    if test "$enable_debug" != yes; then
      CFLAGS="$CFLAGS -O"		# any optimization breaks debug
    fi
! fi
! 
! # Pick right test-and-set (TAS) code.  We need out-of-line assembler
! # when not using gcc.
! case $host in
!   sparc-*-solaris*)
! 	if test "$GCC" != yes ; then
! 		need_tas=yes
! 		tas_file=solaris_sparc.s
! 	fi
      ;;
!   i?86-*-solaris*)
! 	if test "$GCC" != yes ; then
! 		if isainfo | grep amd64
! 		then
! 			need_tas=yes
! 			tas_file=solaris_x86_64.s
! 		else
! 			need_tas=yes
! 			tas_file=solaris_i386.s
! 		fi
! 	fi
      ;;
! esac
  
  # -D_POSIX_PTHREAD_SEMANTICS enables 5-arg getpwuid_r, among other things
--- 4,24 ----
    if test "$enable_debug" != yes; then
      CFLAGS="$CFLAGS -O"		# any optimization breaks debug
    fi
! else
!   # Pick the right test-and-set (TAS) code for the Sun compiler.
!   # We would like to use in-line assembler, but the compiler
!   # requires *.il files to be on every compile line, making 
!   # the build system too fragile.
!   case $host in
!     sparc-*-solaris*)
! 	need_tas=yes
! 	tas_file=solaris_sparc.s
      ;;
!     i?86-*-solaris*)
! 	need_tas=yes
! 	tas_file=solaris_x86.s
      ;;
!   esac
! fi
  
  # -D_POSIX_PTHREAD_SEMANTICS enables 5-arg getpwuid_r, among other things
