Extra Zero/Shark patches for review

Christos Zoulas christos at zoulas.com
Thu Nov 19 15:44:02 PST 2009


On Nov 19,  3:31pm, glewis at eyesbeyond.com (Greg Lewis) wrote:
-- Subject: Re: Extra Zero/Shark patches for review

| 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.

FYI, I've gotten rid of all the ${MACHINE} conditionals in my
version of the code and this is what I am using now:

    http://www.zoulas.com/junk/atomic_bsd_zero.inline.hpp

So it turns out that NetBSD's atomic implementation (which is ~=
to Solaris) has all the necessary functions to implement the calls
directly without any glue. I just wrote macros/inlines for the
FreeBSD to supplement the functions where they were missing.

I don't think that the substitute functions (which I just copied
from the bodies of the original file) are safe, since they do
unlocked multiple accesses to the memory locations involved, so it
would be better to implement directly the atomic primitives. But
then again I did not look at them very hard.

MI:
    http://cvsweb.netbsd.org/bsdweb.cgi/src/common/lib/libc/atomic/
MD[arm]:
    http://cvsweb.netbsd.org/bsdweb.cgi/src/common/lib/libc/arch/arm/atomic/

Of course something needs to be done with 64 bit atomics on the 32
bit implementations that don't support them, but...

christos



More information about the bsd-port-dev mailing list