1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 // UNSUPPORTED: tvos, watchos
3 // XFAIL: ios && !iossim
4 #include "sanitizer_common/sanitizer_ucontext.h"
7 char stack
[64 * 1024] __attribute__((aligned(16)));
9 ucontext_t uc
, orig_uc1
, orig_uc2
;
10 void *fiber
, *orig_fiber1
, *orig_fiber2
;
14 void *Thread(void *x
) {
15 orig_fiber2
= __tsan_get_current_fiber();
16 swapcontext(&orig_uc2
, &orig_uc1
);
22 pthread_create(&t
, 0, Thread
, 0);
24 __tsan_switch_to_fiber(orig_fiber1
, 0);
25 swapcontext(&uc
, &orig_uc1
);
29 orig_fiber1
= __tsan_get_current_fiber();
30 fiber
= __tsan_create_fiber(0);
32 uc
.uc_stack
.ss_sp
= stack
;
33 uc
.uc_stack
.ss_size
= sizeof(stack
);
35 makecontext(&uc
, func
, 0);
37 __tsan_switch_to_fiber(fiber
, 0);
38 swapcontext(&orig_uc1
, &uc
);
40 __tsan_switch_to_fiber(orig_fiber2
, 0);
41 swapcontext(&orig_uc1
, &orig_uc2
);
43 __tsan_destroy_fiber(fiber
);
44 fprintf(stderr
, "PASS\n");
48 // CHECK-NOT: WARNING: ThreadSanitizer: