Path: blob/main/contrib/llvm-project/compiler-rt/lib/orc/run_program_wrapper.cpp
39566 views
//===- run_program_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" int64_t __orc_rt_run_program(const char *JITDylibName,21const char *EntrySymbolName, int argc,22char *argv[]);2324ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult25__orc_rt_run_program_wrapper(const char *ArgData, size_t ArgSize) {26return WrapperFunction<int64_t(SPSString, SPSString,27SPSSequence<SPSString>)>::28handle(ArgData, ArgSize,29[](const std::string &JITDylibName,30const std::string &EntrySymbolName,31const std::vector<std::string_view> &Args) {32std::vector<std::unique_ptr<char[]>> ArgVStorage;33ArgVStorage.reserve(Args.size());34for (auto &Arg : Args) {35ArgVStorage.push_back(36std::make_unique<char[]>(Arg.size() + 1));37memcpy(ArgVStorage.back().get(), Arg.data(), Arg.size());38ArgVStorage.back()[Arg.size()] = '\0';39}40std::vector<char *> ArgV;41ArgV.reserve(ArgVStorage.size() + 1);42for (auto &ArgStorage : ArgVStorage)43ArgV.push_back(ArgStorage.get());44ArgV.push_back(nullptr);45return __orc_rt_run_program(JITDylibName.c_str(),46EntrySymbolName.c_str(),47ArgV.size() - 1, ArgV.data());48})49.release();50}515253