cpu-feature: Add a common class to query available CPU features
Currently supported is x86/x64 via cpuid() for some common features.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Martin Willi
|
||||
* Copyright (C) 2015 revosec AG
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup cpu_feature cpu_feature
|
||||
* @{ @ingroup utils
|
||||
*/
|
||||
|
||||
#ifndef CPU_FEATURE_H_
|
||||
#define CPU_FEATURE_H_
|
||||
|
||||
#include <library.h>
|
||||
|
||||
typedef enum {
|
||||
/** x86/x64 extensions */
|
||||
CPU_FEATURE_MMX = (1 << 0),
|
||||
CPU_FEATURE_SSE = (1 << 1),
|
||||
CPU_FEATURE_SSE2 = (1 << 2),
|
||||
CPU_FEATURE_SSE3 = (1 << 3),
|
||||
CPU_FEATURE_SSSE3 = (1 << 4),
|
||||
CPU_FEATURE_SSE41 = (1 << 5),
|
||||
CPU_FEATURE_SSE42 = (1 << 6),
|
||||
CPU_FEATURE_AVX = (1 << 7),
|
||||
CPU_FEATURE_RDRAND = (1 << 8),
|
||||
CPU_FEATURE_AESNI = (1 << 9),
|
||||
CPU_FEATURE_PCLMULQDQ = (1 << 10),
|
||||
} cpu_feature_t;
|
||||
|
||||
/**
|
||||
* Get a bitmask for all supported CPU features
|
||||
*/
|
||||
cpu_feature_t cpu_feature_get_all();
|
||||
|
||||
/**
|
||||
* Check if a given set of CPU features is available.
|
||||
*/
|
||||
bool cpu_feature_available(cpu_feature_t feature);
|
||||
|
||||
#endif /** CPU_FEATURE_H_ @}*/
|
||||
Reference in New Issue
Block a user