Skip to content

Commit

Permalink
Merge pull request #2324 from leaf-potato/unittest
Browse files Browse the repository at this point in the history
Fix unit test running error under arch64
  • Loading branch information
Huixxi authored Jul 25, 2023
2 parents 92ad882 + 863476d commit e6881ee
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/butil/thread_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#endif // _MSC_VER

#define BAIDU_VOLATILE_THREAD_LOCAL(type, var_name, default_value) \
BAIDU_THREAD_LOCAL type var_name = default_value; \
BAIDU_THREAD_LOCAL type var_name = default_value; \
static __attribute__((noinline, unused)) type get_##var_name(void) { \
asm volatile(""); \
return var_name; \
Expand All @@ -46,10 +46,10 @@
var_name = v; \
}

#if defined(__clang__)
// Clang compiler is incorrectly caching the address of thread_local variables
// across a suspend-point. The following macros used to disable the volatile
// thread local access optimization.
#if (defined (__aarch64__) && defined (__GNUC__)) || defined(__clang__)
// GNU compiler under aarch and Clang compiler is incorrectly caching the
// address of thread_local variables across a suspend-point. The following
// macros used to disable the volatile thread local access optimization.
#define BAIDU_GET_VOLATILE_THREAD_LOCAL(var_name) get_##var_name()
#define BAIDU_GET_PTR_VOLATILE_THREAD_LOCAL(var_name) get_ptr_##var_name()
#define BAIDU_SET_VOLATILE_THREAD_LOCAL(var_name, value) set_##var_name(value)
Expand Down

0 comments on commit e6881ee

Please sign in to comment.