From 7fba4bf4db81996400fe7212cec967e44398c5d2 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 16 Feb 2023 00:51:43 +0100 Subject: [PATCH] btrfs-progs: add special CPU flag bit representing no features Add CPU_FLAG_NONE that's first in the list and represents a CPU without any acceleration features. Can be used for reference/fallback implementation. Signed-off-by: David Sterba --- common/cpu-utils.c | 7 ++++--- common/cpu-utils.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/cpu-utils.c b/common/cpu-utils.c index f7dda74f..3527a3cb 100644 --- a/common/cpu-utils.c +++ b/common/cpu-utils.c @@ -18,8 +18,8 @@ #include #include "common/cpu-utils.h" -unsigned long __cpu_flags = 0; -unsigned long __cpu_flags_orig = 0; +unsigned long __cpu_flags = CPU_FLAG_NONE; +unsigned long __cpu_flags_orig = CPU_FLAG_NONE; #ifdef __x86_64__ /* @@ -69,6 +69,7 @@ void cpu_detect_flags(void) unsigned int a, b, c, d; __builtin_cpu_init(); + __cpu_flags = CPU_FLAG_NONE; if (__builtin_cpu_supports("sse2")) __cpu_flags |= CPU_FLAG_SSE2; if (__builtin_cpu_supports("ssse3")) @@ -95,7 +96,7 @@ void cpu_set_level(unsigned long topbit) if (topbit) __cpu_flags &= (topbit << 1) - 1; else - __cpu_flags = 0; + __cpu_flags = CPU_FLAG_NONE; } void cpu_reset_level(void) diff --git a/common/cpu-utils.h b/common/cpu-utils.h index d5f492f0..e4a8641b 100644 --- a/common/cpu-utils.h +++ b/common/cpu-utils.h @@ -29,6 +29,7 @@ __ ## name ## _SEQ = __ ## name ## _BIT enum cpu_feature { + ENUM_CPU_BIT(CPU_FLAG_NONE), ENUM_CPU_BIT(CPU_FLAG_SSE2), ENUM_CPU_BIT(CPU_FLAG_SSSE3), ENUM_CPU_BIT(CPU_FLAG_SSE41),