[cairo] Atomic reference counting

Chris Wilson chris at chris-wilson.co.uk
Tue Sep 25 02:16:09 PDT 2007


Behdad Esfahbod (behdad at behdad.org) said: 
> On Sun, 2007-09-23 at 22:14 +0100, Chris Wilson wrote:
> > 
> > +AC_ARG_ENABLE(atomics,
> > +  AS_HELP_STRING([--disable-atomics],
> > +                [Do not use atomic operations]),
> 
> Humm, what do you see as the usecase for this?  If we want to do
> something like this it should be like --disable-mt and imply NO_MUTEX
> too.

It was a debugging aid. Removed and added an informative
AC_MSG_CHECKING() ... AC_MSG_RESULT() instead.
 
 
> > +  [use_atomic=$enableval], [use_atomic=auto])
> > +if test "x$use_atomic" != "xno"; then
> > +    AC_TRY_COMPILE([int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); }], [],
> > +      AC_DEFINE(CAIRO_HAS_ATOMIC_OPS, 1, [Enable if your platform has native atomic operations])
> > +      AC_DEFINE(CAIRO_HAS_INTEL_ATOMIC_PRIMITIVES, 1, [Enable if your compiler supports the Intel __sync_* atomic primitives])
> 
> I was thinking about defining CAIRO_HAS_ATOMIC_OPS automatically in the
> header file based on whether any concrete implementation was found.  As
> in:
> 
> #define CAIRO_HAS_ATOMIC_OPS 1
> #if CAIRO_HAS_INTEL_ATOMIC_PRIMITIVES
> ...
> #elif CAIRO_HAS_SOMEOTHER_ATOMIC_PRIMITIES
> ...
> #else
> ...
> # undef CAIRO_HAS_ATOMIC_OPS
> #end
> 
> > +      )
> > +fi
> > + 

Done.
 
 
> The rest looks good.  Thanks.  Feel free to push.
Thanks for the feedback.
--
Chris Wilson


More information about the cairo mailing list