Theo Schlossnagle wrote:
> 
> On May 18, 2006, at 11:56 AM, Bruce Momjian wrote:
> 
> > Theo Schlossnagle wrote:
> >>
> >> On May 17, 2006, at 8:30 PM, Bruce Momjian wrote:
> >>
> 
> [ snip ]
> 
> >>> OK, so what do you suggest?  Remove that URL from the comments?
> >>> Anything else?
> >>
> >> If you compile with -xarch=v8plus you should be able to omit the
> >> #ifdef's entirely.  The sparcv8plus and sparcv9 cas instruction are
> >> identical.  Is the goal here to support Sparc chips that do not
> >> support the v8plus instruction set?  I'm not on the ports list, so
> >> maybe I missed the original problem report.
> >
> > We don't actually know all the Solaris versions/hardware we should
> > support, so it is hard to say if we currently have running sparcv8  
> > CPUs.
> > The best solution is to use separate entries for v8 and v9.  Is  
> > there a
> > unique preprocessor symbol when a sparcv8plus binary is being  
> > generated?
> 
> Heh.. you could likely guess it:
> #if defined(__sparcv8plus)

Nice, comments and macro tests updated.  New version of file attached.

-- 
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
!=======================================================================
! solaris_sparc.s -- compare and swap for solaris_sparc
!=======================================================================

! 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
        ! requies 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
        !

#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
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to