On Mar 9, 2009, at 12:28 AM, Monty Taylor wrote:
it strikes me as odd, considering that most, if not all, modern
operating systems ship this kind of thing in libc. i might be missing
something, though (and am genuinely interested in what that might be,
since i'm working on lock-free data structures right now).
however, if the goal is to save you the ld stub call to libc and
inlining the assembly required, i can see the point.
It's not that implementations aren't all over the place (and I
certainly
don't mind link steps) - the real problem is finding standard
interfaces
for this stuff.
GCC atomics was a nice stop gap for dealing with that for us... except
it still isn't a win because we can't use GCC on Solaris. So what I
wound up doing is making a local impl of atomic<> for when one isn't
there already and filling in the impl with gcc atomics if we're on GCC
and atomic.h if we're on solaris. If all of the above fails, with
pthread locks. (eek)
If I'd known about 4.2 on OSX, I wouldn't have had to write the
pthread-lock implementation, since GCC4.0 on OSX was the only one that
wasn't covered by existing interfaces to system atomic behavior. In
fact
... I might be able to delete it now...
for reference: OS X has <libkern/OSAtomic.h> (don't be fooled by the
libkern in there, it's part of libc)
but yeah, if gcc implements them already, that's easier. wonder if
LLVM/gcc does the right thing and pulls them from gcc.
we are using glib's implementation right now, since i seriously don't
want to go hunting for this stuff on AIX and HP/UX,
plus it swaps in the pthread version if it has to punt. rather
convenient. you might want to take a look at that (gatomic.[ch] in
glib2).
These will pretty much be useful for decent interface to things like
counters and the like, I think... still working on it though.
under the covers it all boils down to a few primitives anyway, so
either API is fine with me :)
cheers,
-k
--
Kay Roepke
Software Engineer, MySQL Enterprise Tools
Sun Microsystems GmbH Sonnenallee 1, DE-85551 Kirchheim-Heimstetten
Geschaeftsfuehrer: Thomas Schroeder, Wolfang Engels, Dr. Roland Boemer
Vorsitz d. Aufs.rat.: Martin Haering HRB MUC 161028
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp