| 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 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "src/signal/raise.h" |
| 10 | |
| 11 | #include "hdr/types/sigset_t.h" |
| 12 | #include "src/__support/common.h" |
| 13 | #include "src/__support/macros/config.h" |
| 14 | #include "src/signal/linux/signal_utils.h" |
| 15 | |
| 16 | namespace LIBC_NAMESPACE_DECL { |
| 17 | |
| 18 | LLVM_LIBC_FUNCTION(int, raise, (int sig)) { |
| 19 | sigset_t sigset; |
| 20 | block_all_signals(sigset); |
| 21 | long pid = LIBC_NAMESPACE::syscall_impl<long>(SYS_getpid); |
| 22 | long tid = LIBC_NAMESPACE::syscall_impl<long>(SYS_gettid); |
| 23 | int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_tgkill, pid, tid, sig); |
| 24 | restore_signals(sigset); |
| 25 | return ret; |
| 26 | } |
| 27 | |
| 28 | } // namespace LIBC_NAMESPACE_DECL |
| 29 | |