Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
a3745243
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看板
提交
a3745243
编写于
3月 24, 2011
作者:
R
Rich Felker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify and optimize FILE lock handling
上级
d8dc2faf
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
14 addition
and
14 deletion
+14
-14
src/internal/stdio_impl.h
src/internal/stdio_impl.h
+2
-3
src/stdio/__lockfile.c
src/stdio/__lockfile.c
+7
-6
src/stdio/ftrylockfile.c
src/stdio/ftrylockfile.c
+3
-3
src/stdio/vsnprintf.c
src/stdio/vsnprintf.c
+1
-1
src/stdio/vswprintf.c
src/stdio/vswprintf.c
+1
-1
未找到文件。
src/internal/stdio_impl.h
浏览文件 @
a3745243
...
@@ -23,8 +23,8 @@
...
@@ -23,8 +23,8 @@
#define UNGET 4
#define UNGET 4
#define FLOCK(f) ((libc.lockfile && (f)->
owner
>=0) ? (libc.lockfile((f)),0) : 0)
#define FLOCK(f) ((libc.lockfile && (f)->
lock
>=0) ? (libc.lockfile((f)),0) : 0)
#define FUNLOCK(f) ((f)->lockcount && (--(f)->lockcount || ((f)->
owner=(f)->
lock=0)))
#define FUNLOCK(f) ((f)->lockcount && (--(f)->lockcount || ((f)->lock=0)))
#define F_PERM 1
#define F_PERM 1
#define F_NORD 4
#define F_NORD 4
...
@@ -59,7 +59,6 @@ struct __FILE_s {
...
@@ -59,7 +59,6 @@ struct __FILE_s {
off_t
(
*
seek
)(
FILE
*
,
off_t
,
int
);
off_t
(
*
seek
)(
FILE
*
,
off_t
,
int
);
int
mode
;
int
mode
;
int
(
*
close
)(
FILE
*
);
int
(
*
close
)(
FILE
*
);
int
owner
;
};
};
size_t
__stdio_read
(
FILE
*
,
unsigned
char
*
,
size_t
);
size_t
__stdio_read
(
FILE
*
,
unsigned
char
*
,
size_t
);
...
...
src/stdio/__lockfile.c
浏览文件 @
a3745243
...
@@ -3,17 +3,18 @@
...
@@ -3,17 +3,18 @@
void
__lockfile
(
FILE
*
f
)
void
__lockfile
(
FILE
*
f
)
{
{
int
spins
;
int
spins
=
100000
;
if
(
f
->
owner
<
0
)
return
;
int
tid
;
if
(
f
->
owner
&&
f
->
owner
==
__pthread_self
()
->
tid
)
{
if
(
f
->
lock
<
0
)
return
;
tid
=
__pthread_self
()
->
tid
;
if
(
f
->
lock
==
tid
)
{
while
(
f
->
lockcount
==
INT_MAX
);
while
(
f
->
lockcount
==
INT_MAX
);
f
->
lockcount
++
;
f
->
lockcount
++
;
return
;
return
;
}
}
spins
=
100000
;
while
(
f
->
lock
||
a_cas
(
&
f
->
lock
,
0
,
tid
))
while
(
a_swap
(
&
f
->
lock
,
1
))
if
(
spins
)
spins
--
,
a_spin
();
if
(
spins
)
spins
--
,
a_spin
();
else
syscall
(
SYS_sched_yield
);
else
syscall
(
SYS_sched_yield
);
f
->
owner
=
__pthread_self
()
->
tid
;
f
->
lockcount
=
1
;
f
->
lockcount
=
1
;
}
}
src/stdio/ftrylockfile.c
浏览文件 @
a3745243
...
@@ -3,16 +3,16 @@
...
@@ -3,16 +3,16 @@
int
ftrylockfile
(
FILE
*
f
)
int
ftrylockfile
(
FILE
*
f
)
{
{
int
tid
=
pthread_self
()
->
tid
;
if
(
!
libc
.
lockfile
)
libc
.
lockfile
=
__lockfile
;
if
(
!
libc
.
lockfile
)
libc
.
lockfile
=
__lockfile
;
if
(
f
->
owner
&&
f
->
owner
==
pthread_self
()
->
tid
)
{
if
(
f
->
lock
==
tid
)
{
if
(
f
->
lockcount
==
INT_MAX
)
if
(
f
->
lockcount
==
INT_MAX
)
return
-
1
;
return
-
1
;
f
->
lockcount
++
;
f
->
lockcount
++
;
return
0
;
return
0
;
}
}
if
(
a_swap
(
&
f
->
lock
,
1
))
if
(
f
->
lock
||
a_cas
(
&
f
->
lock
,
0
,
tid
))
return
-
1
;
return
-
1
;
f
->
owner
=
pthread_self
()
->
tid
;
f
->
lockcount
=
1
;
f
->
lockcount
=
1
;
return
0
;
return
0
;
}
}
src/stdio/vsnprintf.c
浏览文件 @
a3745243
...
@@ -17,7 +17,7 @@ int vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
...
@@ -17,7 +17,7 @@ int vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
f
.
write
=
sn_write
;
f
.
write
=
sn_write
;
f
.
buf_size
=
1
;
f
.
buf_size
=
1
;
f
.
buf
=
buf
;
f
.
buf
=
buf
;
f
.
owner
=
-
1
;
f
.
lock
=
-
1
;
if
(
n
>
INT_MAX
)
{
if
(
n
>
INT_MAX
)
{
errno
=
EOVERFLOW
;
errno
=
EOVERFLOW
;
return
-
1
;
return
-
1
;
...
...
src/stdio/vswprintf.c
浏览文件 @
a3745243
...
@@ -32,7 +32,7 @@ int vswprintf(wchar_t *s, size_t n, const wchar_t *fmt, va_list ap)
...
@@ -32,7 +32,7 @@ int vswprintf(wchar_t *s, size_t n, const wchar_t *fmt, va_list ap)
f
.
write
=
sw_write
;
f
.
write
=
sw_write
;
f
.
buf_size
=
sizeof
buf
;
f
.
buf_size
=
sizeof
buf
;
f
.
buf
=
buf
;
f
.
buf
=
buf
;
f
.
owner
=
-
1
;
f
.
lock
=
-
1
;
f
.
cookie
=
&
c
;
f
.
cookie
=
&
c
;
if
(
!
n
)
{
if
(
!
n
)
{
return
-
1
;
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录