diff options
Diffstat (limited to 'compiler-rt/test/profile/Inputs/instrprof-gcov-multithread_fork.cpp')
-rw-r--r-- | compiler-rt/test/profile/Inputs/instrprof-gcov-multithread_fork.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/compiler-rt/test/profile/Inputs/instrprof-gcov-multithread_fork.cpp b/compiler-rt/test/profile/Inputs/instrprof-gcov-multithread_fork.cpp new file mode 100644 index 00000000000..94db50fc826 --- /dev/null +++ b/compiler-rt/test/profile/Inputs/instrprof-gcov-multithread_fork.cpp @@ -0,0 +1,35 @@ +#include <sys/types.h> +#include <thread> +#include <unistd.h> +#include <vector> + +template <typename T> +void launcher(T func) { + std::vector<std::thread> pool; + + for (int i = 0; i < 10; i++) { + pool.emplace_back(std::thread(func)); + } + + for (auto &t : pool) { + t.join(); + } +} + +void h() {} + +void g() { + fork(); + launcher<>(h); +} + +void f() { + fork(); + launcher<>(g); +} + +int main() { + launcher<>(f); + + return 0; +} |