compat: use __atomic operations instead of __sync, when present

Some platforms (mips, powerpc, sparc) do not have __sync_add_and_fetch_8 as used by mpv, which means that mpv will fail to build on them. GCC 4.8 introduced the __atomic_* intrinsics, which will use the corresponding __sync_* operations when available, or fallback to the implementations provided by libatomic.

These patches add checks for libatomic and __atomic_* at build time, and make mpv use them if available.

Note that this will make mpv link to libatomic even on platforms where it isn't needed. My current lazy fix in the Debian package is to use `-Wl,--as-needed`, a more elegant solution may be possible with some waf magic though.

Also note that on platforms where GCC < 4.8 and __sync_add_and_fetch_8 is not available, mpv still fails (it works fine if GCC < 4.8 and __sync_add_and_fetch_8 is present though). A more general solution would be to hand-roll __sync_add_and_fetch_8 using a mutex or something like that, but it should probably be handled with care.