Commit cfc1d564 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

x86: cpu -- Use bitwise operator for option check

Usually people simply leave cpu checkin in default
mode (which is fpu level) but idea was to be able
to compose a mixture of settings, for this sake
CPU_CAP_ constants are bit shifts. Thus use bitwise
operator for this.

Same time define CPU_CAP_ as bit shifts explicitly
and use explicit CPU_CAP_NONE compare where needed.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Reviewed-by: 's avatarDmitry Safonov <0x7f454c46@gmaill.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 8595dec9
......@@ -236,7 +236,7 @@ static int cpu_validate_features(compel_cpuinfo_t *cpu_info)
if (cpu_has_unsupported_features())
return -1;
if (opts.cpu_cap == CPU_CAP_FPU) {
if (opts.cpu_cap & CPU_CAP_FPU) {
/*
* If we're requested to check FPU only ignore
* any other bit. It's up to a user if the
......@@ -288,7 +288,7 @@ static int cpu_validate_features(compel_cpuinfo_t *cpu_info)
/*
* Capability on instructions level only.
*/
if (opts.cpu_cap == CPU_CAP_INS)
if (opts.cpu_cap & CPU_CAP_INS)
return cpu_validate_ins_features(cpu_info);
/*
......@@ -458,7 +458,7 @@ int cpuinfo_check(void)
* still allow to check instructions only
* and etc.
*/
if (!opts.cpu_cap)
if (opts.cpu_cap == CPU_CAP_NONE)
opts.cpu_cap = CPU_CAP_ALL;
if (cpu_validate_cpuinfo())
......
......@@ -24,11 +24,11 @@
/*
* CPU capability options.
*/
#define CPU_CAP_NONE (0u)
#define CPU_CAP_ALL (-1u)
#define CPU_CAP_FPU (1u) /* Only FPU capability required */
#define CPU_CAP_CPU (2u) /* Strict CPU capability required */
#define CPU_CAP_INS (4u) /* Instructions CPU capability */
#define CPU_CAP_NONE (0u << 0) /* Don't check capability at all */
#define CPU_CAP_FPU (1u << 0) /* Only FPU capability required */
#define CPU_CAP_CPU (1u << 1) /* Strict CPU capability required */
#define CPU_CAP_INS (1u << 2) /* Instructions CPU capability */
#define CPU_CAP_ALL (CPU_CAP_FPU | CPU_CAP_CPU | CPU_CAP_INS)
#define CPU_CAP_DEFAULT (CPU_CAP_FPU)
struct cg_root_opt {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment