1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This test verifies the correct handling of child thread exits.
11 #include "pseudo_barrier.h"
15 pseudo_barrier_t g_barrier1;
16 pseudo_barrier_t g_barrier2;
21 // Synchronize with the main thread.
22 pseudo_barrier_wait(g_barrier1);
24 // Synchronize with the main thread and thread2.
25 pseudo_barrier_wait(g_barrier2);
28 return NULL; // Should not reach here. (thread2 should raise SIGILL)
34 raise(SIGILL); // Raise SIGILL
36 // Synchronize with thread1 and the main thread.
37 pseudo_barrier_wait(g_barrier2); // Should not reach here.
45 pseudo_barrier_init(g_barrier1, 2);
46 pseudo_barrier_init(g_barrier2, 3);
49 std::thread thread_1(thread1);
51 // Wait for thread1 to start.
52 pseudo_barrier_wait(g_barrier1);
54 // Create another thread.
55 std::thread thread_2(thread2);
57 // Wait for thread2 to start.
58 // Second thread should crash but first thread and main thread may reach here.
59 pseudo_barrier_wait(g_barrier2);