[Gc] Should libatomic_ops be inside bdwgc?

Petter Urkedal urkedal at nbi.dk
Thu Aug 11 00:04:24 PDT 2011

On 2011-08-10, Boehm, Hans wrote:
> Given that libatomic_ops is packaged separately, and seems to be
> generally available, I don't see a good reason for including it in the
> gc distribution anymore.  I agree that it seems increasingly strange
> to include it.  If we don't, we do need to make sure we still have
> simple build directions for Windows and MacOS etc., e.g. "plug the
> libatomic_ops tree or a link to it in here".

To make it really simple, we could add a script which fetches and
unpacks a suitable version of libatomic_ops into the current directory.
configure would point the user to the script if necessary.

> Hopefully we can arrange to make bdwgc buildable in single-threaded
> mode without libatomic_ops?  That's been a goal, but I'm not sure it's
> currently true.

I can see currently this is not the case.  To avoid littering the code
with "#ifdef"s, one could write a placement header which implements
the types and functions non-atomically, and add a suitable -I option
from configure when building for the single-threaded case.

> The libatomic_ops API should be stable at this point.  I would
> discourage major changes, since I think it's obsoleted by C++0x and
> C1x atomics, which can be viewed as another, much more careful,
> iteration on libatomic_ops.
> In the slightly longer term, bdwgc should also work with C++0x/C1x
> atomics instead of libatomic_ops.  In the even longer term, we should
> phase out libatomic_ops.  In the short term, we have too few
> implementations of the C++0x atomics, and they may still be too
> immature.

This is really good, as it will presumably be written by the compiler
writers.  I can see GCC already have experimental support.  I think it
usually takes some time before new C/C++ standards are widely adopted.
One possibility in the meantime is to make a thin wrapper within
"libatomic_ops" which defines all atomic types up to long and
"int_least32_t" as "struct { AO_t value; }" and implement the function
in terms of the corresponding libatomic_ops functions.

More information about the Gc mailing list