Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add workaround to build on ubuntu 20.04 #5

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,25 @@ endif()

add_executable(app src/app.cpp)

include(CheckSymbolExists)
check_symbol_exists(mallinfo2 malloc.h HAVE_MALLINFO2)

add_library(preloaded_heaptrack SHARED src/preloaded.cpp)
if(HAVE_MALLINFO2)
target_compile_definitions(preloaded_heaptrack
PRIVATE
HAVE_MALLINFO2
)
endif()

add_library(preloaded_tlsf SHARED src/preloaded_tlsf.cpp)
target_link_libraries(preloaded_tlsf PRIVATE tlsf::tlsf)
if(HAVE_MALLINFO2)
target_compile_definitions(preloaded_tlsf
PRIVATE
HAVE_MALLINFO2
)
endif()

install(TARGETS preloaded_heaptrack preloaded_tlsf DESTINATION lib)
install(TARGETS app DESTINATION bin)
Expand Down
2 changes: 2 additions & 0 deletions src/preloaded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,15 @@ struct mallinfo mallinfo()
return orig();
}

#ifdef HAVE_MALLINFO2
using mallinfo2_type = struct mallinfo2 (*)( void);
struct mallinfo2 mallinfo2()
{
static mallinfo2_type orig = reinterpret_cast<mallinfo2_type>(dlsym(RTLD_NEXT, "mallinfo2"));
printf("hoge: mallinfo2 called\n");
return orig();
}
#endif

using mallopt_type = int (*)(int, int);
int mallopt(int param, int value)
Expand Down
2 changes: 2 additions & 0 deletions src/preloaded_tlsf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,15 @@ struct mallinfo mallinfo()
return orig();
}

#ifdef HAVE_MALLINFO2
using mallinfo2_type = struct mallinfo2 (*)( void);
struct mallinfo2 mallinfo2()
{
static mallinfo2_type orig = reinterpret_cast<mallinfo2_type>(dlsym(RTLD_NEXT, "mallinfo2"));
printf("hoge: mallinfo2 called\n");
return orig();
}
#endif

using mallopt_type = int (*)(int, int);
int mallopt(int param, int value)
Expand Down
Loading