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

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