Extra Zero/Shark patches for review

Greg Lewis glewis at eyesbeyond.com
Thu Nov 19 15:31:02 PST 2009


G'day Kurt,

On Wed, Nov 18, 2009 at 08:18:30AM -0500, Kurt Miller wrote:
> Greg Lewis wrote:
> > Anyway, I'm looking for alternatives before I breakdown and write
> > any assembler.  Any suggestions gratefully accepted.
> > 
> 
> On OpenBSD we continue to use gcc 3.x on most archs since 4.x is
> substantially slower on older and slower architectures (among other
> reasons). In the cases where custom asm has been written to support
> an arch I think we should use it and fall back to the gcc builtins
> if gcc is being used.
> 
> For example:
> 
> >  inline jint Atomic::add(jint add_value, volatile jint* dest) {
> > -#ifdef ARM
> > -  return arm_add_and_fetch(dest, add_value);
> > -#else
> > -#ifdef M68K
> > -  return m68k_add_and_fetch(dest, add_value);
> > -#else
> > -  return __sync_add_and_fetch(dest, add_value);
> > -#endif // M68K
> > -#endif // ARM
> > +  atomic_add_int((volatile u_int*) dest, add_value);
> > +  return *dest;
> >  }
> 
> Would look something like:
> 
> inline jint Atomic::add(jint add_value, volatile jint* dest) {
> #if defined(ARM)
>   return arm_add_and_fetch(dest, add_value);
> #elif defined(M68K)
>   return m68k_add_and_fetch(dest, add_value);
> #elif defined(__GNUC__)
>   #if defined (__GNUC_MINOR__) && ((4 < __GNUC__) || (4 == __GNUC__ && 1
> <= __GNUC_MINOR__))
>     return __sync_add_and_fetch(dest, add_value);
>   #else
>     atomic_add_int((volatile u_int*) dest, add_value);
>   #endif // GCC ver
> #else
>   #error "No atomic add implementation"
> #endif // GNUC
> 
> Does that sound reasonable?

I'm ok with that.  I'm just against us writing assembler for Zero without a
good reason.

BTW, is that GCC conditional correct?  It looks like you want to use
__sync_add_and_fetch if we're using <= gcc 4.1, but I didn't think
it was added until after that.

One other comment is IMHO that all those conditionals make the code harder to
read, which was one of the reasons I was thinking of just using the atomic*
functions.

-- 
Greg Lewis                          Email   : glewis at eyesbeyond.com
Eyes Beyond                         Web     : http://www.eyesbeyond.com
Information Technology              FreeBSD : glewis at FreeBSD.org



More information about the bsd-port-dev mailing list