backend/codegen, runtime: support interop intrinsics and natives
This commit is contained in:
committed by
SvyatoslavScherbina
parent
3892820052
commit
4b694225c1
@@ -1,3 +1,6 @@
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@@ -187,4 +190,22 @@ OBJ_GETTER0(Kotlin_konan_internal_undefined) {
|
||||
RETURN_OBJ(nullptr);
|
||||
}
|
||||
|
||||
void* Kotlin_interop_malloc(KLong size, KInt align) {
|
||||
if (size > SIZE_MAX) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* result = malloc(size);
|
||||
if ((reinterpret_cast<uintptr_t>(result) & (align - 1)) != 0) {
|
||||
// Unaligned!
|
||||
RuntimeAssert(false, "unsupported alignment");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Kotlin_interop_free(void* ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user