Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / src / signal / linux / raise.cpp
blobdd6f5eb4b35754226670ca0a285d441980305b1f
1 //===-- Linux implementation of signal ------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/signal/raise.h"
10 #include "src/signal/linux/signal_utils.h"
12 #include "src/__support/common.h"
14 namespace LIBC_NAMESPACE {
16 LLVM_LIBC_FUNCTION(int, raise, (int sig)) {
17 ::sigset_t sigset;
18 block_all_signals(sigset);
19 long pid = LIBC_NAMESPACE::syscall_impl<long>(SYS_getpid);
20 long tid = LIBC_NAMESPACE::syscall_impl<long>(SYS_gettid);
21 int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_tgkill, pid, tid, sig);
22 restore_signals(sigset);
23 return ret;
26 } // namespace LIBC_NAMESPACE