aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt/test
diff options
context:
space:
mode:
authorJulian Lettner <jlettner@apple.com>2019-04-20 00:18:44 +0000
committerJulian Lettner <jlettner@apple.com>2019-04-20 00:18:44 +0000
commit4d2b9426b99f1d6d4d4b168a3133124ea85da7ea (patch)
tree492d9e2f1fd683650f59320fb3367d8b86b3dfda /compiler-rt/test
parentfe8aabf9d9164ac52e7352506ef56f4d7724f766 (diff)
downloadllvm-4d2b9426b99f1d6d4d4b168a3133124ea85da7ea.zip
llvm-4d2b9426b99f1d6d4d4b168a3133124ea85da7ea.tar.gz
llvm-4d2b9426b99f1d6d4d4b168a3133124ea85da7ea.tar.bz2
[TSan] Support fiber API on macOS
Committing on behalf of Yuri Per (yuri). Reviewers: dvyukov, kubamracek, yln Reviewed By: kubamracek Authored By: yuri Differential Revision: https://reviews.llvm.org/D58110 llvm-svn: 358802
Diffstat (limited to 'compiler-rt/test')
-rw-r--r--compiler-rt/test/lsan/TestCases/swapcontext.cc7
-rw-r--r--compiler-rt/test/sanitizer_common/sanitizer_ucontext.h11
-rw-r--r--compiler-rt/test/tsan/fiber_asm.cc10
-rw-r--r--compiler-rt/test/tsan/fiber_from_thread.cc4
-rw-r--r--compiler-rt/test/tsan/fiber_longjmp.cc4
-rw-r--r--compiler-rt/test/tsan/fiber_race.cc4
-rw-r--r--compiler-rt/test/tsan/fiber_simple.cc4
-rw-r--r--compiler-rt/test/tsan/fiber_two_threads.cc4
-rw-r--r--compiler-rt/test/tsan/test.h6
9 files changed, 33 insertions, 21 deletions
diff --git a/compiler-rt/test/lsan/TestCases/swapcontext.cc b/compiler-rt/test/lsan/TestCases/swapcontext.cc
index 9774f6c..afce8d9 100644
--- a/compiler-rt/test/lsan/TestCases/swapcontext.cc
+++ b/compiler-rt/test/lsan/TestCases/swapcontext.cc
@@ -6,13 +6,8 @@
// RUN: %env_lsan_opts= not %run %t foo 2>&1 | FileCheck %s
// UNSUPPORTED: arm,powerpc64
+#include "sanitizer_common/sanitizer_ucontext.h"
#include <stdio.h>
-#if defined(__APPLE__)
-// Note: ucontext.h is deprecated on OSX, so this test may stop working
-// someday. We define _XOPEN_SOURCE to keep using ucontext.h for now.
-#define _XOPEN_SOURCE 1
-#endif
-#include <ucontext.h>
#include <unistd.h>
const int kStackSize = 1 << 20;
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_ucontext.h b/compiler-rt/test/sanitizer_common/sanitizer_ucontext.h
new file mode 100644
index 0000000..d7882fd
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/sanitizer_ucontext.h
@@ -0,0 +1,11 @@
+#ifdef __APPLE__
+// ucontext.h is deprecated on macOS, so tests that include it may stop working
+// someday. We define _XOPEN_SOURCE to keep using ucontext.h for now.
+#ifdef _STRUCT_UCONTEXT
+#error incomplete ucontext_t already defined, change #include order
+#endif
+#define _XOPEN_SOURCE 700
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
+#include <ucontext.h>
diff --git a/compiler-rt/test/tsan/fiber_asm.cc b/compiler-rt/test/tsan/fiber_asm.cc
index 806c70cc..63b63d38 100644
--- a/compiler-rt/test/tsan/fiber_asm.cc
+++ b/compiler-rt/test/tsan/fiber_asm.cc
@@ -1,6 +1,6 @@
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
// REQUIRES: x86_64-target-arch
-// UNSUPPORTED: darwin
+// UNSUPPORTED: tvos, watchos
#include "test.h"
struct ucontext {
@@ -13,8 +13,8 @@ extern "C" {
void ucontext_trampoline();
}
-__asm__(".global ucontext_do_switch\n"
- "ucontext_do_switch:\n\t"
+__asm__(".global " ASM_SYMBOL(ucontext_do_switch) "\n"
+ ASM_SYMBOL(ucontext_do_switch) ":\n\t"
"pushq %rbp\n\t"
"pushq %r15\n\t"
"pushq %r14\n\t"
@@ -31,8 +31,8 @@ __asm__(".global ucontext_do_switch\n"
"popq %rbp\n\t"
"retq");
-__asm__(".global ucontext_trampoline\n"
- "ucontext_trampoline:\n\t"
+__asm__(".global " ASM_SYMBOL(ucontext_trampoline) "\n"
+ ASM_SYMBOL(ucontext_trampoline) ":\n\t"
".cfi_startproc\n\t"
".cfi_undefined rip\n\t"
"movq %r12, %rdi\n\t"
diff --git a/compiler-rt/test/tsan/fiber_from_thread.cc b/compiler-rt/test/tsan/fiber_from_thread.cc
index d8af1e8..a432eb0 100644
--- a/compiler-rt/test/tsan/fiber_from_thread.cc
+++ b/compiler-rt/test/tsan/fiber_from_thread.cc
@@ -1,7 +1,7 @@
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: darwin
+// UNSUPPORTED: tvos, watchos
+#include "sanitizer_common/sanitizer_ucontext.h"
#include "test.h"
-#include <ucontext.h>
char stack[64 * 1024] __attribute__((aligned(16)));
diff --git a/compiler-rt/test/tsan/fiber_longjmp.cc b/compiler-rt/test/tsan/fiber_longjmp.cc
index 27d776a..bcf7dbd 100644
--- a/compiler-rt/test/tsan/fiber_longjmp.cc
+++ b/compiler-rt/test/tsan/fiber_longjmp.cc
@@ -1,8 +1,8 @@
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: darwin
+// UNSUPPORTED: tvos, watchos
+#include "sanitizer_common/sanitizer_ucontext.h"
#include "test.h"
#include <setjmp.h>
-#include <ucontext.h>
char stack[64 * 1024] __attribute__((aligned(16)));
diff --git a/compiler-rt/test/tsan/fiber_race.cc b/compiler-rt/test/tsan/fiber_race.cc
index 89bcddd..4724c72 100644
--- a/compiler-rt/test/tsan/fiber_race.cc
+++ b/compiler-rt/test/tsan/fiber_race.cc
@@ -1,7 +1,7 @@
// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: darwin
+// UNSUPPORTED: tvos, watchos
+#include "sanitizer_common/sanitizer_ucontext.h"
#include "test.h"
-#include <ucontext.h>
char stack[64 * 1024] __attribute__((aligned(16)));
diff --git a/compiler-rt/test/tsan/fiber_simple.cc b/compiler-rt/test/tsan/fiber_simple.cc
index ce529e7..550e5be 100644
--- a/compiler-rt/test/tsan/fiber_simple.cc
+++ b/compiler-rt/test/tsan/fiber_simple.cc
@@ -1,7 +1,7 @@
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: darwin
+// UNSUPPORTED: tvos, watchos
+#include "sanitizer_common/sanitizer_ucontext.h"
#include "test.h"
-#include <ucontext.h>
char stack[64 * 1024] __attribute__((aligned(16)));
diff --git a/compiler-rt/test/tsan/fiber_two_threads.cc b/compiler-rt/test/tsan/fiber_two_threads.cc
index eaadb65..5886586 100644
--- a/compiler-rt/test/tsan/fiber_two_threads.cc
+++ b/compiler-rt/test/tsan/fiber_two_threads.cc
@@ -1,7 +1,7 @@
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: darwin
+// UNSUPPORTED: tvos, watchos
+#include "sanitizer_common/sanitizer_ucontext.h"
#include "test.h"
-#include <ucontext.h>
char stack[64 * 1024] __attribute__((aligned(16)));
diff --git a/compiler-rt/test/tsan/test.h b/compiler-rt/test/tsan/test.h
index 595590b..af2e6f0 100644
--- a/compiler-rt/test/tsan/test.h
+++ b/compiler-rt/test/tsan/test.h
@@ -89,3 +89,9 @@ void AnnotateRWLockReleased(const char *f, int l, void *m, long is_w);
AnnotateRWLockAcquired(__FILE__, __LINE__, m, is_w)
#define ANNOTATE_RWLOCK_RELEASED(m, is_w) \
AnnotateRWLockReleased(__FILE__, __LINE__, m, is_w)
+
+#ifdef __APPLE__
+#define ASM_SYMBOL(symbol) "_" #symbol
+#else
+#define ASM_SYMBOL(symbol) #symbol
+#endif