diff options
author | Robie Basak <robie.basak@canonical.com> | 2013-12-13 15:52:07 +0000 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2014-05-09 15:42:05 -0400 |
commit | 19cceceb780ab13104d5a4e44c373472ac5f430d (patch) | |
tree | ee23d4bbb5b672587760dcf258b433eeaff9c815 /SConstruct | |
parent | 677bd638dd2eb7f604fe09c61c5f7b9335510eee (diff) | |
download | mongo-19cceceb780ab13104d5a4e44c373472ac5f430d.tar.gz |
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>
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct index 2d7e9a2b4a5..5c7c664bd5e 100644 --- a/SConstruct +++ b/SConstruct @@ -1431,6 +1431,30 @@ def doConfigure(myenv): if haveUUThread: myenv.Append(CPPDEFINES=['MONGO_HAVE___THREAD']) + if using_gcc() or using_clang(): + def CheckGCCAtomicBuiltins(context): + test_body = """ + int main(int argc, char **argv) { + int a = 0; + int b = 0; + int c = 0; + + __atomic_compare_exchange(&a, &b, &c, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); + return 0; + } + """ + context.Message('Checking for gcc atomic builtins... ') + ret = context.TryLink(textwrap.dedent(test_body), '.cpp') + context.Result(ret) + return ret + conf = Configure(myenv, help=False, custom_tests = { + 'CheckGCCAtomicBuiltins': CheckGCCAtomicBuiltins, + }) + haveGCCAtomicBuiltins = conf.CheckGCCAtomicBuiltins() + conf.Finish() + if haveGCCAtomicBuiltins: + conf.env.Append(CPPDEFINES=["HAVE_GCC_ATOMIC_BUILTINS"]) + conf = Configure(myenv) libdeps.setup_conftests(conf) |