mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-09-17 08:17:30 -04:00
x86_cpu_features: allow testing for multiple features
This commit is contained in:
parent
0776bc94d7
commit
0e4c2c8597
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user