2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 // REQUIRES: linux && target={{aarch64-.+}}
12 // pthread_cancel in case of glibc calls _Unwind_ForcedUnwind from a signal on
13 // the child_thread. This test ensures sigretrun is handled correctly (see:
14 // UnwindCursor<A, R>::setInfoForSigReturn).
16 #include <cstdlib> // defines __BIONIC__
18 // Android/Bionic does not support pthread_cancel.
26 #include <condition_variable>
30 using namespace std::chrono_literals
;
32 std::condition_variable cv
;
34 bool thread_ready
= false;
36 static void* test(void* arg
) {
41 // This must be a pthread cancellation point.
49 pthread_t child_thread
;
50 std::unique_lock
<std::mutex
> lk(cv_m
);
51 pthread_create(&child_thread
, 0, test
, (void*)0);
53 if (!cv
.wait_for(lk
, 100ms
, [] { return thread_ready
; }))
56 pthread_cancel(child_thread
);
57 pthread_join(child_thread
, NULL
);