5#include <boost/asio/local/datagram_protocol.hpp>
9#include <sys/syscall.h>
10#include <linux/memfd.h>
12namespace sysio {
namespace chain {
namespace eosvmoc {
24 _inuse = other._inuse;
30 operator int()
const {
31 FC_ASSERT(_inuse,
"trying to get the value of a not-in-use wrappedfd");
50std::tuple<bool, eosvmoc_message, std::vector<wrapped_fd>>
read_message_with_fds(boost::asio::local::datagram_protocol::socket&
s);
57 int fd = syscall(SYS_memfd_create,
"eosvmoc_code", MFD_CLOEXEC);
58 FC_ASSERT(fd >= 0,
"Failed to create memfd");
59 FC_ASSERT(ftruncate(fd,
bytes.size()) == 0,
"failed to grow memfd");
61 uint8_t* b = (
uint8_t*)mmap(
nullptr,
bytes.size(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
62 FC_ASSERT(b != MAP_FAILED,
"failed to mmap memfd");
64 munmap(b,
bytes.size());
wrapped_fd & operator=(wrapped_fd &&other)
wrapped_fd & operator=(const wrapped_fd &)=delete
wrapped_fd(wrapped_fd &&other)
wrapped_fd(const wrapped_fd &)=delete
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
void close(T *e, websocketpp::connection_hdl hdl)
std::vector< uint8_t > vector_for_memfd(const wrapped_fd &memfd)
bool write_message_with_fds(boost::asio::local::datagram_protocol::socket &s, const eosvmoc_message &message, const std::vector< wrapped_fd > &fds=std::vector< wrapped_fd >())
std::tuple< bool, eosvmoc_message, std::vector< wrapped_fd > > read_message_with_fds(boost::asio::local::datagram_protocol::socket &s)
std::variant< initialize_message, initalize_response_message, compile_wasm_message, evict_wasms_message, code_compilation_result_message, wasm_compilation_result_message > eosvmoc_message
wrapped_fd memfd_for_bytearray(const T &bytes)
#define T(meth, val, expected)
memcpy((char *) pInfo->slotDescription, s, l)