Comment from Lennart Poettering:
5) Atomic.h should be updated to make use of the gcc sync builtins
when available. They are nowadays supported on almost all archs and
support the full set of atomic ops. If you have them then you don't
need implement those operations manually based on the CAS. I have
seen that you currently use sync_bool_compare_and_swap() as a
fallback. But it should be the first choice nowadays. Both PA and
glib have been using sync now for a while and by default. While we
initially had problems with some of the code generated this has long
been fixed since then in gcc.