Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
21ec438b
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
9 个月 前同步成功
通知
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看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
21ec438b
编写于
4月 21, 2022
作者:
F
fangting
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pthread_create.c中增加线程栈命名的功能
Signed-off-by:
N
fangting
<
fangting10@huawei.com
>
上级
a6b5f75a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
3 deletion
+16
-3
musl_src.gni
musl_src.gni
+1
-0
porting/linux/user/src/thread/pthread_create.c
porting/linux/user/src/thread/pthread_create.c
+15
-3
未找到文件。
musl_src.gni
浏览文件 @
21ec438b
...
...
@@ -1854,6 +1854,7 @@ musl_src_porting_file = [
"src/exit/atexit.c",
"crt/arm/crti.s",
"crt/aarch64/crti.s",
"src/thread/pthread_create.c",
]
musl_inc_hook_files = [
...
...
porting/linux/user/src/thread/pthread_create.c
浏览文件 @
21ec438b
#define _GNU_SOURCE
#define ANON_STACK_NAME_SIZE 50
#include "pthread_impl.h"
#include "stdio_impl.h"
#include "libc.h"
...
...
@@ -7,6 +8,7 @@
#include <string.h>
#include <stddef.h>
#include <stdarg.h>
#include <sys/prctl.h>
void
log_print
(
const
char
*
info
,...)
{
...
...
@@ -231,9 +233,9 @@ static void init_file_lock(FILE *f)
int
__pthread_create
(
pthread_t
*
restrict
res
,
const
pthread_attr_t
*
restrict
attrp
,
void
*
(
*
entry
)(
void
*
),
void
*
restrict
arg
)
{
int
ret
,
c11
=
(
attrp
==
__ATTRP_C11_THREAD
);
size_t
size
,
guard
;
size_t
size
,
guard
,
size_len
;
struct
pthread
*
self
,
*
new
;
unsigned
char
*
map
=
0
,
*
stack
=
0
,
*
tsd
=
0
,
*
stack_limit
;
unsigned
char
*
map
=
0
,
*
stack
=
0
,
*
tsd
=
0
,
*
stack_limit
,
*
start_addr
;
unsigned
flags
=
CLONE_VM
|
CLONE_FS
|
CLONE_FILES
|
CLONE_SIGHAND
|
CLONE_THREAD
|
CLONE_SYSVSEM
|
CLONE_SETTLS
|
CLONE_PARENT_SETTID
|
CLONE_CHILD_CLEARTID
|
CLONE_DETACHED
;
...
...
@@ -293,15 +295,25 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
__munmap
(
map
,
size
);
goto
fail
;
}
char
guard_name
[
ANON_STACK_NAME_SIZE
];
snprintf
(
guard_name
,
ANON_STACK_NAME_SIZE
,
"guard:%d"
,
__pthread_self
()
->
tid
);
prctl
(
PR_SET_VMA
,
PR_SET_VMA_ANON_NAME
,
map
,
guard
,
guard_name
);
start_addr
=
map
+
guard
;
size_len
=
size
-
guard
;
}
else
{
map
=
__mmap
(
0
,
size
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_ANON
,
-
1
,
0
);
if
(
map
==
MAP_FAILED
)
goto
fail
;
start_addr
=
map
;
size_len
=
size
;
}
tsd
=
map
+
size
-
__pthread_tsd_size
;
if
(
!
stack
)
{
stack
=
tsd
-
libc
.
tls_size
;
stack_limit
=
map
+
guard
;
}
char
name
[
ANON_STACK_NAME_SIZE
];
snprintf
(
name
,
ANON_STACK_NAME_SIZE
,
"stack:%d"
,
__pthread_self
()
->
tid
);
prctl
(
PR_SET_VMA
,
PR_SET_VMA_ANON_NAME
,
start_addr
,
size_len
,
name
);
}
new
=
__copy_tls
(
tsd
-
libc
.
tls_size
);
...
...
@@ -419,4 +431,4 @@ pid_t __pthread_gettid_np(pthread_t t)
__tl_unlock
();
return
thread
?
thread
->
tid
:
-
1
;
}
weak_alias
(
__pthread_gettid_np
,
pthread_gettid_np
);
\ No newline at end of file
weak_alias
(
__pthread_gettid_np
,
pthread_gettid_np
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录