threads: add a thread_local autoconf check
(cherry picked from commit bitcoin/bitcoin@f7f7e2cd34)
This commit is contained in:
parent
4ad38a45e5
commit
f1c166d3db
23
configure.ac
23
configure.ac
|
@ -702,6 +702,29 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([
|
|||
]
|
||||
)
|
||||
|
||||
TEMP_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$TEMP_LDFLAGS $PTHREAD_CFLAGS"
|
||||
AC_MSG_CHECKING([for thread_local support])
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([
|
||||
#include <thread>
|
||||
static thread_local int foo = 0;
|
||||
static void run_thread() { foo++;}
|
||||
int main(){
|
||||
for(int i = 0; i < 10; i++) { std::thread(run_thread).detach();}
|
||||
return foo;
|
||||
}
|
||||
])],
|
||||
[
|
||||
AC_DEFINE(HAVE_THREAD_LOCAL,1,[Define if thread_local is supported.])
|
||||
AC_MSG_RESULT(yes)
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT(no)
|
||||
]
|
||||
)
|
||||
LDFLAGS="$TEMP_LDFLAGS"
|
||||
|
||||
# Check for reduced exports
|
||||
if test x$use_reduce_exports = xyes; then
|
||||
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"],
|
||||
[AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduce-exports.])])
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#ifdef DEBUG_LOCKCONTENTION
|
||||
#if !defined(HAVE_THREAD_LOCAL)
|
||||
static_assert(false, "thread_local is not supported");
|
||||
#endif
|
||||
void PrintLockContention(const char* pszName, const char* pszFile, int nLine)
|
||||
{
|
||||
LogPrintf("LOCKCONTENTION: %s\n", pszName);
|
||||
|
|
Loading…
Reference in New Issue