github.com/grailbio/base@v0.0.11/compress/libdeflate/cpu_features.h (about)

     1  /*
     2   * x86/cpu_features.h - feature detection for x86 processors
     3   */
     4  
     5  #ifndef LIB_X86_CPU_FEATURES_H
     6  #define LIB_X86_CPU_FEATURES_H
     7  
     8  #include "lib_common.h"
     9  
    10  #if (defined(__i386__) || defined(__x86_64__)) && \
    11  	COMPILER_SUPPORTS_TARGET_FUNCTION_ATTRIBUTE
    12  #  define X86_CPU_FEATURES_ENABLED 1
    13  #else
    14  #  define X86_CPU_FEATURES_ENABLED 0
    15  #endif
    16  
    17  #if X86_CPU_FEATURES_ENABLED
    18  
    19  #define X86_CPU_FEATURE_SSE2		0x00000001
    20  #define X86_CPU_FEATURE_PCLMULQDQ	0x00000002
    21  #define X86_CPU_FEATURE_AVX		0x00000004
    22  #define X86_CPU_FEATURE_AVX2		0x00000008
    23  #define X86_CPU_FEATURE_BMI2		0x00000010
    24  
    25  #define X86_CPU_FEATURES_KNOWN		0x80000000
    26  
    27  extern volatile u32 _cpu_features;
    28  
    29  extern void setup_cpu_features(void);
    30  
    31  static inline u32 get_cpu_features(void)
    32  {
    33  	if (_cpu_features == 0)
    34  		setup_cpu_features();
    35  	return _cpu_features;
    36  }
    37  
    38  #endif /* X86_CPU_FEATURES_ENABLED */
    39  
    40  #endif /* LIB_X86_CPU_FEATURES_H */