Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
1a9a2ff7
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看板
提交
1a9a2ff7
编写于
2月 13, 2011
作者:
R
Rich Felker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reorganize thread exit code, make pthread_exit call cancellation handlers (pt2)
上级
50e26f09
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
23 deletion
+53
-23
include/limits.h
include/limits.h
+2
-1
src/thread/cancellation.c
src/thread/cancellation.c
+1
-9
src/thread/pthread_create.c
src/thread/pthread_create.c
+50
-13
未找到文件。
include/limits.h
浏览文件 @
1a9a2ff7
...
@@ -23,7 +23,8 @@
...
@@ -23,7 +23,8 @@
/* Implementation choices... */
/* Implementation choices... */
#define PTHREAD_KEYS_MAX 1024
#define PTHREAD_KEYS_MAX 1024
#define PTHREAD_STACK_MIN (2*PAGE_SIZE)
#define PTHREAD_STACK_MIN PAGE_SIZE
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
/* Arbitrary numbers... */
/* Arbitrary numbers... */
...
...
src/thread/cancellation.c
浏览文件 @
1a9a2ff7
...
@@ -7,16 +7,8 @@ void __pthread_register_cancel(struct __ptcb *cb)
...
@@ -7,16 +7,8 @@ void __pthread_register_cancel(struct __ptcb *cb)
self
->
cancelbuf
=
cb
;
self
->
cancelbuf
=
cb
;
}
}
#define pthread_self __pthread_self
void
__pthread_unregister_cancel
(
struct
__ptcb
*
cb
)
void
__pthread_unregister_cancel
(
struct
__ptcb
*
cb
)
{
{
struct
pthread
*
self
=
pthread_self
();
struct
pthread
*
self
=
__
pthread_self
();
self
->
cancelbuf
=
self
->
cancelbuf
->
__next
;
self
->
cancelbuf
=
self
->
cancelbuf
->
__next
;
}
}
void
__pthread_unwind_next
(
struct
__ptcb
*
cb
)
{
if
(
cb
->
__next
)
longjmp
((
void
*
)
cb
->
__next
->
__jb
,
1
);
pthread_exit
(
PTHREAD_CANCELLED
);
}
src/thread/pthread_create.c
浏览文件 @
1a9a2ff7
#include "pthread_impl.h"
#include "pthread_impl.h"
#define pthread_self __pthread_self
void
__pthread_unwind_next
(
struct
__ptcb
*
cb
)
{
int
i
,
j
,
not_finished
;
pthread_t
self
;
if
(
cb
->
__next
)
longjmp
((
void
*
)
cb
->
__next
->
__jb
,
1
);
self
=
pthread_self
();
if
(
self
->
cancel
)
self
->
result
=
PTHREAD_CANCELLED
;
if
(
!
a_fetch_add
(
&
libc
.
threads_minus_1
,
-
1
))
exit
(
0
);
LOCK
(
&
self
->
exitlock
);
not_finished
=
self
->
tsd_used
;
for
(
j
=
0
;
not_finished
&&
j
<
PTHREAD_DESTRUCTOR_ITERATIONS
;
j
++
)
{
not_finished
=
0
;
for
(
i
=
0
;
i
<
PTHREAD_KEYS_MAX
;
i
++
)
{
if
(
self
->
tsd
[
i
]
&&
libc
.
tsd_keys
[
i
])
{
void
*
tmp
=
self
->
tsd
[
i
];
self
->
tsd
[
i
]
=
0
;
libc
.
tsd_keys
[
i
](
tmp
);
not_finished
=
1
;
}
}
}
if
(
self
->
detached
&&
self
->
map_base
)
__unmapself
(
self
->
map_base
,
self
->
map_size
);
__syscall_exit
(
0
);
}
static
void
docancel
(
struct
pthread
*
self
)
static
void
docancel
(
struct
pthread
*
self
)
{
{
...
@@ -10,13 +42,21 @@ static void docancel(struct pthread *self)
...
@@ -10,13 +42,21 @@ static void docancel(struct pthread *self)
static
void
cancel_handler
(
int
sig
,
siginfo_t
*
si
,
void
*
ctx
)
static
void
cancel_handler
(
int
sig
,
siginfo_t
*
si
,
void
*
ctx
)
{
{
struct
pthread
*
self
=
pthread_self
();
struct
pthread
*
self
=
__
pthread_self
();
self
->
cancel
=
1
;
self
->
cancel
=
1
;
if
(
self
->
canceldisable
||
(
!
self
->
cancelasync
&&
!
self
->
cancelpoint
))
if
(
self
->
canceldisable
||
(
!
self
->
cancelasync
&&
!
self
->
cancelpoint
))
return
;
return
;
docancel
(
self
);
docancel
(
self
);
}
}
static
void
cancelpt
(
int
x
)
{
struct
pthread
*
self
=
__pthread_self
();
if
(
self
->
canceldisable
)
return
;
self
->
cancelpoint
=
x
;
if
(
self
->
cancel
)
docancel
(
self
);
}
/* "rsyscall" is a mechanism by which a thread can synchronously force all
/* "rsyscall" is a mechanism by which a thread can synchronously force all
* other threads to perform an arbitrary syscall. It is necessary to work
* other threads to perform an arbitrary syscall. It is necessary to work
* around the non-conformant implementation of setuid() et al on Linux,
* around the non-conformant implementation of setuid() et al on Linux,
...
@@ -50,7 +90,7 @@ static int rsyscall(int nr, long a, long b, long c, long d, long e, long f)
...
@@ -50,7 +90,7 @@ static int rsyscall(int nr, long a, long b, long c, long d, long e, long f)
{
{
int
i
,
ret
;
int
i
,
ret
;
sigset_t
set
=
{
0
};
sigset_t
set
=
{
0
};
struct
pthread
*
self
=
pthread_self
();
struct
pthread
*
self
=
__
pthread_self
();
sigaddset
(
&
set
,
SIGSYSCALL
);
sigaddset
(
&
set
,
SIGSYSCALL
);
LOCK
(
&
rs
.
lock
);
LOCK
(
&
rs
.
lock
);
...
@@ -90,14 +130,6 @@ static int rsyscall(int nr, long a, long b, long c, long d, long e, long f)
...
@@ -90,14 +130,6 @@ static int rsyscall(int nr, long a, long b, long c, long d, long e, long f)
return
ret
;
return
ret
;
}
}
static
void
cancelpt
(
int
x
)
{
struct
pthread
*
self
=
pthread_self
();
if
(
self
->
canceldisable
)
return
;
self
->
cancelpoint
=
x
;
if
(
self
->
cancel
)
docancel
(
self
);
}
static
void
init_threads
()
static
void
init_threads
()
{
{
struct
sigaction
sa
=
{
.
sa_flags
=
SA_SIGINFO
|
SA_RESTART
};
struct
sigaction
sa
=
{
.
sa_flags
=
SA_SIGINFO
|
SA_RESTART
};
...
@@ -120,8 +152,6 @@ static int start(void *p)
...
@@ -120,8 +152,6 @@ static int start(void *p)
return
0
;
return
0
;
}
}
#undef pthread_self
#define CLONE_MAGIC 0x7d0f00
#define CLONE_MAGIC 0x7d0f00
int
__clone
(
int
(
*
)(
void
*
),
void
*
,
int
,
void
*
,
pid_t
*
,
void
*
,
pid_t
*
);
int
__clone
(
int
(
*
)(
void
*
),
void
*
,
int
,
void
*
,
pid_t
*
,
void
*
,
pid_t
*
);
...
@@ -187,3 +217,10 @@ int pthread_create(pthread_t *res, const pthread_attr_t *attr, void *(*entry)(vo
...
@@ -187,3 +217,10 @@ int pthread_create(pthread_t *res, const pthread_attr_t *attr, void *(*entry)(vo
*
res
=
new
;
*
res
=
new
;
return
0
;
return
0
;
}
}
void
pthread_exit
(
void
*
result
)
{
struct
pthread
*
self
=
pthread_self
();
self
->
result
=
result
;
docancel
(
self
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录