[gn] port afa8aeeeec (RISCVGenExegesis.inc)
[llvm-project.git] / libc / src / signal / linux / kill.cpp
blobed117858f51ef2a547a0b1320658d39a75521e8b
1 //===-- Linux implementation of kill --------------------------------------===//
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/kill.h"
11 #include "src/__support/OSUtil/syscall.h" // For internal syscall function.
12 #include "src/__support/common.h"
13 #include "src/__support/macros/config.h"
14 #include "src/errno/libc_errno.h"
15 #include "src/signal/linux/signal_utils.h"
17 #include <signal.h>
18 #include <sys/syscall.h> // For syscall numbers.
20 namespace LIBC_NAMESPACE_DECL {
22 LLVM_LIBC_FUNCTION(int, kill, (pid_t pid, int sig)) {
23 int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_kill, pid, sig);
25 // A negative return value indicates an error with the magnitude of the
26 // value being the error code.
27 if (ret != 0) {
28 libc_errno = (ret > 0 ? ret : -ret);
29 return -1;
32 return ret; // always 0
35 } // namespace LIBC_NAMESPACE_DECL