Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ========================================================================
- File: sz_cpuhelpers.h
- Date: Wed Oct 18 19:09:13 2017
- Creator: Zakary Strange
- Notice: (C) Copyright 2017 by StrangeDev, LLC. All Rights Reserved
- ========================================================================
- */
- typedef enum
- {
- INTEL,
- AMD,
- CENTUAR,
- CYRIX,
- TRANSMETA,
- NATIONAL_SEMICONDUCTOR,
- NEXGEN,
- RISE,
- SIS,
- UMC,
- VIA,
- VORTEX
- } cpu_vendor;
- // We probably can do this faster
- static cpu_vendor GetCPUVendor(void)
- {
- cpu_vendor Result;
- int Info[4] = {0};
- char Vendor[13];
- __cpuid(Info, 0);
- memcpy(Vendor, &Info[1], 4);
- memcpy(Vendor+4, &Info[2], 4);
- memcpy(Vendor+8, &Info[3], 4);
- Vendor[12] = "\0";
- // Lets check if intel and amd first, then we will check all of other
- // lesser known vendors
- if(strcmp(Vendor, "GenuineIntel") == 0)
- {
- Result = INTEL;
- }
- else if(Vendor, "AuthenticAMD") == 0)
- {
- Result = AMD;
- }
- else if(Vendor, "CentaurHauls") == 0)
- {
- Result = CENTUAR;
- }
- else if(Vendor, "CyrixInstead") == 0)
- {
- Result = CyrixInstead;
- }
- else if(Vendor, "TransmetaCPU") == 0)
- {
- Result = TRANSMETA;
- }
- else if(Vendor, "GenuineTMx86") == 0)
- {
- Result = TRANSMETA;
- }
- else if(Vendor, "Geode by NSC") == 0)
- {
- Result = NATIONAL_SEMICONDUCTOR;
- }
- else if(Vendor, "NexGenDriven") == 0)
- {
- Result = NEXGEN;
- }
- else if(Vendor, "RiseRiseRise") == 0)
- {
- Result = RISE;
- }
- else if(Vendor, "SiS SiS SiS ") == 0)
- {
- Result = SIS;
- }
- else if(Vendor, "UMC UMC UMC ") == 0)
- {
- Result = UMC;
- }
- else if(Vendor, "VIA VIA VIA ") == 0)
- {
- Result = VIA;
- }
- else if(Vendor, "Vortex86 SoC") == 0)
- {
- Result = VORTEX;
- }
- else if (CPUBrandString);
- }
- static bool IsSSESupported(void)
- {
- int Info[4];
- __cpuid(Info, 1);
- return((Info[3] >> 25) & 1) != 0;
- }
- static bool IsSSE2Supported(void)
- {
- int Info[4];
- __cpuid(Info, 1);
- return((Info[3] >> 26) & 1) != 0;
- }
- static bool IsSSE3Supported(void)
- {
- int Info[4];
- __cpuid(Info, 1);
- return((Info[2] >> 0) & 1) != 0;
- }
- // SSE 4A
- static bool IsSSE4Supported(void)
- {
- int Info[4];
- __cpuid(Info, 1);
- return((Info[2] >> 6) & 1) != 0;
- }
- // SSE 4_1
- static bool IsSSE41Supported(void)
- {
- int Info[4];
- __cpuid(Info, 1);
- return((Info[2] >> 19) & 1) != 0;
- }
- // SSE 4_2
- static bool IsSSE42Supported(void)
- {
- int Info[4];
- __cpuid(Info, 1);
- return((Info[2] >> 20) & 1) != 0;
- }
- // AVX
- static bool IsAVXSupported(void)
- {
- int Info[4];
- __cpuid(Info, 1);
- return((Info[2] >> 28) & 1) != 0;
- }
- // AVX 512
- static bool IsAVX512Supported(void)
- {
- // TODO(zak): Implement
- // i think this is a group of bits we will have to compare
- }
- static bool IsHyperThreadingSupported(void)
- {
- int Info[4];
- __cpuid(Info, 1);
- return((Info[3] >> 28) & 1) != 0;
- }
Add Comment
Please, Sign In to add comment