31 lines · cpp
1//===-- LibcGlue.cpp ------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9// This file adds functions missing from libc on older versions of linux10 11#include <cerrno>12#include <lldb/Host/linux/Uio.h>13#include <sys/syscall.h>14#include <unistd.h>15 16#if !HAVE_PROCESS_VM_READV17// If the syscall wrapper is not available, provide one.18ssize_t process_vm_readv(::pid_t pid, const struct iovec *local_iov,19 unsigned long liovcnt, const struct iovec *remote_iov,20 unsigned long riovcnt, unsigned long flags) {21#if HAVE_NR_PROCESS_VM_READV22 // If we have the syscall number, we can issue the syscall ourselves.23 return syscall(__NR_process_vm_readv, pid, local_iov, liovcnt, remote_iov,24 riovcnt, flags);25#else // If not, let's pretend the syscall is not present.26 errno = ENOSYS;27 return -1;28#endif29}30#endif31