Path: blob/main/contrib/llvm-project/compiler-rt/lib/orc/dlfcn_wrapper.cpp
39566 views
//===- dlfcn_wrapper.cpp --------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file is a part of the ORC runtime support library.9//10//===----------------------------------------------------------------------===//1112#include "adt.h"13#include "common.h"14#include "wrapper_function_utils.h"1516#include <vector>1718using namespace __orc_rt;1920extern "C" const char *__orc_rt_jit_dlerror();21extern "C" void *__orc_rt_jit_dlopen(const char *path, int mode);22extern "C" int __orc_rt_jit_dlclose(void *dso_handle);2324ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult25__orc_rt_jit_dlerror_wrapper(const char *ArgData, size_t ArgSize) {26return WrapperFunction<SPSString()>::handle(27ArgData, ArgSize,28[]() { return std::string(__orc_rt_jit_dlerror()); })29.release();30}3132ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult33__orc_rt_jit_dlopen_wrapper(const char *ArgData, size_t ArgSize) {34return WrapperFunction<SPSExecutorAddr(SPSString, int32_t)>::handle(35ArgData, ArgSize,36[](const std::string &Path, int32_t mode) {37return ExecutorAddr::fromPtr(38__orc_rt_jit_dlopen(Path.c_str(), mode));39})40.release();41}4243ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult44__orc_rt_jit_dlclose_wrapper(const char *ArgData, size_t ArgSize) {45return WrapperFunction<int32_t(SPSExecutorAddr)>::handle(46ArgData, ArgSize,47[](ExecutorAddr &DSOHandle) {48return __orc_rt_jit_dlclose(DSOHandle.toPtr<void *>());49})50.release();51}525354