2018-06-26 19:03:42 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2020-03-30 06:28:32 +00:00
|
|
|
|
2018-06-26 19:03:42 +00:00
|
|
|
def supported(result):
|
2020-03-30 06:28:32 +00:00
|
|
|
return "supported" if result else "not supported"
|
2018-06-26 19:03:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
def check_cxx11_thread_local(conf):
|
2020-03-30 06:28:32 +00:00
|
|
|
print("Checking for `thread_local` support...", end=" ")
|
|
|
|
result = conf.TryCompile("thread_local int foo = 0; int main() { return foo; }", ".cpp")
|
2018-06-26 19:03:42 +00:00
|
|
|
print(supported(result))
|
|
|
|
return bool(result)
|
|
|
|
|
|
|
|
|
|
|
|
def check_declspec_thread(conf):
|
2020-03-30 06:28:32 +00:00
|
|
|
print("Checking for `__declspec(thread)` support...", end=" ")
|
|
|
|
result = conf.TryCompile("__declspec(thread) int foo = 0; int main() { return foo; }", ".cpp")
|
2018-06-26 19:03:42 +00:00
|
|
|
print(supported(result))
|
|
|
|
return bool(result)
|
|
|
|
|
|
|
|
|
|
|
|
def check_gcc___thread(conf):
|
2020-03-30 06:28:32 +00:00
|
|
|
print("Checking for `__thread` support...", end=" ")
|
|
|
|
result = conf.TryCompile("__thread int foo = 0; int main() { return foo; }", ".cpp")
|
2018-06-26 19:03:42 +00:00
|
|
|
print(supported(result))
|
|
|
|
return bool(result)
|
|
|
|
|
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
if check_cxx11_thread_local(conf):
|
2020-03-30 06:28:32 +00:00
|
|
|
conf.env.Append(CPPDEFINES=["HAVE_CXX11_THREAD_LOCAL"])
|
2018-06-26 19:03:42 +00:00
|
|
|
else:
|
|
|
|
if conf.env.msvc:
|
|
|
|
if check_declspec_thread(conf):
|
2020-03-30 06:28:32 +00:00
|
|
|
conf.env.Append(CPPDEFINES=["HAVE_DECLSPEC_THREAD"])
|
2018-06-26 19:03:42 +00:00
|
|
|
elif check_gcc___thread(conf):
|
2020-03-30 06:28:32 +00:00
|
|
|
conf.env.Append(CPPDEFINES=["HAVE_GCC___THREAD"])
|