Skip to content

Add support for C11 atomics

Adrian Johnson requested to merge ajohnson/cairo:c11-atomics into master

This adds support for C11 atomics which should make the code more portable. The HAVE_CXX11_ATOMIC_PRIMITIVES are gcc builtins.

The existing atomics code was sloppy with the cairo_atomic_int_t type, using it as the get/set value of an atomic. C11 atomics does not allow this so I have fixed up all the cairo_atomic_int_t atomics to use int for the get or set type.

One potential problem is the _cairo_status_set_error macro assumes an int * can be cast to cairo_atomic_int_t *. Most of the time this should work. I added an assert to the C11 meson check to ensure only lock free C11 atomics are permitted which together with the sizeof check in the macro should ensure the cast in the macro is safe.

I've added a meson warning if no atomic support is found. I would like to make atomic support mandatory for cairo 1.20 and maybe drop the CXX11 and gcc legacy atomics as by then gcc/clang C11 atomic support will be > 10 years old.

Merge request reports