Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2019-04-24 07:21:05 +0300
committerEric Fiselier <eric@efcs.ca>2019-04-24 07:21:05 +0300
commit5a235865f7211563e69ba15d6d60aca9c3a20592 (patch)
treee2189165c5e768f1956044b9d091a8800e52173c /libcxxabi/src/cxa_guard_impl.h
parentb5f39845417560b7a54342dcb013af82f83567b2 (diff)
Cleanup new cxa guard implementation.
* Add TSAN annotations around the futex syscalls. * Test that the futex syscall wrappers actually work. * Fix bad names. llvm-svn: 359069
Diffstat (limited to 'libcxxabi/src/cxa_guard_impl.h')
-rw-r--r--libcxxabi/src/cxa_guard_impl.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/libcxxabi/src/cxa_guard_impl.h b/libcxxabi/src/cxa_guard_impl.h
index 8c31848625c4..ea82d2013315 100644
--- a/libcxxabi/src/cxa_guard_impl.h
+++ b/libcxxabi/src/cxa_guard_impl.h
@@ -70,6 +70,13 @@
# error "Either BUILDING_CXA_GUARD or TESTING_CXA_GUARD must be defined"
#endif
+#if __has_feature(thread_sanitizer)
+extern "C" void __tsan_acquire(void*);
+extern "C" void __tsan_release(void*);
+#else
+#define __tsan_acquire(addr) ((void)0)
+#define __tsan_release(addr) ((void)0)
+#endif
namespace __cxxabiv1 {
// Use an anonymous namespace to ensure that the tests and actual implementation
@@ -116,7 +123,7 @@ constexpr uint32_t (*PlatformThreadID)() = nullptr;
#endif
-constexpr bool DoesPlatformSupportThreadID() {
+constexpr bool PlatformSupportsThreadID() {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
@@ -265,7 +272,7 @@ struct InitByteGlobalMutex
explicit InitByteGlobalMutex(uint32_t *g)
: BaseT(g), has_thread_id_support(false) {}
explicit InitByteGlobalMutex(uint64_t *g)
- : BaseT(g), has_thread_id_support(DoesPlatformSupportThreadID()) {}
+ : BaseT(g), has_thread_id_support(PlatformSupportsThreadID()) {}
public:
AcquireResult acquire_init_byte() {
@@ -358,9 +365,11 @@ private:
void PlatformFutexWait(int* addr, int expect) {
constexpr int WAIT = 0;
syscall(SYS_futex, addr, WAIT, expect, 0);
+ __tsan_acquire(addr);
}
void PlatformFutexWake(int* addr) {
constexpr int WAKE = 1;
+ __tsan_release(addr);
syscall(SYS_futex, addr, WAKE, INT_MAX);
}
#else
@@ -368,7 +377,7 @@ constexpr void (*PlatformFutexWait)(int*, int) = nullptr;
constexpr void (*PlatformFutexWake)(int*) = nullptr;
#endif
-constexpr bool DoesPlatformSupportFutex() {
+constexpr bool PlatformSupportsFutex() {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
@@ -539,7 +548,7 @@ constexpr Implementation CurrentImplementation =
#endif
static_assert(CurrentImplementation != Implementation::Futex
- || DoesPlatformSupportFutex(), "Futex selected but not supported");
+ || PlatformSupportsFutex(), "Futex selected but not supported");
using SelectedImplementation =
SelectImplementation<CurrentImplementation>::type;