winpr/sysinfo: fixes and detection for avx PCLMULQDQ added

- fixed defines for avx aes detection
- added detection for avx carry less multiplication (PF_EX_AVX_PCLMULQDQ)
This commit is contained in:
Bernhard Miklautz 2013-03-15 01:06:33 +01:00
parent 81580f10d9
commit 3bac044825
3 changed files with 15 additions and 4 deletions

View File

@ -301,6 +301,7 @@ WINPR_API BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature);
#define PF_EX_ARM_VFP4 11
#define PF_EX_ARM_IDIVA 12
#define PF_EX_ARM_IDIVT 13
#define PF_EX_AVX_PCLMULQDQ 14
/*
* some "aliases" for the standard defines

View File

@ -389,18 +389,20 @@ ULONGLONG GetTickCount64(void)
#define D_BIT_SSE2 (1<<26)
#define D_BIT_3DN (1<<30)
#define C_BIT_SSE3 (1<<0)
#define C_BIT_PCLMULQDQ (1<<1)
#define C_BIT_3DNP (1<<8)
#define C_BIT_3DNP (1<<8)
#define C_BIT_SSSE3 (1<<9)
#define C_BIT_SSE41 (1<<19)
#define C_BIT_SSE42 (1<<20)
#define C_BIT_XGETBV (1<<27)
#define C_BIT_FMA (1<<12)
#define C_BIT_AES (1<<25)
#define C_BIT_XGETBV (1<<27)
#define C_BIT_AVX (1<<28)
#define C_BITS_AVX (C_BIT_XGETBV|C_BIT_AVX)
#define E_BIT_XMM (1<<1)
#define E_BIT_YMM (1<<2)
#define E_BITS_AVX (E_BIT_XMM|E_BIT_YMM)
#define C_BIT_FMA (1<<11)
#define C_BIT_AVX_AES (1<<24)
static void cpuid(
unsigned info,
@ -660,13 +662,16 @@ BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature)
case PF_EX_AVX:
case PF_EX_FMA:
case PF_EX_AVX_AES:
case PF_EX_AVX_PCLMULQDQ:
{
/* Check for general AVX support */
if ((c & C_BITS_AVX) != C_BITS_AVX)
break;
int e, f;
xgetbv(0, e, f);
/* XGETBV enabled for applications and XMM/YMM states enabled */
if ((e & E_BITS_AVX) == E_BITS_AVX)
{
switch (ProcessorFeature)
@ -679,7 +684,11 @@ BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature)
ret = TRUE;
break;
case PF_EX_AVX_AES:
if (c & C_BIT_AVX_AES)
if (c & C_BIT_AES)
ret = TRUE;
break;
case PF_EX_AVX_PCLMULQDQ:
if (c & C_BIT_PCLMULQDQ)
ret = TRUE;
break;
}

View File

@ -21,6 +21,7 @@ int TestCPUFeatures(int argc, char* argv[])
printf("\tPF_EX_AVX: %s\n", IsProcessorFeaturePresentEx(PF_EX_AVX) ? "yes" : "no");
printf("\tPF_EX_FMA: %s\n", IsProcessorFeaturePresentEx(PF_EX_FMA) ? "yes" : "no");
printf("\tPF_EX_AVX_AES: %s\n", IsProcessorFeaturePresentEx(PF_EX_AVX_AES) ? "yes" : "no");
printf("\tPF_EX_AVX_PCLMULQDQD: %s\n", IsProcessorFeaturePresentEx(PF_EX_AVX_PCLMULQDQ) ? "yes" : "no");
#elif defined(_M_ARM)
printf("\tPF_ARM_NEON_INSTRUCTIONS_AVAILABLE: %s\n", IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) ? "yes" : "no");
printf("\tPF_ARM_THUMB: %s\n", IsProcessorFeaturePresent(PF_ARM_THUMB) ? "yes" : "no");