x86_cpu_features: allow testing for multiple features

This commit is contained in:
Eric Biggers 2016-10-23 22:35:10 -07:00
parent 0776bc94d7
commit 0e4c2c8597
4 changed files with 6 additions and 6 deletions

View File

@ -195,7 +195,7 @@ static u32 dispatch(u32 adler, const void *buffer, size_t size)
{
adler32_func_t f = DEFAULT_IMPL;
#if NEED_AVX2_IMPL && !defined(__AVX2__)
if (x86_have_cpu_feature(X86_CPU_FEATURE_AVX2))
if (x86_have_cpu_features(X86_CPU_FEATURE_AVX2))
f = adler32_avx2;
#endif
adler32_impl = f;

View File

@ -570,7 +570,7 @@ static u32 dispatch(u32 remainder, const u8 *buffer, size_t nbytes)
{
crc32_func_t f = DEFAULT_IMPL;
#if NEED_PCLMUL_IMPL && !defined(__PCLMUL__)
if (x86_have_cpu_feature(X86_CPU_FEATURE_PCLMULQDQ))
if (x86_have_cpu_features(X86_CPU_FEATURE_PCLMULQDQ))
f = crc32_pclmul;
#endif
crc32_impl = f;

View File

@ -842,7 +842,7 @@ dispatch(struct libdeflate_decompressor * restrict d,
{
decompress_func_t f = deflate_decompress_default;
#if X86_CPU_FEATURES_ENABLED
if (x86_have_cpu_feature(X86_CPU_FEATURE_BMI2))
if (x86_have_cpu_features(X86_CPU_FEATURE_BMI2))
f = deflate_decompress_bmi2;
#endif
decompress_impl = f;

View File

@ -34,13 +34,13 @@ extern u32 _x86_cpu_features;
extern void
x86_setup_cpu_features(void);
/* Does the processor have the specified feature? */
/* Does the processor have the specified feature(s)? */
static inline bool
x86_have_cpu_feature(u32 feature)
x86_have_cpu_features(u32 features)
{
if (_x86_cpu_features == 0)
x86_setup_cpu_features();
return _x86_cpu_features & feature;
return (_x86_cpu_features & features) == features;
}
#endif /* X86_CPU_FEATURES_ENABLED */