[cairo] Atomic reference counting

Chris Wilson chris at chris-wilson.co.uk
Thu Apr 5 01:00:26 PDT 2007


Carl Worth (cworth at cworth.org) said: 
> This is actually a small problem.
> 
> Cairo's license is both the LGPL and the MPL, so adding this code as
> is would make cairo not usable under the MPL anymore.
Sorry, that was my naivety wrt the licensing.
 
> Solutions could be to find the equivalent code elsewhere, (one of the
> BSDs perhaps?), to determine that it could only be implemented one
> way anyway, so there's not any copyright concern, or to just ask
> Sebastian if he would relicense the code as LGPL+MPL.
> 
> On this second point, from a quick glance the glib stuff looks
> overengineered compared to what cairo actually needs. I haven't looked
> closely, but are you really using all of that for what cairo needs?

No, we minimally need routines for an atomic inc and an atomic
dec-and-test. As has been suggested on IRC, gcc provides builtins which
are available across most of gcc's supported architectures.

My plan for the next iteration:
1) typedef struct _cairo_ref { unsigned int ref_count; } cairo_ref_t
2) implement a minimal cairo-atomic.[ch] (using gcc + mutex fallback)
3) introduce struct _cairo_object { ref_count, status, user_data};
--
Chris Wilson


More information about the cairo mailing list