1
1

opal/thread: Added keyword opal_thread_local for TLS.

configure: add checks for `__thread` on top of current check for `_Thread_local` and define OPAL_HAVE_THREAD_LOCAL if the compiler support TLS.

Added `opal_thread_local` keyword to unify the definition.

Signed-off-by: Thananon Patinyasakdikul <thananon.patinyasakdikul@intel.com>
Этот коммит содержится в:
Thananon Patinyasakdikul 2018-06-14 12:14:30 -07:00
родитель f9bfb9d239
Коммит 469a404c3b
2 изменённых файлов: 22 добавлений и 1 удалений

Просмотреть файл

@ -46,7 +46,7 @@ AC_DEFUN([OPAL_PROG_CC_C11_HELPER],[
opal_prog_cc_c11_helper_CFLAGS_save=$CFLAGS opal_prog_cc_c11_helper_CFLAGS_save=$CFLAGS
CFLAGS="$CFLAGS $1" CFLAGS="$CFLAGS $1"
OPAL_CC_HELPER([if $CC $1 supports C11 thread local storage], [opal_prog_cc_c11_helper__Thread_local_available], OPAL_CC_HELPER([if $CC $1 supports C11 _Thread_local], [opal_prog_cc_c11_helper__Thread_local_available],
[],[[static _Thread_local int foo = 1;++foo;]], [OPAL_C_HAVE__THREAD_LOCAL], [],[[static _Thread_local int foo = 1;++foo;]], [OPAL_C_HAVE__THREAD_LOCAL],
[Whether C compiler supports __Thread_local]) [Whether C compiler supports __Thread_local])
@ -160,6 +160,13 @@ AC_DEFUN([OPAL_SETUP_CC],[
OPAL_PROG_CC_C11_HELPER([],[],[]) OPAL_PROG_CC_C11_HELPER([],[],[])
fi fi
# Check if compiler support __thread
OPAL_VAR_SCOPE_PUSH([opal_prog_cc__thread_available])
OPAL_CC_HELPER([if $CC $1 supports __thread], [opal_prog_cc__thread_available],
[],[[static __thread int foo = 1;++foo;]], [OPAL_C_HAVE___THREAD],
[Whether C compiler supports __thread])
OPAL_VAR_SCOPE_POP
OPAL_C_COMPILER_VENDOR([opal_c_vendor]) OPAL_C_COMPILER_VENDOR([opal_c_vendor])
# Check for standard headers, needed here because needed before # Check for standard headers, needed here because needed before

Просмотреть файл

@ -249,4 +249,18 @@ OPAL_THREAD_DEFINE_ATOMIC_SWAP(int64_t, int64_t, 64)
#endif #endif
/* thread local storage */
#if OPAL_C_HAVE__THREAD_LOCAL
#define opal_thread_local _Thread_local
#define OPAL_HAVE_THREAD_LOCAL 1
#elif OPAL_C_HAVE___THREAD /* OPAL_C_HAVE__THREAD_LOCAL */
#define opal_thread_local __thread
#define OPAL_HAVE_THREAD_LOCAL 1
#endif /* OPAL_C_HAVE___THREAD */
#if !defined(OPAL_HAVE_THREAD_LOCAL)
#define OPAL_HAVE_THREAD_LOCAL 0
#endif /* !defined(OPAL_HAVE_THREAD_LOCAL) */
#endif /* !defined(OPAL_THREAD_USAGE_H) */ #endif /* !defined(OPAL_THREAD_USAGE_H) */