1 //===---------- TargetProcessControlTypes.cpp - Shared TPC types ----------===// 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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // TargetProcessControl types. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h" 14 15 namespace llvm { 16 namespace orc { 17 namespace tpctypes { 18 from(StringRef S)19WrapperFunctionResult WrapperFunctionResult::from(StringRef S) { 20 CWrapperFunctionResult R; 21 zeroInit(R); 22 R.Size = S.size(); 23 if (R.Size > sizeof(uint64_t)) { 24 R.Data.ValuePtr = new uint8_t[R.Size]; 25 memcpy(R.Data.ValuePtr, S.data(), R.Size); 26 R.Destroy = destroyWithDeleteArray; 27 } else 28 memcpy(R.Data.Value, S.data(), R.Size); 29 return R; 30 } 31 destroyWithFree(CWrapperFunctionResultData Data,uint64_t Size)32void WrapperFunctionResult::destroyWithFree(CWrapperFunctionResultData Data, 33 uint64_t Size) { 34 free(Data.ValuePtr); 35 } 36 destroyWithDeleteArray(CWrapperFunctionResultData Data,uint64_t Size)37void WrapperFunctionResult::destroyWithDeleteArray( 38 CWrapperFunctionResultData Data, uint64_t Size) { 39 delete[] Data.ValuePtr; 40 } 41 42 } // end namespace tpctypes 43 } // end namespace orc 44 } // end namespace llvm 45