mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-08-04 10:16:44 -04:00

* Bring in common headers and program code from xpack project * Move program code to programs/ * Move library code to lib/ * GNU89 and MSVC2010 compatibility * Other changes
48 lines
1.1 KiB
C
48 lines
1.1 KiB
C
/*
|
|
* x86_cpu_features.h - feature detection for x86 processors
|
|
*/
|
|
|
|
#ifndef _LIB_X86_CPU_FEATURES_H
|
|
#define _LIB_X86_CPU_FEATURES_H
|
|
|
|
#include "common_defs.h"
|
|
|
|
#if defined(__x86_64__) && COMPILER_SUPPORTS_TARGET_FUNCTION_ATTRIBUTE
|
|
# define X86_CPU_FEATURES_ENABLED 1
|
|
#else
|
|
# define X86_CPU_FEATURES_ENABLED 0
|
|
#endif
|
|
|
|
#if X86_CPU_FEATURES_ENABLED
|
|
|
|
#define X86_CPU_FEATURE_SSE 0x00000001
|
|
#define X86_CPU_FEATURE_SSE2 0x00000002
|
|
#define X86_CPU_FEATURE_SSE3 0x00000004
|
|
#define X86_CPU_FEATURE_SSSE3 0x00000008
|
|
#define X86_CPU_FEATURE_SSE4_1 0x00000010
|
|
#define X86_CPU_FEATURE_SSE4_2 0x00000020
|
|
#define X86_CPU_FEATURE_AVX 0x00000040
|
|
#define X86_CPU_FEATURE_BMI 0x00000080
|
|
#define X86_CPU_FEATURE_AVX2 0x00000100
|
|
#define X86_CPU_FEATURE_BMI2 0x00000200
|
|
|
|
#define X86_CPU_FEATURES_KNOWN 0x80000000
|
|
|
|
extern u32 _x86_cpu_features;
|
|
|
|
extern void
|
|
x86_setup_cpu_features(void);
|
|
|
|
/* Does the processor have the specified feature? */
|
|
static inline bool
|
|
x86_have_cpu_feature(u32 feature)
|
|
{
|
|
if (_x86_cpu_features == 0)
|
|
x86_setup_cpu_features();
|
|
return _x86_cpu_features & feature;
|
|
}
|
|
|
|
#endif /* X86_CPU_FEATURES_ENABLED */
|
|
|
|
#endif /* _LIB_X86_CPU_FEATURES_H */
|