Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
05df2105
提交
05df2105
3月 24, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add free_value to wq_for API
上级
58f3bfbd
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
26 行增加
和
10 行删除
+26
-10
xdu.cc
bin/xdu.cc
+1
-4
xls.cc
bin/xls.cc
+0
-2
dirit.hh
include/dirit.hh
+7
-1
wqfor.hh
include/wqfor.hh
+18
-3
没有找到文件。
bin/xdu.cc
浏览文件 @
05df2105
...
@@ -51,15 +51,12 @@ du(int fd)
...
@@ -51,15 +51,12 @@ du(int fd)
[](
dirit
&
i
)
->
bool
{
return
!
i
.
end
();
},
[](
dirit
&
i
)
->
bool
{
return
!
i
.
end
();
},
[
&
size
,
&
fd
](
const
char
*
name
)
->
void
[
&
size
,
&
fd
](
const
char
*
name
)
->
void
{
{
if
(
!
strcmp
(
name
,
"."
)
||
!
strcmp
(
name
,
".."
))
{
if
(
!
strcmp
(
name
,
"."
)
||
!
strcmp
(
name
,
".."
))
free
((
void
*
)
name
);
return
;
return
;
}
int
nfd
=
openat
(
fd
,
name
,
0
);
int
nfd
=
openat
(
fd
,
name
,
0
);
if
(
nfd
>=
0
)
if
(
nfd
>=
0
)
size
+=
du
(
nfd
);
// should go into work queue
size
+=
du
(
nfd
);
// should go into work queue
free
((
void
*
)
name
);
});
});
}
else
{
}
else
{
close
(
fd
);
close
(
fd
);
...
...
bin/xls.cc
浏览文件 @
05df2105
...
@@ -67,14 +67,12 @@ ls(const char *path)
...
@@ -67,14 +67,12 @@ ls(const char *path)
struct
stat
st
;
struct
stat
st
;
if
(
xfstatat
(
fd
,
name
,
&
st
)
<
0
){
if
(
xfstatat
(
fd
,
name
,
&
st
)
<
0
){
printf
(
"ls: cannot stat %s
\n
"
,
name
);
printf
(
"ls: cannot stat %s
\n
"
,
name
);
free
((
void
*
)
name
);
return
;
return
;
}
}
if
(
!
silent
)
if
(
!
silent
)
printf
(
"%u %10lu %10lu %s
\n
"
,
printf
(
"%u %10lu %10lu %s
\n
"
,
ST_TYPE
(
st
),
ST_INO
(
st
),
ST_SIZE
(
st
),
name
);
ST_TYPE
(
st
),
ST_INO
(
st
),
ST_SIZE
(
st
),
name
);
free
((
void
*
)
name
);
});
});
}
else
{
}
else
{
close
(
fd
);
close
(
fd
);
...
...
include/dirit.hh
浏览文件 @
05df2105
...
@@ -42,8 +42,14 @@ private:
...
@@ -42,8 +42,14 @@ private:
};
};
static
inline
const
char
*
static
inline
const
char
*
copy_value
(
const
dirit
&
it
)
copy_value
(
dirit
&
it
)
{
{
char
*
buf
=
(
char
*
)
malloc
(
256
);
char
*
buf
=
(
char
*
)
malloc
(
256
);
return
it
.
name
(
buf
,
256
);
return
it
.
name
(
buf
,
256
);
}
}
static
inline
void
free_value
(
dirit
&
it
,
const
char
*
name
)
{
free
((
void
*
)
name
);
}
include/wqfor.hh
浏览文件 @
05df2105
...
@@ -21,6 +21,7 @@ struct forwork : public work {
...
@@ -21,6 +21,7 @@ struct forwork : public work {
wq_push
(
w
);
wq_push
(
w
);
}
}
body_
(
v
);
body_
(
v
);
free_value
(
it_
,
v
);
frame_
.
dec
();
frame_
.
dec
();
delete
this
;
delete
this
;
}
}
...
@@ -60,22 +61,36 @@ wq_for(IT &init, bool (*cond)(IT &it), BODY body)
...
@@ -60,22 +61,36 @@ wq_for(IT &init, bool (*cond)(IT &it), BODY body)
}
}
body
(
v
);
body
(
v
);
free_value
(
init
,
v
);
while
(
!
frame
.
zero
())
while
(
!
frame
.
zero
())
wq_trywork
();
wq_trywork
();
}
}
// For debugging
// Same API as wq_for but serially executes body
template
<
typename
IT
,
typename
BODY
>
template
<
typename
IT
,
typename
BODY
>
static
inline
void
static
inline
void
wq_for_serial
(
IT
&
init
,
bool
(
*
cond
)(
IT
&
it
),
BODY
body
)
wq_for_serial
(
IT
&
init
,
bool
(
*
cond
)(
IT
&
it
),
BODY
body
)
{
{
for
(;
cond
(
init
);
++
init
)
for
(;
cond
(
init
);
++
init
)
{
body
(
copy_value
(
init
));
decltype
(
copy_value
(
init
))
v
=
copy_value
(
init
);
body
(
v
);
free_value
(
init
,
v
);
}
}
}
// Default copy_value
template
<
typename
T
>
template
<
typename
T
>
static
inline
T
static
inline
T
copy_value
(
const
T
&
it
)
copy_value
(
T
&
it
)
{
{
return
it
;
return
it
;
}
}
// Default free_value
template
<
typename
T
>
static
inline
void
free_value
(
T
&
it
,
T
&
v
)
{
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论