forked from OSchip/llvm-project
[ORC-RT] Rename C-API functions to use __orc_rt_ prefix (instead of OrcRT).
This matches the C++ namespace name, and is consistent with other C linkage functions (e.g. __orc_rt_jit_dispatch).
This commit is contained in:
parent
d791f0c219
commit
28c3e9c0d1
|
@ -50,18 +50,19 @@ ORC_RT_C_EXTERN_C_BEGIN
|
||||||
typedef union {
|
typedef union {
|
||||||
const char *ValuePtr;
|
const char *ValuePtr;
|
||||||
char Value[sizeof(ValuePtr)];
|
char Value[sizeof(ValuePtr)];
|
||||||
} OrcRTCWrapperFunctionResultDataUnion;
|
} __orc_rt_CWrapperFunctionResultDataUnion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OrcRTCWrapperFunctionResult is a kind of C-SmallVector with an out-of-band
|
* __orc_rt_CWrapperFunctionResult is a kind of C-SmallVector with an
|
||||||
* error state.
|
* out-of-band error state.
|
||||||
*
|
*
|
||||||
* If Size == 0 and Data.ValuePtr is non-zero then the value is in the
|
* If Size == 0 and Data.ValuePtr is non-zero then the value is in the
|
||||||
* 'out-of-band error' state, and Data.ValuePtr points at a malloc-allocated,
|
* 'out-of-band error' state, and Data.ValuePtr points at a malloc-allocated,
|
||||||
* null-terminated string error message.
|
* null-terminated string error message.
|
||||||
*
|
*
|
||||||
* If Size <= sizeof(OrcRTCWrapperFunctionResultData) then the value is in the
|
* If Size <= sizeof(__orc_rt_CWrapperFunctionResultData) then the value is in
|
||||||
* 'small' state and the content is held in the first Size bytes of Data.Value.
|
* the 'small' state and the content is held in the first Size bytes of
|
||||||
|
* Data.Value.
|
||||||
*
|
*
|
||||||
* If Size > sizeof(OrtRTCWrapperFunctionResultData) then the value is in the
|
* If Size > sizeof(OrtRTCWrapperFunctionResultData) then the value is in the
|
||||||
* 'large' state and the content is held in the first Size bytes of the
|
* 'large' state and the content is held in the first Size bytes of the
|
||||||
|
@ -69,29 +70,29 @@ typedef union {
|
||||||
* malloc, and will be freed with free when this value is destroyed.
|
* malloc, and will be freed with free when this value is destroyed.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
OrcRTCWrapperFunctionResultDataUnion Data;
|
__orc_rt_CWrapperFunctionResultDataUnion Data;
|
||||||
size_t Size;
|
size_t Size;
|
||||||
} OrcRTCWrapperFunctionResult;
|
} __orc_rt_CWrapperFunctionResult;
|
||||||
|
|
||||||
typedef struct OrcRTCSharedOpaqueJITProcessControl
|
typedef struct __orc_rt_CSharedOpaqueJITProcessControl
|
||||||
*OrcRTSharedJITProcessControlRef;
|
*__orc_rt_SharedJITProcessControlRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zero-initialize an OrcRTCWrapperFunctionResult.
|
* Zero-initialize an __orc_rt_CWrapperFunctionResult.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
OrcRTCWrapperFunctionResultInit(OrcRTCWrapperFunctionResult *R) {
|
__orc_rt_CWrapperFunctionResultInit(__orc_rt_CWrapperFunctionResult *R) {
|
||||||
R->Size = 0;
|
R->Size = 0;
|
||||||
R->Data.ValuePtr = 0;
|
R->Data.ValuePtr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an OrcRTCWrapperFunctionResult with an uninitialized buffer of size
|
* Create an __orc_rt_CWrapperFunctionResult with an uninitialized buffer of
|
||||||
* Size. The buffer is returned via the DataPtr argument.
|
* size Size. The buffer is returned via the DataPtr argument.
|
||||||
*/
|
*/
|
||||||
static inline char *
|
static inline char *
|
||||||
OrcRTCWrapperFunctionResultAllocate(OrcRTCWrapperFunctionResult *R,
|
__orc_rt_CWrapperFunctionResultAllocate(__orc_rt_CWrapperFunctionResult *R,
|
||||||
size_t Size) {
|
size_t Size) {
|
||||||
char *DataPtr;
|
char *DataPtr;
|
||||||
R->Size = Size;
|
R->Size = Size;
|
||||||
if (Size > sizeof(R->Data.Value)) {
|
if (Size > sizeof(R->Data.Value)) {
|
||||||
|
@ -103,11 +104,11 @@ OrcRTCWrapperFunctionResultAllocate(OrcRTCWrapperFunctionResult *R,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an OrcRTWrapperFunctionResult from the given data range.
|
* Create an __orc_rt_WrapperFunctionResult from the given data range.
|
||||||
*/
|
*/
|
||||||
static inline OrcRTCWrapperFunctionResult
|
static inline __orc_rt_CWrapperFunctionResult
|
||||||
OrcRTCreateCWrapperFunctionResultFromRange(const char *Data, size_t Size) {
|
__orc_rt_CreateCWrapperFunctionResultFromRange(const char *Data, size_t Size) {
|
||||||
OrcRTCWrapperFunctionResult R;
|
__orc_rt_CWrapperFunctionResult R;
|
||||||
R.Size = Size;
|
R.Size = Size;
|
||||||
if (R.Size > sizeof(R.Data.Value)) {
|
if (R.Size > sizeof(R.Data.Value)) {
|
||||||
char *Tmp = (char *)malloc(Size);
|
char *Tmp = (char *)malloc(Size);
|
||||||
|
@ -119,27 +120,28 @@ OrcRTCreateCWrapperFunctionResultFromRange(const char *Data, size_t Size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an OrcRTCWrapperFunctionResult by copying the given string, including
|
* Create an __orc_rt_CWrapperFunctionResult by copying the given string,
|
||||||
* the null-terminator.
|
* including the null-terminator.
|
||||||
*
|
*
|
||||||
* This function copies the input string. The client is responsible for freeing
|
* This function copies the input string. The client is responsible for freeing
|
||||||
* the ErrMsg arg.
|
* the ErrMsg arg.
|
||||||
*/
|
*/
|
||||||
static inline OrcRTCWrapperFunctionResult
|
static inline __orc_rt_CWrapperFunctionResult
|
||||||
OrcRTCreateCWrapperFunctionResultFromString(const char *Source) {
|
__orc_rt_CreateCWrapperFunctionResultFromString(const char *Source) {
|
||||||
return OrcRTCreateCWrapperFunctionResultFromRange(Source, strlen(Source) + 1);
|
return __orc_rt_CreateCWrapperFunctionResultFromRange(Source,
|
||||||
|
strlen(Source) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an OrcRTCWrapperFunctionResult representing an out-of-band
|
* Create an __orc_rt_CWrapperFunctionResult representing an out-of-band
|
||||||
* error.
|
* error.
|
||||||
*
|
*
|
||||||
* This function takes ownership of the string argument which must have been
|
* This function takes ownership of the string argument which must have been
|
||||||
* allocated with malloc.
|
* allocated with malloc.
|
||||||
*/
|
*/
|
||||||
static inline OrcRTCWrapperFunctionResult
|
static inline __orc_rt_CWrapperFunctionResult
|
||||||
OrcRTCreateCWrapperFunctionResultFromOutOfBandError(const char *ErrMsg) {
|
__orc_rt_CreateCWrapperFunctionResultFromOutOfBandError(const char *ErrMsg) {
|
||||||
OrcRTCWrapperFunctionResult R;
|
__orc_rt_CWrapperFunctionResult R;
|
||||||
R.Size = 0;
|
R.Size = 0;
|
||||||
char *Tmp = (char *)malloc(strlen(ErrMsg) + 1);
|
char *Tmp = (char *)malloc(strlen(ErrMsg) + 1);
|
||||||
strcpy(Tmp, ErrMsg);
|
strcpy(Tmp, ErrMsg);
|
||||||
|
@ -148,11 +150,11 @@ OrcRTCreateCWrapperFunctionResultFromOutOfBandError(const char *ErrMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should be called to destroy OrcRTCWrapperFunctionResult values
|
* This should be called to destroy __orc_rt_CWrapperFunctionResult values
|
||||||
* regardless of their state.
|
* regardless of their state.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
OrcRTDisposeCWrapperFunctionResult(OrcRTCWrapperFunctionResult *R) {
|
__orc_rt_DisposeCWrapperFunctionResult(__orc_rt_CWrapperFunctionResult *R) {
|
||||||
if (R->Size > sizeof(R->Data.Value) ||
|
if (R->Size > sizeof(R->Data.Value) ||
|
||||||
(R->Size == 0 && R->Data.ValuePtr))
|
(R->Size == 0 && R->Data.ValuePtr))
|
||||||
free((void *)R->Data.ValuePtr);
|
free((void *)R->Data.ValuePtr);
|
||||||
|
@ -160,22 +162,22 @@ OrcRTDisposeCWrapperFunctionResult(OrcRTCWrapperFunctionResult *R) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a pointer to the data contained in the given
|
* Get a pointer to the data contained in the given
|
||||||
* OrcRTCWrapperFunctionResult.
|
* __orc_rt_CWrapperFunctionResult.
|
||||||
*/
|
*/
|
||||||
static inline const char *
|
static inline const char *
|
||||||
OrcRTCWrapperFunctionResultData(const OrcRTCWrapperFunctionResult *R) {
|
__orc_rt_CWrapperFunctionResultData(const __orc_rt_CWrapperFunctionResult *R) {
|
||||||
assert((R->Size != 0 || R->Data.ValuePtr == nullptr) &&
|
assert((R->Size != 0 || R->Data.ValuePtr == nullptr) &&
|
||||||
"Cannot get data for out-of-band error value");
|
"Cannot get data for out-of-band error value");
|
||||||
return R->Size > sizeof(R->Data.Value) ? R->Data.ValuePtr : R->Data.Value;
|
return R->Size > sizeof(R->Data.Value) ? R->Data.ValuePtr : R->Data.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Safely get the size of the given OrcRTCWrapperFunctionResult.
|
* Safely get the size of the given __orc_rt_CWrapperFunctionResult.
|
||||||
*
|
*
|
||||||
* Asserts that we're not trying to access the size of an error value.
|
* Asserts that we're not trying to access the size of an error value.
|
||||||
*/
|
*/
|
||||||
static inline size_t
|
static inline size_t
|
||||||
OrcRTCWrapperFunctionResultSize(const OrcRTCWrapperFunctionResult *R) {
|
__orc_rt_CWrapperFunctionResultSize(const __orc_rt_CWrapperFunctionResult *R) {
|
||||||
assert((R->Size != 0 || R->Data.ValuePtr == nullptr) &&
|
assert((R->Size != 0 || R->Data.ValuePtr == nullptr) &&
|
||||||
"Cannot get size for out-of-band error value");
|
"Cannot get size for out-of-band error value");
|
||||||
return R->Size;
|
return R->Size;
|
||||||
|
@ -183,22 +185,22 @@ OrcRTCWrapperFunctionResultSize(const OrcRTCWrapperFunctionResult *R) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns 1 if this value is equivalent to a value just initialized by
|
* Returns 1 if this value is equivalent to a value just initialized by
|
||||||
* OrcRTCWrapperFunctionResultInit, 0 otherwise.
|
* __orc_rt_CWrapperFunctionResultInit, 0 otherwise.
|
||||||
*/
|
*/
|
||||||
static inline size_t
|
static inline size_t
|
||||||
OrcRTCWrapperFunctionResultEmpty(const OrcRTCWrapperFunctionResult *R) {
|
__orc_rt_CWrapperFunctionResultEmpty(const __orc_rt_CWrapperFunctionResult *R) {
|
||||||
return R->Size == 0 && R->Data.ValuePtr == 0;
|
return R->Size == 0 && R->Data.ValuePtr == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to the out-of-band error string for this
|
* Returns a pointer to the out-of-band error string for this
|
||||||
* OrcRTCWrapperFunctionResult, or null if there is no error.
|
* __orc_rt_CWrapperFunctionResult, or null if there is no error.
|
||||||
*
|
*
|
||||||
* The OrcRTCWrapperFunctionResult retains ownership of the error
|
* The __orc_rt_CWrapperFunctionResult retains ownership of the error
|
||||||
* string, so it should be copied if the caller wishes to preserve it.
|
* string, so it should be copied if the caller wishes to preserve it.
|
||||||
*/
|
*/
|
||||||
static inline const char *OrcRTCWrapperFunctionResultGetOutOfBandError(
|
static inline const char *__orc_rt_CWrapperFunctionResultGetOutOfBandError(
|
||||||
const OrcRTCWrapperFunctionResult *R) {
|
const __orc_rt_CWrapperFunctionResult *R) {
|
||||||
return R->Size == 0 ? R->Data.ValuePtr : 0;
|
return R->Size == 0 ? R->Data.ValuePtr : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ extern "C" __orc_rt_Opaque __orc_rt_jit_dispatch_ctx
|
||||||
/// This is declared for use by the runtime, but should be implemented in the
|
/// This is declared for use by the runtime, but should be implemented in the
|
||||||
/// executor or provided by a definition added to the JIT before the runtime
|
/// executor or provided by a definition added to the JIT before the runtime
|
||||||
/// is loaded.
|
/// is loaded.
|
||||||
extern "C" OrcRTCWrapperFunctionResult
|
extern "C" __orc_rt_CWrapperFunctionResult
|
||||||
__orc_rt_jit_dispatch(__orc_rt_Opaque *DispatchCtx, const void *FnTag,
|
__orc_rt_jit_dispatch(__orc_rt_Opaque *DispatchCtx, const void *FnTag,
|
||||||
const char *Data, size_t Size)
|
const char *Data, size_t Size)
|
||||||
__attribute__((weak_import));
|
__attribute__((weak_import));
|
||||||
|
|
|
@ -14,24 +14,24 @@
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
TEST(CAPITest, CWrapperFunctionResultInit) {
|
TEST(CAPITest, CWrapperFunctionResultInit) {
|
||||||
OrcRTCWrapperFunctionResult R;
|
__orc_rt_CWrapperFunctionResult R;
|
||||||
OrcRTCWrapperFunctionResultInit(&R);
|
__orc_rt_CWrapperFunctionResultInit(&R);
|
||||||
|
|
||||||
EXPECT_EQ(R.Size, 0U);
|
EXPECT_EQ(R.Size, 0U);
|
||||||
EXPECT_EQ(R.Data.ValuePtr, nullptr);
|
EXPECT_EQ(R.Data.ValuePtr, nullptr);
|
||||||
|
|
||||||
// Check that this value isn't treated as an out-of-band error.
|
// Check that this value isn't treated as an out-of-band error.
|
||||||
EXPECT_EQ(OrcRTCWrapperFunctionResultGetOutOfBandError(&R), nullptr);
|
EXPECT_EQ(__orc_rt_CWrapperFunctionResultGetOutOfBandError(&R), nullptr);
|
||||||
|
|
||||||
// Check that we can dispose of the value.
|
// Check that we can dispose of the value.
|
||||||
OrcRTDisposeCWrapperFunctionResult(&R);
|
__orc_rt_DisposeCWrapperFunctionResult(&R);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CAPITest, CWrapperFunctionResultAllocSmall) {
|
TEST(CAPITest, CWrapperFunctionResultAllocSmall) {
|
||||||
constexpr size_t SmallAllocSize = sizeof(const char *);
|
constexpr size_t SmallAllocSize = sizeof(const char *);
|
||||||
|
|
||||||
OrcRTCWrapperFunctionResult R;
|
__orc_rt_CWrapperFunctionResult R;
|
||||||
char *DataPtr = OrcRTCWrapperFunctionResultAllocate(&R, SmallAllocSize);
|
char *DataPtr = __orc_rt_CWrapperFunctionResultAllocate(&R, SmallAllocSize);
|
||||||
|
|
||||||
for (size_t I = 0; I != SmallAllocSize; ++I)
|
for (size_t I = 0; I != SmallAllocSize; ++I)
|
||||||
DataPtr[I] = 0x55 + I;
|
DataPtr[I] = 0x55 + I;
|
||||||
|
@ -44,24 +44,24 @@ TEST(CAPITest, CWrapperFunctionResultAllocSmall) {
|
||||||
<< "Unexpected value at index " << I;
|
<< "Unexpected value at index " << I;
|
||||||
|
|
||||||
// Check that this value isn't treated as an out-of-band error.
|
// Check that this value isn't treated as an out-of-band error.
|
||||||
EXPECT_EQ(OrcRTCWrapperFunctionResultGetOutOfBandError(&R), nullptr);
|
EXPECT_EQ(__orc_rt_CWrapperFunctionResultGetOutOfBandError(&R), nullptr);
|
||||||
|
|
||||||
// Check that OrcRTCWrapperFunctionResult(Data|Result|Size) and
|
// Check that __orc_rt_CWrapperFunctionResult(Data|Result|Size) and
|
||||||
// OrcRTCWrapperFunctionResultGetOutOfBandError behave as expected.
|
// __orc_rt_CWrapperFunctionResultGetOutOfBandError behave as expected.
|
||||||
EXPECT_EQ(OrcRTCWrapperFunctionResultData(&R), R.Data.Value);
|
EXPECT_EQ(__orc_rt_CWrapperFunctionResultData(&R), R.Data.Value);
|
||||||
EXPECT_EQ(OrcRTCWrapperFunctionResultSize(&R), SmallAllocSize);
|
EXPECT_EQ(__orc_rt_CWrapperFunctionResultSize(&R), SmallAllocSize);
|
||||||
EXPECT_FALSE(OrcRTCWrapperFunctionResultEmpty(&R));
|
EXPECT_FALSE(__orc_rt_CWrapperFunctionResultEmpty(&R));
|
||||||
EXPECT_EQ(OrcRTCWrapperFunctionResultGetOutOfBandError(&R), nullptr);
|
EXPECT_EQ(__orc_rt_CWrapperFunctionResultGetOutOfBandError(&R), nullptr);
|
||||||
|
|
||||||
// Check that we can dispose of the value.
|
// Check that we can dispose of the value.
|
||||||
OrcRTDisposeCWrapperFunctionResult(&R);
|
__orc_rt_DisposeCWrapperFunctionResult(&R);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CAPITest, CWrapperFunctionResultAllocLarge) {
|
TEST(CAPITest, CWrapperFunctionResultAllocLarge) {
|
||||||
constexpr size_t LargeAllocSize = sizeof(const char *) + 1;
|
constexpr size_t LargeAllocSize = sizeof(const char *) + 1;
|
||||||
|
|
||||||
OrcRTCWrapperFunctionResult R;
|
__orc_rt_CWrapperFunctionResult R;
|
||||||
char *DataPtr = OrcRTCWrapperFunctionResultAllocate(&R, LargeAllocSize);
|
char *DataPtr = __orc_rt_CWrapperFunctionResultAllocate(&R, LargeAllocSize);
|
||||||
|
|
||||||
for (size_t I = 0; I != LargeAllocSize; ++I)
|
for (size_t I = 0; I != LargeAllocSize; ++I)
|
||||||
DataPtr[I] = 0x55 + I;
|
DataPtr[I] = 0x55 + I;
|
||||||
|
@ -75,17 +75,17 @@ TEST(CAPITest, CWrapperFunctionResultAllocLarge) {
|
||||||
<< "Unexpected value at index " << I;
|
<< "Unexpected value at index " << I;
|
||||||
|
|
||||||
// Check that this value isn't treated as an out-of-band error.
|
// Check that this value isn't treated as an out-of-band error.
|
||||||
EXPECT_EQ(OrcRTCWrapperFunctionResultGetOutOfBandError(&R), nullptr);
|
EXPECT_EQ(__orc_rt_CWrapperFunctionResultGetOutOfBandError(&R), nullptr);
|
||||||
|
|
||||||
// Check that OrcRTCWrapperFunctionResult(Data|Result|Size) and
|
// Check that __orc_rt_CWrapperFunctionResult(Data|Result|Size) and
|
||||||
// OrcRTCWrapperFunctionResultGetOutOfBandError behave as expected.
|
// __orc_rt_CWrapperFunctionResultGetOutOfBandError behave as expected.
|
||||||
EXPECT_EQ(OrcRTCWrapperFunctionResultData(&R), R.Data.ValuePtr);
|
EXPECT_EQ(__orc_rt_CWrapperFunctionResultData(&R), R.Data.ValuePtr);
|
||||||
EXPECT_EQ(OrcRTCWrapperFunctionResultSize(&R), LargeAllocSize);
|
EXPECT_EQ(__orc_rt_CWrapperFunctionResultSize(&R), LargeAllocSize);
|
||||||
EXPECT_FALSE(OrcRTCWrapperFunctionResultEmpty(&R));
|
EXPECT_FALSE(__orc_rt_CWrapperFunctionResultEmpty(&R));
|
||||||
EXPECT_EQ(OrcRTCWrapperFunctionResultGetOutOfBandError(&R), nullptr);
|
EXPECT_EQ(__orc_rt_CWrapperFunctionResultGetOutOfBandError(&R), nullptr);
|
||||||
|
|
||||||
// Check that we can dispose of the value.
|
// Check that we can dispose of the value.
|
||||||
OrcRTDisposeCWrapperFunctionResult(&R);
|
__orc_rt_DisposeCWrapperFunctionResult(&R);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CAPITest, CWrapperFunctionResultFromRangeSmall) {
|
TEST(CAPITest, CWrapperFunctionResultFromRangeSmall) {
|
||||||
|
@ -95,8 +95,8 @@ TEST(CAPITest, CWrapperFunctionResultFromRangeSmall) {
|
||||||
for (size_t I = 0; I != SmallAllocSize; ++I)
|
for (size_t I = 0; I != SmallAllocSize; ++I)
|
||||||
Source[I] = 0x55 + I;
|
Source[I] = 0x55 + I;
|
||||||
|
|
||||||
OrcRTCWrapperFunctionResult R =
|
__orc_rt_CWrapperFunctionResult R =
|
||||||
OrcRTCreateCWrapperFunctionResultFromRange(Source, SmallAllocSize);
|
__orc_rt_CreateCWrapperFunctionResultFromRange(Source, SmallAllocSize);
|
||||||
|
|
||||||
// Check that the inline storage in R.Data.Value contains the expected
|
// Check that the inline storage in R.Data.Value contains the expected
|
||||||
// sequence.
|
// sequence.
|
||||||
|
@ -106,7 +106,7 @@ TEST(CAPITest, CWrapperFunctionResultFromRangeSmall) {
|
||||||
<< "Unexpected value at index " << I;
|
<< "Unexpected value at index " << I;
|
||||||
|
|
||||||
// Check that we can dispose of the value.
|
// Check that we can dispose of the value.
|
||||||
OrcRTDisposeCWrapperFunctionResult(&R);
|
__orc_rt_DisposeCWrapperFunctionResult(&R);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CAPITest, CWrapperFunctionResultFromRangeLarge) {
|
TEST(CAPITest, CWrapperFunctionResultFromRangeLarge) {
|
||||||
|
@ -116,8 +116,8 @@ TEST(CAPITest, CWrapperFunctionResultFromRangeLarge) {
|
||||||
for (size_t I = 0; I != LargeAllocSize; ++I)
|
for (size_t I = 0; I != LargeAllocSize; ++I)
|
||||||
Source[I] = 0x55 + I;
|
Source[I] = 0x55 + I;
|
||||||
|
|
||||||
OrcRTCWrapperFunctionResult R =
|
__orc_rt_CWrapperFunctionResult R =
|
||||||
OrcRTCreateCWrapperFunctionResultFromRange(Source, LargeAllocSize);
|
__orc_rt_CreateCWrapperFunctionResultFromRange(Source, LargeAllocSize);
|
||||||
|
|
||||||
// Check that the inline storage in R.Data.Value contains the expected
|
// Check that the inline storage in R.Data.Value contains the expected
|
||||||
// sequence.
|
// sequence.
|
||||||
|
@ -127,7 +127,7 @@ TEST(CAPITest, CWrapperFunctionResultFromRangeLarge) {
|
||||||
<< "Unexpected value at index " << I;
|
<< "Unexpected value at index " << I;
|
||||||
|
|
||||||
// Check that we can dispose of the value.
|
// Check that we can dispose of the value.
|
||||||
OrcRTDisposeCWrapperFunctionResult(&R);
|
__orc_rt_DisposeCWrapperFunctionResult(&R);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CAPITest, CWrapperFunctionResultFromStringSmall) {
|
TEST(CAPITest, CWrapperFunctionResultFromStringSmall) {
|
||||||
|
@ -138,8 +138,8 @@ TEST(CAPITest, CWrapperFunctionResultFromStringSmall) {
|
||||||
Source[I] = 'a' + I;
|
Source[I] = 'a' + I;
|
||||||
Source[SmallAllocSize - 1] = '\0';
|
Source[SmallAllocSize - 1] = '\0';
|
||||||
|
|
||||||
OrcRTCWrapperFunctionResult R =
|
__orc_rt_CWrapperFunctionResult R =
|
||||||
OrcRTCreateCWrapperFunctionResultFromString(Source);
|
__orc_rt_CreateCWrapperFunctionResultFromString(Source);
|
||||||
|
|
||||||
// Check that the inline storage in R.Data.Value contains the expected
|
// Check that the inline storage in R.Data.Value contains the expected
|
||||||
// sequence.
|
// sequence.
|
||||||
|
@ -151,7 +151,7 @@ TEST(CAPITest, CWrapperFunctionResultFromStringSmall) {
|
||||||
<< "Unexpected value at index " << (SmallAllocSize - 1);
|
<< "Unexpected value at index " << (SmallAllocSize - 1);
|
||||||
|
|
||||||
// Check that we can dispose of the value.
|
// Check that we can dispose of the value.
|
||||||
OrcRTDisposeCWrapperFunctionResult(&R);
|
__orc_rt_DisposeCWrapperFunctionResult(&R);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CAPITest, CWrapperFunctionResultFromStringLarge) {
|
TEST(CAPITest, CWrapperFunctionResultFromStringLarge) {
|
||||||
|
@ -162,8 +162,8 @@ TEST(CAPITest, CWrapperFunctionResultFromStringLarge) {
|
||||||
Source[I] = 'a' + I;
|
Source[I] = 'a' + I;
|
||||||
Source[LargeAllocSize - 1] = '\0';
|
Source[LargeAllocSize - 1] = '\0';
|
||||||
|
|
||||||
OrcRTCWrapperFunctionResult R =
|
__orc_rt_CWrapperFunctionResult R =
|
||||||
OrcRTCreateCWrapperFunctionResultFromString(Source);
|
__orc_rt_CreateCWrapperFunctionResultFromString(Source);
|
||||||
|
|
||||||
// Check that the inline storage in R.Data.Value contains the expected
|
// Check that the inline storage in R.Data.Value contains the expected
|
||||||
// sequence.
|
// sequence.
|
||||||
|
@ -175,26 +175,26 @@ TEST(CAPITest, CWrapperFunctionResultFromStringLarge) {
|
||||||
<< "Unexpected value at index " << (LargeAllocSize - 1);
|
<< "Unexpected value at index " << (LargeAllocSize - 1);
|
||||||
|
|
||||||
// Check that we can dispose of the value.
|
// Check that we can dispose of the value.
|
||||||
OrcRTDisposeCWrapperFunctionResult(&R);
|
__orc_rt_DisposeCWrapperFunctionResult(&R);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CAPITest, CWrapperFunctionResultFromOutOfBandError) {
|
TEST(CAPITest, CWrapperFunctionResultFromOutOfBandError) {
|
||||||
constexpr const char *ErrMsg = "test error message";
|
constexpr const char *ErrMsg = "test error message";
|
||||||
OrcRTCWrapperFunctionResult R =
|
__orc_rt_CWrapperFunctionResult R =
|
||||||
OrcRTCreateCWrapperFunctionResultFromOutOfBandError(ErrMsg);
|
__orc_rt_CreateCWrapperFunctionResultFromOutOfBandError(ErrMsg);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
EXPECT_DEATH({ OrcRTCWrapperFunctionResultData(&R); },
|
EXPECT_DEATH({ __orc_rt_CWrapperFunctionResultData(&R); },
|
||||||
"Cannot get data for out-of-band error value");
|
"Cannot get data for out-of-band error value");
|
||||||
EXPECT_DEATH({ OrcRTCWrapperFunctionResultSize(&R); },
|
EXPECT_DEATH({ __orc_rt_CWrapperFunctionResultSize(&R); },
|
||||||
"Cannot get size for out-of-band error value");
|
"Cannot get size for out-of-band error value");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXPECT_FALSE(OrcRTCWrapperFunctionResultEmpty(&R));
|
EXPECT_FALSE(__orc_rt_CWrapperFunctionResultEmpty(&R));
|
||||||
const char *OOBErrMsg = OrcRTCWrapperFunctionResultGetOutOfBandError(&R);
|
const char *OOBErrMsg = __orc_rt_CWrapperFunctionResultGetOutOfBandError(&R);
|
||||||
EXPECT_NE(OOBErrMsg, nullptr);
|
EXPECT_NE(OOBErrMsg, nullptr);
|
||||||
EXPECT_NE(OOBErrMsg, ErrMsg);
|
EXPECT_NE(OOBErrMsg, ErrMsg);
|
||||||
EXPECT_TRUE(strcmp(OOBErrMsg, ErrMsg) == 0);
|
EXPECT_TRUE(strcmp(OOBErrMsg, ErrMsg) == 0);
|
||||||
|
|
||||||
OrcRTDisposeCWrapperFunctionResult(&R);
|
__orc_rt_DisposeCWrapperFunctionResult(&R);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue