Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
104a3203
A
anbox
项目概览
openeuler
/
anbox
通知
24
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
anbox
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
104a3203
编写于
9月 12, 2018
作者:
S
Simon Fels
提交者:
GitHub
9月 12, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #912 from morphis/cpu-features-sanity-check
cmds: implement CPU feature sanity check via builtin compiler functions
上级
12386eba
ae8cefb7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
2 deletion
+34
-2
src/anbox/cmds/check_features.cpp
src/anbox/cmds/check_features.cpp
+31
-2
src/anbox/cmds/check_features.h
src/anbox/cmds/check_features.h
+3
-0
未找到文件。
src/anbox/cmds/check_features.cpp
浏览文件 @
104a3203
...
...
@@ -52,7 +52,7 @@ anbox::cmds::CheckFeatures::CheckFeatures()
cli
::
Name
{
"check-features"
},
cli
::
Usage
{
"check-features"
},
cli
::
Description
{
"Check that the host system supports all necessary features"
}}
{
action
([](
const
cli
::
Command
::
Context
&
)
{
action
([
this
](
const
cli
::
Command
::
Context
&
)
{
#if defined(CPU_FEATURES_ARCH_X86)
const
auto
info
=
cpu_features
::
GetX86Info
();
std
::
vector
<
std
::
string
>
missing_features
;
...
...
@@ -78,7 +78,7 @@ anbox::cmds::CheckFeatures::CheckFeatures()
}
}
if
(
missing_features
.
size
()
>
0
&&
!
is_whitelisted
)
{
if
(
missing_features
.
size
()
>
0
&&
!
is_whitelisted
&&
!
sanity_check_for_features
()
)
{
std
::
cerr
<<
"The CPU of your computer ("
<<
brand_string
<<
") does not support all"
<<
std
::
endl
<<
"features Anbox requires."
<<
std
::
endl
<<
"It is missing support for the following features: "
;
...
...
@@ -105,3 +105,32 @@ anbox::cmds::CheckFeatures::CheckFeatures()
#endif
});
}
// In case that the CPU supports AVX we take the decision as from our analysis
// of the output from the cpu_features library. If it does not we have to check
// further via the compiler builtins if we the CPU supports all mandatory features
// or not. In case that any is missing we will fail the test.
//
// This uses the compiler builtin function __builtin_cpu_supports which allows us
// to detect certain CPU features.
// See https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html
bool
anbox
::
cmds
::
CheckFeatures
::
sanity_check_for_features
()
{
#if defined(CPU_FEATURES_ARCH_X86)
if
(
__builtin_cpu_supports
(
"avx"
))
return
true
;
std
::
vector
<
std
::
string
>
missing_features
;
#define CHECK_FEATURE(name) \
if (!__builtin_cpu_supports(name)) \
missing_features.push_back(name);
CHECK_FEATURE
(
"sse4.1"
);
CHECK_FEATURE
(
"sse4.2"
);
CHECK_FEATURE
(
"ssse3"
);
return
missing_features
.
empty
();
#else
return
true
;
#endif
}
src/anbox/cmds/check_features.h
浏览文件 @
104a3203
...
...
@@ -29,6 +29,9 @@ namespace cmds {
class
CheckFeatures
:
public
cli
::
CommandWithFlagsAndAction
{
public:
CheckFeatures
();
private:
bool
sanity_check_for_features
();
};
}
// namespace cmds
}
// namespace anbox
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录