[X86] avx512-pmovxrm.ll - replace X32 checks with X86. NFC.
[llvm-project.git] / libcxxabi / test / forced_unwind4.pass.cpp
blob2864426ca16dcd85667f3f5208ec496e6e9c9080
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
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
7 //
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.
19 #ifdef __BIONIC__
20 int main() {
21 return 0;
23 #else
25 #include <chrono>
26 #include <condition_variable>
27 #include <pthread.h>
28 #include <unistd.h>
30 using namespace std::chrono_literals;
32 std::condition_variable cv;
33 std::mutex cv_m;
34 bool thread_ready = false;
36 static void* test(void* arg) {
37 (void)arg;
38 thread_ready = true;
39 cv.notify_all();
41 // This must be a pthread cancellation point.
42 while (1)
43 sleep(100);
45 return (void*)1;
48 int main() {
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; }))
54 return -1;
56 pthread_cancel(child_thread);
57 pthread_join(child_thread, NULL);
58 return 0;
60 #endif