SERVER-12064 SERVER-12283 Use gcc atomic builtins if available

Switch to using gcc atomic builtins for atomic operations if using a new
enough gcc and clang and support is available. Otherwise, fall back to
the old behaviour of existing non-portable inline assembly to continue
to support builds on older versions of gcc.

Signed-off-by: Benety Goh <benety@mongodb.com>