Fix undefined reference caused by wrong detection of gcc builtin atomic functions.
Merge pull request #2667 from ulion/fix_unreference_gcc_builtin_atomic_func

Fix undefined reference caused by wrong detection of gcc builtin atomic functions.