1*80814287SRaphael Isemann //===-- LibcGlue.cpp ------------------------------------------------------===//
233b51e87SPavel Labath //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
633b51e87SPavel Labath //
733b51e87SPavel Labath //===----------------------------------------------------------------------===//
833b51e87SPavel Labath
933b51e87SPavel Labath // This file adds functions missing from libc on older versions of linux
1033b51e87SPavel Labath
11cd4994e9SPavel Labath #include <cerrno>
12b9c1b51eSKate Stone #include <lldb/Host/linux/Uio.h>
13b9c1b51eSKate Stone #include <sys/syscall.h>
14b9c1b51eSKate Stone #include <unistd.h>
1533b51e87SPavel Labath
16090b8616SPavel Labath #if !HAVE_PROCESS_VM_READV
17090b8616SPavel Labath // 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)18b9c1b51eSKate Stone ssize_t process_vm_readv(::pid_t pid, const struct iovec *local_iov,
19b9c1b51eSKate Stone unsigned long liovcnt, const struct iovec *remote_iov,
20b9c1b51eSKate Stone unsigned long riovcnt, unsigned long flags) {
21090b8616SPavel Labath #if HAVE_NR_PROCESS_VM_READV
22090b8616SPavel Labath // If we have the syscall number, we can issue the syscall ourselves.
23b9c1b51eSKate Stone return syscall(__NR_process_vm_readv, pid, local_iov, liovcnt, remote_iov,
24b9c1b51eSKate Stone riovcnt, flags);
2533b51e87SPavel Labath #else // If not, let's pretend the syscall is not present.
2633b51e87SPavel Labath errno = ENOSYS;
2733b51e87SPavel Labath return -1;
2833b51e87SPavel Labath #endif
2933b51e87SPavel Labath }
3033b51e87SPavel Labath #endif
31