Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
9080cc15
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
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看板
提交
9080cc15
编写于
4月 17, 2011
作者:
R
Rich Felker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean up handling of thread/nothread mode, locking
上级
eb0e8fa0
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
16 addition
and
27 deletion
+16
-27
src/internal/libc.h
src/internal/libc.h
+3
-4
src/internal/stdio_impl.h
src/internal/stdio_impl.h
+1
-1
src/process/fork.c
src/process/fork.c
+1
-1
src/stdio/flockfile.c
src/stdio/flockfile.c
+1
-4
src/stdio/ftrylockfile.c
src/stdio/ftrylockfile.c
+0
-1
src/thread/cancel_impl.c
src/thread/cancel_impl.c
+1
-1
src/thread/pthread_create.c
src/thread/pthread_create.c
+8
-14
src/thread/pthread_setcancelstate.c
src/thread/pthread_setcancelstate.c
+1
-1
未找到文件。
src/internal/libc.h
浏览文件 @
9080cc15
...
...
@@ -7,8 +7,8 @@
struct
__libc
{
int
*
(
*
errno_location
)(
void
);
void
(
*
testcancel
)(
void
);
void
(
*
lock
)(
volatile
int
*
)
;
void
(
*
lockfile
)(
FILE
*
)
;
int
threaded
;
int
canceldisable
;
void
(
*
fork_handler
)(
int
);
int
(
*
atexit
)(
void
(
*
)(
void
));
void
(
*
fini
)(
void
);
...
...
@@ -16,7 +16,6 @@ struct __libc {
volatile
int
threads_minus_1
;
int
ofl_lock
;
FILE
*
ofl_head
;
int
canceldisable
;
};
...
...
@@ -40,7 +39,7 @@ extern struct __libc *__libc_loc(void) __attribute__((const));
void
__lock
(
volatile
int
*
);
void
__lockfile
(
FILE
*
);
#define LOCK(x) (libc.threads_minus_1 ? (__lock(x),1) : ((void)(x),1))
#define UNLOCK(x) (*(x)=0)
#define UNLOCK(x) (*(
volatile int *)(
x)=0)
int
__rsyscall
(
int
,
long
,
long
,
long
,
long
,
long
,
long
);
...
...
src/internal/stdio_impl.h
浏览文件 @
9080cc15
...
...
@@ -24,7 +24,7 @@
#define UNGET 8
#define FLOCK(f) ((libc.
lockfile && (f)->lock>=0) ? (libc.
lockfile((f)),0) : 0)
#define FLOCK(f) ((libc.
threads_minus_1 && (f)->lock>=0) ? (__
lockfile((f)),0) : 0)
#define FUNLOCK(f) ((f)->lockcount && (--(f)->lockcount || ((f)->lock=0)))
#define F_PERM 1
...
...
src/process/fork.c
浏览文件 @
9080cc15
...
...
@@ -8,7 +8,7 @@ pid_t fork(void)
pid_t
ret
;
if
(
libc
.
fork_handler
)
libc
.
fork_handler
(
-
1
);
ret
=
syscall
(
SYS_fork
);
if
(
libc
.
lock
&&
!
ret
)
{
if
(
libc
.
threaded
&&
!
ret
)
{
pthread_t
self
=
__pthread_self
();
self
->
tid
=
self
->
pid
=
syscall
(
SYS_getpid
);
libc
.
threads_minus_1
=
0
;
...
...
src/stdio/flockfile.c
浏览文件 @
9080cc15
...
...
@@ -3,9 +3,6 @@
void
flockfile
(
FILE
*
f
)
{
if
(
!
libc
.
lockfile
)
{
pthread_self
();
libc
.
lockfile
=
__lockfile
;
}
if
(
!
libc
.
threaded
)
pthread_self
();
__lockfile
(
f
);
}
src/stdio/ftrylockfile.c
浏览文件 @
9080cc15
...
...
@@ -4,7 +4,6 @@
int
ftrylockfile
(
FILE
*
f
)
{
int
tid
=
pthread_self
()
->
tid
;
if
(
!
libc
.
lockfile
)
libc
.
lockfile
=
__lockfile
;
if
(
f
->
lock
==
tid
)
{
if
(
f
->
lockcount
==
INT_MAX
)
return
-
1
;
...
...
src/thread/cancel_impl.c
浏览文件 @
9080cc15
...
...
@@ -17,7 +17,7 @@ long (__syscall_cp)(long nr, long u, long v, long w, long x, long y, long z)
uintptr_t
old_sp
,
old_ip
;
long
r
;
if
(
!
libc
.
lock
||
(
self
=
__pthread_self
())
->
canceldisable
)
if
(
!
libc
.
threaded
||
(
self
=
__pthread_self
())
->
canceldisable
)
return
__syscall
(
nr
,
u
,
v
,
w
,
x
,
y
,
z
);
old_sp
=
self
->
cp_sp
;
...
...
src/thread/pthread_create.c
浏览文件 @
9080cc15
...
...
@@ -44,18 +44,6 @@ void __pthread_unwind_next(struct __ptcb *cb)
__syscall
(
SYS_exit
,
0
);
}
static
void
init_threads
()
{
sigset_t
set
;
libc
.
lock
=
__lock
;
libc
.
lockfile
=
__lockfile
;
sigemptyset
(
&
set
);
sigaddset
(
&
set
,
SIGSYSCALL
);
sigaddset
(
&
set
,
SIGCANCEL
);
__libc_sigprocmask
(
SIG_UNBLOCK
,
&
set
,
0
);
}
static
int
start
(
void
*
p
)
{
struct
pthread
*
self
=
p
;
...
...
@@ -79,7 +67,6 @@ weak_alias(dummy, __pthread_tsd_size);
int
pthread_create
(
pthread_t
*
res
,
const
pthread_attr_t
*
attr
,
void
*
(
*
entry
)(
void
*
),
void
*
arg
)
{
static
int
init
;
int
ret
;
size_t
size
,
guard
;
struct
pthread
*
self
=
pthread_self
(),
*
new
;
...
...
@@ -87,7 +74,14 @@ int pthread_create(pthread_t *res, const pthread_attr_t *attr, void *(*entry)(vo
const
pthread_attr_t
default_attr
=
{
0
};
if
(
!
self
)
return
ENOSYS
;
if
(
!
init
&&
++
init
)
init_threads
();
if
(
!
libc
.
threaded
)
{
sigset_t
set
;
sigemptyset
(
&
set
);
sigaddset
(
&
set
,
SIGSYSCALL
);
sigaddset
(
&
set
,
SIGCANCEL
);
__libc_sigprocmask
(
SIG_UNBLOCK
,
&
set
,
0
);
libc
.
threaded
=
1
;
}
if
(
!
attr
)
attr
=
&
default_attr
;
guard
=
ROUND
(
attr
->
_a_guardsize
+
DEFAULT_GUARD_SIZE
);
...
...
src/thread/pthread_setcancelstate.c
浏览文件 @
9080cc15
...
...
@@ -3,7 +3,7 @@
int
pthread_setcancelstate
(
int
new
,
int
*
old
)
{
if
(
new
>
1U
)
return
EINVAL
;
if
(
libc
.
lock
)
{
if
(
libc
.
threaded
)
{
struct
pthread
*
self
=
__pthread_self
();
if
(
old
)
*
old
=
self
->
canceldisable
;
self
->
canceldisable
=
new
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录