Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
06abeb9e
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
接近 2 年 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
06abeb9e
编写于
11月 04, 2022
作者:
C
ChenJie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support jemalloc
Signed-off-by:
N
ChenJie
<
chenjie174@huawei.com
>
上级
ffdb7b7c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
128 addition
and
0 deletion
+128
-0
musl_config.gni
musl_config.gni
+1
-0
musl_template.gni
musl_template.gni
+87
-0
porting/linux/user/src/malloc/jemalloc/jemalloc.c
porting/linux/user/src/malloc/jemalloc/jemalloc.c
+1
-0
porting/linux/user/src/malloc/malloc.c
porting/linux/user/src/malloc/malloc.c
+22
-0
porting/linux/user/src/malloc/malloc_usable_size.c
porting/linux/user/src/malloc/malloc_usable_size.c
+8
-0
porting/linux/user/src/malloc/memalign.c
porting/linux/user/src/malloc/memalign.c
+9
-0
未找到文件。
musl_config.gni
浏览文件 @
06abeb9e
...
...
@@ -32,6 +32,7 @@ declare_args() {
runtime_lib_path =
"//prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/12.0.1/lib"
user_custom_libc = true
use_jemalloc = false
musl_ported_dir = "intermidiates/${musl_target_os}/musl_src_ported"
musl_inc_out_dir = "usr/include/${musl_target_triple}"
uapi_dir = "//kernel/linux/patches/linux-5.10/prebuilts/usr/include"
...
...
musl_template.gni
浏览文件 @
06abeb9e
...
...
@@ -207,6 +207,66 @@ template("musl_libs") {
}
}
config("soft_jemalloc") {
configs = []
include_dirs = [
"${target_out_dir}/${musl_ported_dir}/arch/${musl_arch}",
"${target_out_dir}/${musl_ported_dir}/arch/generic",
"${target_out_dir}/${musl_ported_dir}/src/internal",
"${target_out_dir}/${musl_ported_dir}/src/include",
"${target_out_dir}/${musl_ported_dir}/include",
"${target_out_dir}/${musl_inc_out_dir}",
"${clang_base_path}/lib/clang/${clang_version}/include",
]
cflags = [
"--target=${musl_target_triple}",
"-D_GNU_SOURCE",
"-D_REENTRANT",
"-Wall",
"-Wshorten-64-to-32",
"-Wsign-compare",
"-Wundef",
"-Wno-format-zero-length",
"-pipe",
"-g3",
"-fvisibility=hidden",
"-O3",
"-funroll-loops",
# The following flags are for avoiding errors when compiling.
"-Wno-unused-parameter",
"-Wno-unused-function",
"-Wno-missing-field-initializers",
"-U_FORTIFY_SOURCE",
"-DOHOS_ENABLE_TCACHE",
"-DOHOS_LG_TCACHE_MAXCLASS_DEFAULT=16",
"-DOHOS_NUM_ARENAS=2",
"-DOHOS_TCACHE_NSLOTS_SMALL_MAX=8",
"-DOHOS_TCACHE_NSLOTS_LARGE=16",
]
if (musl_arch == "arm") {
cflags += [ "-march=armv7-a" ]
} else if (musl_arch == "aarch64") {
cflags += [ "-march=armv8" ]
} else if (musl_arch == "x86_64") {
cflags += [ "-march=x86-64" ]
}
include_dirs += [
"//third_party",
"//third_party/musl/src/include/",
"//third_party/jemalloc/include/",
"//third_party/jemalloc/include/jemalloc/internal",
"//third_party/jemalloc/include/jemalloc",
]
}
source_set("soft_musl_crt") {
sources = [
"${target_out_dir}/${musl_ported_dir}/crt/${musl_arch}/crti.s",
...
...
@@ -450,6 +510,11 @@ template("musl_libs") {
"-fstack-protector-strong",
]
if (use_jemalloc) {
defines += [ "USE_JEMALLOC" ]
include_dirs = [ "//third_party/jemalloc/include/jemalloc" ]
}
configs -= musl_inherited_configs
configs += [ ":soft_musl_config" ]
...
...
@@ -575,6 +640,24 @@ template("musl_libs") {
]
}
source_set("soft_musl_jemalloc") {
sources = [ "./porting/linux/user/src/malloc/jemalloc/jemalloc.c" ]
deps = [
"//third_party/musl:create_alltypes_h",
"//third_party/musl:create_porting_src",
"//third_party/musl:create_syscall_h",
"//third_party/musl:create_version_h",
"//third_party/musl:musl_copy_inc_bits",
"//third_party/musl:musl_copy_inc_root",
"//third_party/musl:musl_copy_inc_sys",
]
configs -= musl_inherited_configs
configs += [ ":soft_jemalloc" ]
}
static_library("soft_libc_musl_static") {
output_name = "libc"
complete_static_lib = true
...
...
@@ -692,6 +775,10 @@ template("musl_libs") {
if (is_standard_system) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
}
if (use_jemalloc) {
deps += [ ":soft_musl_jemalloc" ]
}
}
action_foreach("soft_musl_crt_install_action") {
...
...
porting/linux/user/src/malloc/jemalloc/jemalloc.c
0 → 100644
浏览文件 @
06abeb9e
#include "jemalloc/src/static.c"
\ No newline at end of file
porting/linux/user/src/malloc/malloc.c
浏览文件 @
06abeb9e
...
...
@@ -12,6 +12,14 @@
#include "malloc_random.h"
#include <sys/prctl.h>
#ifdef USE_JEMALLOC
#include <malloc.h>
extern
void
*
je_malloc
(
size_t
size
);
extern
void
*
je_calloc
(
size_t
count
,
size_t
size
);
extern
void
*
je_realloc
(
void
*
p
,
size_t
newsize
);
extern
void
je_free
(
void
*
p
);
#endif
#if defined(__GNUC__) && defined(__PIC__)
#define inline inline __attribute__((always_inline))
#endif
...
...
@@ -448,6 +456,9 @@ void *__libc_malloc(size_t n)
void
*
malloc
(
size_t
n
)
#endif
{
#ifdef USE_JEMALLOC
return
je_malloc
(
n
);
#endif
return
internal_malloc
(
n
);
}
...
...
@@ -555,6 +566,9 @@ static size_t mal0_clear(char *p, size_t pagesz, size_t n)
void
*
calloc
(
size_t
m
,
size_t
n
)
{
#ifdef USE_JEMALLOC
return
je_calloc
(
m
,
n
);
#endif
if
(
n
&&
m
>
(
size_t
)
-
1
/
n
){
errno
=
ENOMEM
;
return
0
;
...
...
@@ -591,6 +605,9 @@ void *internal_calloc(size_t m, size_t n)
void
*
realloc
(
void
*
p
,
size_t
n
)
{
#ifdef USE_JEMALLOC
return
je_realloc
(
p
,
n
);
#endif
struct
chunk
*
self
,
*
next
;
size_t
n0
,
n1
;
void
*
new
;
...
...
@@ -1036,6 +1053,9 @@ void __libc_free(void *p)
void
free
(
void
*
p
)
#endif
{
#ifdef USE_JEMALLOC
return
je_free
(
p
);
#endif
return
internal_free
(
p
);
}
...
...
@@ -1065,6 +1085,7 @@ void internal_free(void *p)
void
__malloc_donate
(
char
*
start
,
char
*
end
)
{
#ifndef USE_JEMALLOC
size_t
align_start_up
=
(
SIZE_ALIGN
-
1
)
&
(
-
(
uintptr_t
)
start
-
OVERHEAD
);
size_t
align_end_down
=
(
SIZE_ALIGN
-
1
)
&
(
uintptr_t
)
end
;
...
...
@@ -1085,4 +1106,5 @@ void __malloc_donate(char *start, char *end)
chunk_checksum_set
(
c
);
#endif
__bin_chunk
(
c
);
#endif
}
porting/linux/user/src/malloc/malloc_usable_size.c
浏览文件 @
06abeb9e
...
...
@@ -5,10 +5,18 @@
#include "atomic.h"
#endif
#ifdef USE_JEMALLOC
extern
size_t
je_malloc_usable_size
(
void
*
p
);
#endif
hidden
void
*
(
*
const
__realloc_dep
)(
void
*
,
size_t
)
=
realloc
;
size_t
malloc_usable_size
(
void
*
p
)
{
#ifdef USE_JEMALLOC
return
je_malloc_usable_size
(
p
);
#endif
#ifndef MALLOC_RED_ZONE
return
p
?
CHUNK_SIZE
(
MEM_TO_CHUNK
(
p
))
-
OVERHEAD
:
0
;
#else
...
...
porting/linux/user/src/malloc/memalign.c
浏览文件 @
06abeb9e
#include <stdlib.h>
#ifndef USE_JEMALLOC
#include <stdint.h>
#include <errno.h>
#include "malloc_impl.h"
#include "malloc_config.h"
#else
extern
void
*
je_memalign
(
size_t
align
,
size_t
len
);
#endif
void
*
__memalign
(
size_t
align
,
size_t
len
)
{
#ifdef USE_JEMALLOC
return
je_memalign
(
align
,
len
);
#else
unsigned
char
*
mem
,
*
new
;
if
((
align
&
-
align
)
!=
align
)
{
...
...
@@ -66,6 +74,7 @@ void *__memalign(size_t align, size_t len)
__bin_chunk
(
c
);
return
new
;
#endif
}
weak_alias
(
__memalign
,
memalign
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录