pslang/libs/jit/source/executable.cpp

31 lines
673 B
C++

#include <pslang/jit/executable.hpp>
#include <stdexcept>
#ifdef __linux__
#include <sys/mman.h>
#endif
#ifdef __APPLE__
#include <sys/mman.h>
#endif
namespace pslang::jit
{
compiled_module make_host_executable(compiled_module module)
{
#if defined(__linux__) || defined(__APPLE__)
if (module.abi != abi::itanium && module.abi != abi::armv8)
throw std::runtime_error("Abi mismatch");
// Assume the module code memory was obtained via mmap
mprotect(module.code.memory.data.get(), module.code.memory.size, PROT_READ | PROT_EXEC);
return module;
#else
throw std::runtime_error("Host-executable modules are not supported for this platform");
#endif
}
}