mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-10 02:25:47 +00:00
Eliminate the copies LLVM's System mmap and cache invalidation code. These were slowly drifting away from the original version, and moreover the copied code was a dead end in terms of portability. We now statically link to Support but in practice with stripping this adds next to no weight to the resultant binary. Also avoid installing lli-child-target to the user's $PATH. It's not meant to be run directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199881 91177308-0d34-0410-b5e6-96231b3b80d8
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
//===- ChildTarget.inc - Child process for external JIT execution for Unix -==//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Implementation of the Unix-specific parts of the ChildTarget class
|
|
// which executes JITed code in a separate process from where it was built.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
|
|
namespace {
|
|
|
|
struct ConnectionData_t {
|
|
int InputPipe;
|
|
int OutputPipe;
|
|
|
|
ConnectionData_t(int in, int out) : InputPipe(in), OutputPipe(out) {}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
LLIChildTarget::~LLIChildTarget() {
|
|
delete static_cast<ConnectionData_t *>(ConnectionData);
|
|
}
|
|
|
|
// OS-specific methods
|
|
void LLIChildTarget::initializeConnection() {
|
|
// Store the parent ends of the pipes
|
|
ConnectionData = (void*)new ConnectionData_t(STDIN_FILENO, STDOUT_FILENO);
|
|
}
|
|
|
|
int LLIChildTarget::WriteBytes(const void *Data, size_t Size) {
|
|
return write(((ConnectionData_t*)ConnectionData)->OutputPipe, Data, Size);
|
|
}
|
|
|
|
int LLIChildTarget::ReadBytes(void *Data, size_t Size) {
|
|
return read(((ConnectionData_t*)ConnectionData)->InputPipe, Data, Size);
|
|
}
|