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 <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-02-16 00:51:43 +01:00
parent 79b3ed9ab8
commit 7fba4bf4db
2 changed files with 5 additions and 3 deletions

View File

@ -18,8 +18,8 @@
#include <stdbool.h> #include <stdbool.h>
#include "common/cpu-utils.h" #include "common/cpu-utils.h"
unsigned long __cpu_flags = 0; unsigned long __cpu_flags = CPU_FLAG_NONE;
unsigned long __cpu_flags_orig = 0; unsigned long __cpu_flags_orig = CPU_FLAG_NONE;
#ifdef __x86_64__ #ifdef __x86_64__
/* /*
@ -69,6 +69,7 @@ void cpu_detect_flags(void)
unsigned int a, b, c, d; unsigned int a, b, c, d;
__builtin_cpu_init(); __builtin_cpu_init();
__cpu_flags = CPU_FLAG_NONE;
if (__builtin_cpu_supports("sse2")) if (__builtin_cpu_supports("sse2"))
__cpu_flags |= CPU_FLAG_SSE2; __cpu_flags |= CPU_FLAG_SSE2;
if (__builtin_cpu_supports("ssse3")) if (__builtin_cpu_supports("ssse3"))
@ -95,7 +96,7 @@ void cpu_set_level(unsigned long topbit)
if (topbit) if (topbit)
__cpu_flags &= (topbit << 1) - 1; __cpu_flags &= (topbit << 1) - 1;
else else
__cpu_flags = 0; __cpu_flags = CPU_FLAG_NONE;
} }
void cpu_reset_level(void) void cpu_reset_level(void)

View File

@ -29,6 +29,7 @@
__ ## name ## _SEQ = __ ## name ## _BIT __ ## name ## _SEQ = __ ## name ## _BIT
enum cpu_feature { enum cpu_feature {
ENUM_CPU_BIT(CPU_FLAG_NONE),
ENUM_CPU_BIT(CPU_FLAG_SSE2), ENUM_CPU_BIT(CPU_FLAG_SSE2),
ENUM_CPU_BIT(CPU_FLAG_SSSE3), ENUM_CPU_BIT(CPU_FLAG_SSSE3),
ENUM_CPU_BIT(CPU_FLAG_SSE41), ENUM_CPU_BIT(CPU_FLAG_SSE41),