Custom malloc support (#742)
This commit is contained in:
@@ -101,12 +101,25 @@ size_t strnlen(const char* buffer, size_t maxSize) {
|
||||
}
|
||||
|
||||
// Memory operations.
|
||||
#if KONAN_INTERNAL_DLMALLOC
|
||||
extern "C" void* dlcalloc(size_t, size_t);
|
||||
extern "C" void dlfree(void*);
|
||||
#endif
|
||||
|
||||
void* calloc(size_t count, size_t size) {
|
||||
#if KONAN_INTERNAL_DLMALLOC
|
||||
return dlcalloc(count, size);
|
||||
#else
|
||||
return ::calloc(count, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void free(void* pointer) {
|
||||
return ::free(pointer);
|
||||
#if KONAN_INTERNAL_DLMALLOC
|
||||
dlfree(pointer);
|
||||
#else
|
||||
::free(pointer);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Time operations.
|
||||
@@ -124,4 +137,11 @@ uint64_t getTimeMicros() {
|
||||
return duration_cast<microseconds>(high_resolution_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
|
||||
#if KONAN_INTERNAL_DLMALLOC
|
||||
// This function is being called when memory allocator needs more RAM.
|
||||
void* moreCore(int size) {
|
||||
return sbrk(size);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace konan
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -44,7 +44,7 @@ class ClangTarget(val target: KonanTarget, val konanProperties: KonanProperties)
|
||||
"-DUSE_GCC_UNWIND=1", "-DUSE_PE_COFF_SYMBOLS=1", "-DKONAN_WINDOWS=1")
|
||||
|
||||
KonanTarget.MACBOOK ->
|
||||
listOf("--sysroot=$sysRoot", "-mmacosx-version-min=10.11")
|
||||
listOf("--sysroot=$sysRoot", "-mmacosx-version-min=10.11", "-DKONAN_OSX=1")
|
||||
|
||||
KonanTarget.IPHONE ->
|
||||
listOf("-stdlib=libc++", "-arch", "arm64", "-isysroot", "$sysRoot", "-miphoneos-version-min=8.0.0")
|
||||
|
||||
Reference in New Issue
Block a user