Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
58f3bfbd
提交
58f3bfbd
3月 24, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support primitive integral types in wq_for without a wrapper
上级
a08f3595
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
26 行增加
和
38 行删除
+26
-38
mktree.cc
bin/mktree.cc
+3
-4
dirit.hh
include/dirit.hh
+10
-8
wqfor.hh
include/wqfor.hh
+13
-5
wqit.hh
include/wqit.hh
+0
-21
没有找到文件。
bin/mktree.cc
浏览文件 @
58f3bfbd
...
...
@@ -4,7 +4,6 @@
#include "lib.h"
#include "fcntl.h"
#include "wq.hh"
#include "wqit.hh"
static
int
branch
;
...
...
@@ -12,9 +11,9 @@ static void
dolevel
(
int
fd
,
int
depth
)
{
if
(
depth
>
0
)
{
wq_num
<
int
>
it
(
0
);
wq_for_serial
<
wq_num
<
int
>
>
(
it
,
[](
wq_num
<
int
>
&
it
)
->
bool
{
return
it
<
branch
;
},
int
it
=
0
;
wq_for_serial
<
int
>
(
it
,
[](
int
&
it
)
->
bool
{
return
it
<
branch
;
},
[
&
fd
,
&
depth
](
int
i
)
->
void
{
char
name
[]
=
"a"
;
...
...
include/dirit.hh
浏览文件 @
58f3bfbd
...
...
@@ -13,14 +13,6 @@ public:
return
*
this
;
}
const
char
*
copy_value
()
{
char
*
buf
=
(
char
*
)
malloc
(
256
);
return
name
(
buf
,
256
);
}
bool
end
()
const
{
return
end_
;
}
private
:
char
*
name
(
char
*
buf
,
size_t
n
)
const
{
n
=
MIN
(
DIRSIZ
+
1
,
n
);
memmove
(
buf
,
de_
.
name
,
n
-
1
);
...
...
@@ -28,6 +20,9 @@ private:
return
buf
;
}
bool
end
()
const
{
return
end_
;
}
private
:
void
refill
(
void
)
{
int
r
;
...
...
@@ -45,3 +40,10 @@ private:
bool
end_
;
struct
dirent
de_
;
};
static
inline
const
char
*
copy_value
(
const
dirit
&
it
)
{
char
*
buf
=
(
char
*
)
malloc
(
256
);
return
it
.
name
(
buf
,
256
);
}
include/wqfor.hh
浏览文件 @
58f3bfbd
...
...
@@ -13,7 +13,7 @@ struct forwork : public work {
:
it_
(
it
),
cond_
(
cond
),
body_
(
body
),
frame_
(
frame
)
{}
virtual
void
run
()
{
decltype
(
it_
.
copy_value
())
v
=
it_
.
copy_value
(
);
decltype
(
copy_value
(
it_
))
v
=
copy_value
(
it_
);
++
it_
;
if
(
cond_
(
it_
))
{
forwork
<
IT
,
BODY
>
*
w
=
new
forwork
<
IT
,
BODY
>
(
it_
,
cond_
,
body_
,
frame_
);
...
...
@@ -48,7 +48,10 @@ wq_for(IT &init, bool (*cond)(IT &it), BODY body)
// XXX(sbw) should be able to coarsen loop
decltype
(
init
.
copy_value
())
v
=
init
.
copy_value
();
if
(
!
cond
(
init
))
return
;
decltype
(
copy_value
(
init
))
v
=
copy_value
(
init
);
++
init
;
if
(
cond
(
init
))
{
forwork
<
IT
,
BODY
>
*
w
=
new
forwork
<
IT
,
BODY
>
(
init
,
cond
,
body
,
frame
);
...
...
@@ -56,8 +59,6 @@ wq_for(IT &init, bool (*cond)(IT &it), BODY body)
wq_push
(
w
);
}
// XXX(sbw) oops, skip first cond check
body
(
v
);
while
(
!
frame
.
zero
())
...
...
@@ -69,5 +70,12 @@ static inline void
wq_for_serial
(
IT
&
init
,
bool
(
*
cond
)(
IT
&
it
),
BODY
body
)
{
for
(;
cond
(
init
);
++
init
)
body
(
init
.
copy_value
());
body
(
copy_value
(
init
));
}
template
<
typename
T
>
static
inline
T
copy_value
(
const
T
&
it
)
{
return
it
;
}
include/wqit.hh
deleted
100644 → 0
浏览文件 @
a08f3595
template
<
typename
T
>
struct
wq_num
{
wq_num
(
T
v
)
{
v_
=
v
;
}
bool
operator
!=
(
const
wq_num
<
T
>
&
i
)
const
{
return
v_
!=
i
.
v_
;
}
bool
operator
!=
(
const
T
&
v
)
const
{
return
v_
!=
v
;
}
bool
operator
<
(
const
wq_num
<
T
>
&
i
)
const
{
return
v_
<
i
.
v_
;
}
bool
operator
<
(
const
T
&
v
)
const
{
return
v_
<
v
;
}
T
copy_value
()
{
return
v_
;
}
wq_num
<
T
>&
operator
++
()
{
++
v_
;
return
*
this
;
}
T
v_
;
};
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论