brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · cb92a1f Raw
64 lines · cpp
1//===- dlfcn_wrapper.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 is a part of the ORC runtime support library.10//11//===----------------------------------------------------------------------===//12 13#include "adt.h"14#include "common.h"15#include "wrapper_function_utils.h"16 17#include <vector>18 19using namespace orc_rt;20 21extern "C" const char *__orc_rt_jit_dlerror();22extern "C" void *__orc_rt_jit_dlopen(const char *path, int mode);23extern "C" int __orc_rt_jit_dlupdate(void *dso_handle);24extern "C" int __orc_rt_jit_dlclose(void *dso_handle);25 26ORC_RT_INTERFACE orc_rt_WrapperFunctionResult27__orc_rt_jit_dlerror_wrapper(const char *ArgData, size_t ArgSize) {28  return WrapperFunction<SPSString()>::handle(29             ArgData, ArgSize,30             []() { return std::string(__orc_rt_jit_dlerror()); })31      .release();32}33 34ORC_RT_INTERFACE orc_rt_WrapperFunctionResult35__orc_rt_jit_dlopen_wrapper(const char *ArgData, size_t ArgSize) {36  return WrapperFunction<SPSExecutorAddr(SPSString, int32_t)>::handle(37             ArgData, ArgSize,38             [](const std::string &Path, int32_t mode) {39               return ExecutorAddr::fromPtr(40                   __orc_rt_jit_dlopen(Path.c_str(), mode));41             })42      .release();43}44 45ORC_RT_INTERFACE orc_rt_WrapperFunctionResult46__orc_rt_jit_dlupdate_wrapper(const char *ArgData, size_t ArgSize) {47  return WrapperFunction<int32_t(SPSExecutorAddr)>::handle(48             ArgData, ArgSize,49             [](ExecutorAddr &DSOHandle) {50               return __orc_rt_jit_dlupdate(DSOHandle.toPtr<void *>());51             })52      .release();53}54 55ORC_RT_INTERFACE orc_rt_WrapperFunctionResult56__orc_rt_jit_dlclose_wrapper(const char *ArgData, size_t ArgSize) {57  return WrapperFunction<int32_t(SPSExecutorAddr)>::handle(58             ArgData, ArgSize,59             [](ExecutorAddr &DSOHandle) {60               return __orc_rt_jit_dlclose(DSOHandle.toPtr<void *>());61             })62      .release();63}64