Skip to content

Commit 7a62130

Browse files
committed
Apply patch to jemalloc
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent bb34f53 commit 7a62130

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,30 @@ else()
139139
GIT_TAG ${UMF_JEMALLOC_TAG})
140140
FetchContent_MakeAvailable(jemalloc_targ)
141141

142+
if(jemalloc_targ_SOURCE_DIR)
143+
# apply patch for jemalloc
144+
execute_process(
145+
COMMAND
146+
git apply
147+
${PROJECT_SOURCE_DIR}/cmake/replace-free_default-with-umf_free_default.patch
148+
WORKING_DIRECTORY ${jemalloc_targ_SOURCE_DIR}
149+
OUTPUT_VARIABLE UMF_JEMALLOC_PATCH_OUTPUT
150+
ERROR_VARIABLE UMF_JEMALLOC_PATCH_ERROR)
151+
152+
if(UMF_JEMALLOC_PATCH_OUTPUT)
153+
message(
154+
STATUS
155+
"jemalloc patch command output:\n${UMF_JEMALLOC_PATCH_OUTPUT}"
156+
)
157+
endif()
158+
if(UMF_JEMALLOC_PATCH_ERROR)
159+
message(
160+
WARNING
161+
"jemalloc patch command output:\n${UMF_JEMALLOC_PATCH_ERROR}"
162+
)
163+
endif()
164+
endif()
165+
142166
add_custom_command(
143167
COMMAND ./autogen.sh
144168
WORKING_DIRECTORY ${jemalloc_targ_SOURCE_DIR}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/src/jemalloc.c b/src/jemalloc.c
2+
index 7655de4e..ccb50b4f 100644
3+
--- a/src/jemalloc.c
4+
+++ b/src/jemalloc.c
5+
@@ -2993,7 +2993,7 @@ isfree(tsd_t *tsd, void *ptr, size_t usize, tcache_t *tcache, bool slow_path) {
6+
7+
JEMALLOC_NOINLINE
8+
void
9+
-free_default(void *ptr) {
10+
+umf_free_default(void *ptr) {
11+
UTRACE(ptr, 0, 0);
12+
if (likely(ptr != NULL)) {
13+
/*
14+
@@ -3159,7 +3159,7 @@ je_free(void *ptr) {
15+
LOG("core.free.entry", "ptr: %p", ptr);
16+
17+
if (!free_fastpath(ptr, 0, false)) {
18+
- free_default(ptr);
19+
+ umf_free_default(ptr);
20+
}
21+
22+
LOG("core.free.exit", "");
23+
--
24+
2.34.1
25+

0 commit comments

Comments
 (0)