mirror of
https://github.com/openharmony/third_party_mimalloc.git
synced 2026-07-01 07:28:51 -04:00
!14 Implement mi_malloc_backtrace stub, fix test-mallinfo2
Merge pull request !14 from Frolikov Boris/implement-mi_malloc_backtrace-stub
This commit is contained in:
+1
-1
@@ -381,7 +381,7 @@ endif()
|
||||
if (MI_BUILD_TESTS)
|
||||
enable_testing()
|
||||
|
||||
foreach(TEST_NAME api api-fill stress stats-print info mallinfo2 mallopt)
|
||||
foreach(TEST_NAME api api-fill stress stats-print info mallinfo2 mallopt backtrace)
|
||||
add_executable(mimalloc-test-${TEST_NAME} test/test-${TEST_NAME}.c)
|
||||
target_compile_definitions(mimalloc-test-${TEST_NAME} PRIVATE ${mi_defines})
|
||||
target_compile_options(mimalloc-test-${TEST_NAME} PRIVATE ${mi_cflags})
|
||||
|
||||
@@ -397,6 +397,9 @@ mi_decl_export void mi_option_set(mi_option_t option, long value);
|
||||
mi_decl_export void mi_option_set_default(mi_option_t option, long value);
|
||||
mi_decl_export int mi_mallopt(int param, int value);
|
||||
|
||||
// Stubs
|
||||
mi_decl_export ssize_t mi_malloc_backtrace(void *pointer, uintptr_t* frames, size_t frame_count);
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// "mi" prefixed implementations of various posix, Unix, Windows, and C++ allocation functions.
|
||||
// (This can be convenient when providing overrides of these functions as done in `mimalloc-override.h`.)
|
||||
|
||||
@@ -953,6 +953,10 @@ void* mi_new_reallocn(void* p, size_t newcount, size_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t mi_malloc_backtrace(void *pointer, uintptr_t* frames, size_t frame_count) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define cap_max(x, MAX_VALUE) ((x > MAX_VALUE) ? MAX_VALUE : x)
|
||||
#define cap(x) cap_max(x, INT_MAX)
|
||||
#define cap2(x) cap_max(x, SIZE_MAX)
|
||||
|
||||
@@ -115,6 +115,9 @@ without_mimalloc_test("xmalloc-test-default") {
|
||||
sources = [ "perfomance/xmalloc-test.c" ]
|
||||
}
|
||||
|
||||
mimalloc_unittest("test-backtrace") {
|
||||
}
|
||||
|
||||
group("mimalloc_test") {
|
||||
testonly = true
|
||||
deps = [
|
||||
@@ -122,6 +125,7 @@ group("mimalloc_test") {
|
||||
":bench-malloc-thread-default",
|
||||
":test-api",
|
||||
":test-api-fill",
|
||||
":test-backtrace",
|
||||
":test-disable",
|
||||
":test-info",
|
||||
":test-mallinfo2",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "mimalloc.h"
|
||||
#include "testhelper.h"
|
||||
|
||||
int main(void) {
|
||||
CHECK_BODY("test-mi_malloc_backtrace-stub", {
|
||||
result = mi_malloc_backtrace(NULL, NULL, 0) == 0;
|
||||
});
|
||||
return print_test_summary();
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <assert.h>
|
||||
#include "mimalloc.h"
|
||||
|
||||
#define ALLOC_NUM 100
|
||||
|
||||
@@ -10,7 +10,7 @@ void test_mallinfo2(void)
|
||||
{
|
||||
struct mallinfo2 mi2;
|
||||
|
||||
mi2 = mallinfo2();
|
||||
mi2 = mi_mallinfo2();
|
||||
|
||||
assert(mi2.hblks);
|
||||
assert(mi2.hblkhd);
|
||||
|
||||
Reference in New Issue
Block a user