xref: /openbsd-src/gnu/llvm/lldb/source/Host/linux/LibcGlue.cpp (revision dda2819751e49c83612958492e38917049128b41)
1*dda28197Spatrick //===-- LibcGlue.cpp ------------------------------------------------------===//
2061da546Spatrick //
3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information.
5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6061da546Spatrick //
7061da546Spatrick //===----------------------------------------------------------------------===//
8061da546Spatrick 
9061da546Spatrick // This file adds functions missing from libc on older versions of linux
10061da546Spatrick 
11061da546Spatrick #include <cerrno>
12061da546Spatrick #include <lldb/Host/linux/Uio.h>
13061da546Spatrick #include <sys/syscall.h>
14061da546Spatrick #include <unistd.h>
15061da546Spatrick 
16061da546Spatrick #if !HAVE_PROCESS_VM_READV
17061da546Spatrick // If the syscall wrapper is not available, provide one.
process_vm_readv(::pid_t pid,const struct iovec * local_iov,unsigned long liovcnt,const struct iovec * remote_iov,unsigned long riovcnt,unsigned long flags)18061da546Spatrick ssize_t process_vm_readv(::pid_t pid, const struct iovec *local_iov,
19061da546Spatrick                          unsigned long liovcnt, const struct iovec *remote_iov,
20061da546Spatrick                          unsigned long riovcnt, unsigned long flags) {
21061da546Spatrick #if HAVE_NR_PROCESS_VM_READV
22061da546Spatrick   // If we have the syscall number, we can issue the syscall ourselves.
23061da546Spatrick   return syscall(__NR_process_vm_readv, pid, local_iov, liovcnt, remote_iov,
24061da546Spatrick                  riovcnt, flags);
25061da546Spatrick #else // If not, let's pretend the syscall is not present.
26061da546Spatrick   errno = ENOSYS;
27061da546Spatrick   return -1;
28061da546Spatrick #endif
29061da546Spatrick }
30061da546Spatrick #endif
31