// Detects the various cpu features void CPUInfo::Detect() { // Set some defaults here // When ARMv8 cpus come out, these need to be updated. HTT = false; #ifdef _M_ARM_64 OS64bit = true; CPU64bit = true; Mode64bit = true; #else OS64bit = false; CPU64bit = false; Mode64bit = false; #endif vendor = VENDOR_ARM; // Get the information about the CPU num_cores = GetCoreCount(); #if defined(__SYMBIAN32__) || defined(BLACKBERRY) || defined(IOS) bool isVFP3 = false; bool isVFP4 = false; #ifdef IOS isVFP3 = true; // Check for swift arch (VFP4`) #ifdef __ARM_ARCH_7S__ isVFP4 = true; #endif // #ifdef __ARM_ARCH_7S__ #elif defined(BLACKBERRY) isVFP3 = true; const char cpuInfoPath[] = "/pps/services/hw_info/inventory"; const std::string marker = "Processor_Name::"; const std::string qcCPU = "MSM"; std::string line; std::ifstream file(cpuInfoPath); if (file) { while (std::getline(file, line)) { if (line.find(marker) != std::string::npos) { std::string first_three_chars = line.substr(marker.length(), qcCPU.length()); if (first_three_chars == qcCPU) { isVFP4 = true; } break; } } } #endif // Hardcode this for now bSwp = true; bHalf = true; bThumb = false; bFastMult = true; bVFP = true; bEDSP = true; bThumbEE = isVFP3; bNEON = isVFP3; bVFPv3 = isVFP3; bTLS = true; bVFPv4 = isVFP4; bIDIVa = isVFP4; bIDIVt = isVFP4; bFP = false; bASIMD = false; #else strncpy(cpu_string, GetCPUString().c_str(), sizeof(cpu_string)); bSwp = CheckCPUFeature("swp"); bHalf = CheckCPUFeature("half"); bThumb = CheckCPUFeature("thumb"); bFastMult = CheckCPUFeature("fastmult"); bVFP = CheckCPUFeature("vfp"); bEDSP = CheckCPUFeature("edsp"); bThumbEE = CheckCPUFeature("thumbee"); bNEON = CheckCPUFeature("neon"); bVFPv3 = CheckCPUFeature("vfpv3"); bTLS = CheckCPUFeature("tls"); bVFPv4 = CheckCPUFeature("vfpv4"); bIDIVa = CheckCPUFeature("idiva"); bIDIVt = CheckCPUFeature("idivt"); // Qualcomm Krait supports IDIVA but it doesn't report it. Check for krait. if (GetCPUImplementer() == 0x51 && GetCPUPart() == 0x6F) // Krait(300) is 0x6F, Scorpion is 0x4D bIDIVa = bIDIVt = true; // These two require ARMv8 or higher bFP = CheckCPUFeature("fp"); bASIMD = CheckCPUFeature("asimd"); #endif // On android, we build a separate library for ARMv7 so this is fine. // TODO: Check for ARMv7 on other platforms. #if defined(__ARM_ARCH_7A__) bArmV7 = true; #else bArmV7 = false; #endif }
// Detects the various cpu features void CPUInfo::Detect() { // Set some defaults here HTT = false; #ifdef ARM64 OS64bit = true; CPU64bit = true; Mode64bit = true; #else OS64bit = false; CPU64bit = false; Mode64bit = false; #endif vendor = VENDOR_ARM; // Get the information about the CPU #if !defined(__linux__) bool isVFP3 = false; bool isVFP4 = false; #ifdef IOS isVFP3 = true; // Check for swift arch (VFP4) #ifdef __ARM_ARCH_7S__ isVFP4 = true; #endif strcpy(brand_string, "Apple A"); num_cores = 2; #elif defined(BLACKBERRY) isVFP3 = true; deviceinfo_details_t* details; deviceinfo_get_details(&details); num_cores = deviceinfo_details_get_processor_core_count(details); strcpy(brand_string, deviceinfo_details_get_processor_name(details)); if (!strncmp(brand_string, "MSM", 3)) isVFP4 = true; deviceinfo_free_details(&details); #else strcpy(brand_string, "Unknown"); num_cores = 1; #endif strncpy(cpu_string, brand_string, sizeof(cpu_string)); // Hardcode this for now bSwp = true; bHalf = true; bThumb = false; bFastMult = true; bVFP = true; bEDSP = true; bThumbEE = isVFP3; bNEON = isVFP3; bVFPv3 = isVFP3; bTLS = true; bVFPv4 = isVFP4; bIDIVa = isVFP4; bIDIVt = isVFP4; bFP = false; bASIMD = false; #else // __linux__ strncpy(cpu_string, GetCPUString().c_str(), sizeof(cpu_string)); strncpy(brand_string, GetCPUBrandString().c_str(), sizeof(brand_string)); bSwp = CheckCPUFeature("swp"); bHalf = CheckCPUFeature("half"); bThumb = CheckCPUFeature("thumb"); bFastMult = CheckCPUFeature("fastmult"); bVFP = CheckCPUFeature("vfp"); bEDSP = CheckCPUFeature("edsp"); bThumbEE = CheckCPUFeature("thumbee"); bNEON = CheckCPUFeature("neon"); bVFPv3 = CheckCPUFeature("vfpv3"); bTLS = CheckCPUFeature("tls"); bVFPv4 = CheckCPUFeature("vfpv4"); bIDIVa = CheckCPUFeature("idiva"); bIDIVt = CheckCPUFeature("idivt"); // Qualcomm Krait supports IDIVA but it doesn't report it. Check for krait (0x4D = Plus, 0x6F = Pro). unsigned short CPUPart = GetCPUPart(); if (GetCPUImplementer() == 0x51 && (CPUPart == 0x4D || CPUPart == 0x6F)) bIDIVa = bIDIVt = true; // These two require ARMv8 or higher bFP = CheckCPUFeature("fp"); bASIMD = CheckCPUFeature("asimd"); num_cores = GetCoreCount(); #endif #ifdef ARM64 // Whether the above detection failed or not, on ARM64 we do have ASIMD/NEON. bNEON = true; bASIMD = true; #endif }
// Detects the various cpu features void CPUInfo::Detect() { // Set some defaults here // When ARMv8 cpus come out, these need to be updated. HTT = false; OS64bit = false; CPU64bit = false; Mode64bit = false; vendor = VENDOR_ARM; // Get the information about the CPU num_cores = GetCoreCount(); #if defined(__SYMBIAN32__) || defined(BLACKBERRY) || defined(IOS) bool isVFP3 = false; bool isVFP4 = false; #ifdef IOS isVFP3 = true; // Check for swift arch (VFP4`) #ifdef __ARM_ARCH_7S__ isVFP4 = true; #endif // #ifdef __ARM_ARCH_7S__ #elif defined(BLACKBERRY) isVFP3 = true; const char cpuInfoPath[] = "/pps/services/hw_info/inventory"; const char marker[] = "Processor_Name::"; const char qcCPU[] = "MSM"; char buf[1024]; FILE* fp; if (fp = fopen(cpuInfoPath, "r")) { while (fgets(buf, sizeof(buf), fp)) { if (strncmp(buf, marker, sizeof(marker) - 1)) continue; if (strncmp(buf + sizeof(marker) - 1, qcCPU, sizeof(qcCPU) - 1) == 0) isVFP4 = true; break; } fclose(fp); } #endif // Hardcode this for now bSwp = true; bHalf = true; bThumb = false; bFastMult = true; bVFP = true; bEDSP = true; bThumbEE = isVFP3; bNEON = isVFP3; bVFPv3 = isVFP3; bTLS = true; bVFPv4 = isVFP4; bIDIVa = isVFP4; bIDIVt = isVFP4; bFP = false; bASIMD = false; #else strncpy(cpu_string, GetCPUString(), sizeof(cpu_string)); bSwp = CheckCPUFeature("swp"); bHalf = CheckCPUFeature("half"); bThumb = CheckCPUFeature("thumb"); bFastMult = CheckCPUFeature("fastmult"); bVFP = CheckCPUFeature("vfp"); bEDSP = CheckCPUFeature("edsp"); bThumbEE = CheckCPUFeature("thumbee"); bNEON = CheckCPUFeature("neon"); bVFPv3 = CheckCPUFeature("vfpv3"); bTLS = CheckCPUFeature("tls"); bVFPv4 = CheckCPUFeature("vfpv4"); bIDIVa = CheckCPUFeature("idiva"); bIDIVt = CheckCPUFeature("idivt"); // Qualcomm Krait supports IDIVA but it doesn't report it. Check for krait. if (GetCPUImplementer() == 0x51 && GetCPUPart() == 0x6F) // Krait(300) is 0x6F, Scorpion is 0x4D bIDIVa = bIDIVt = true; // These two require ARMv8 or higher bFP = CheckCPUFeature("fp"); bASIMD = CheckCPUFeature("asimd"); #endif // On android, we build a separate library for ARMv7 so this is fine. // TODO: Check for ARMv7 on other platforms. #if defined(__ARM_ARCH_7A__) bArmV7 = true; #else bArmV7 = false; #endif }
// Detects the various cpu features void CPUInfo::Detect() { // Set some defaults here // When ARMv8 cpus come out, these need to be updated. HTT = false; OS64bit = false; CPU64bit = false; Mode64bit = false; vendor = VENDOR_ARM; // Get the information about the CPU #if defined(__SYMBIAN32__) || defined(BLACKBERRY) || defined(IOS) bool isVFP3 = false; bool isVFP4 = false; #ifdef IOS isVFP3 = true; // Check for swift arch (VFP4) #ifdef __ARM_ARCH_7S__ isVFP4 = true; #endif strcpy(brand_string, "Apple"); num_cores = 2; #elif defined(BLACKBERRY) isVFP3 = true; deviceinfo_details_t* details; deviceinfo_get_details(&details); num_cores = deviceinfo_details_get_processor_core_count(details); strcpy(brand_string, deviceinfo_details_get_processor_name(details)); if (!strncmp(brand_string, "MSM", 3)) isVFP4 = true; deviceinfo_free_details(&details); #elif defined(SYMBIAN) strcpy(brand_string, "Samsung ARMv6"); num_cores = 1; #endif // Hardcode this for now bSwp = true; bHalf = true; bThumb = false; bFastMult = true; bVFP = true; bEDSP = true; bThumbEE = isVFP3; bNEON = isVFP3; bVFPv3 = isVFP3; bTLS = true; bVFPv4 = isVFP4; bIDIVa = isVFP4; bIDIVt = isVFP4; bFP = false; bASIMD = false; #else strncpy(cpu_string, GetCPUString(), sizeof(cpu_string)); bSwp = CheckCPUFeature("swp"); bHalf = CheckCPUFeature("half"); bThumb = CheckCPUFeature("thumb"); bFastMult = CheckCPUFeature("fastmult"); bVFP = CheckCPUFeature("vfp"); bEDSP = CheckCPUFeature("edsp"); bThumbEE = CheckCPUFeature("thumbee"); bNEON = CheckCPUFeature("neon"); bVFPv3 = CheckCPUFeature("vfpv3"); bTLS = CheckCPUFeature("tls"); bVFPv4 = CheckCPUFeature("vfpv4"); bIDIVa = CheckCPUFeature("idiva"); bIDIVt = CheckCPUFeature("idivt"); // Qualcomm Krait supports IDIVA but it doesn't report it. Check for krait. if (GetCPUImplementer() == 0x51 && GetCPUPart() == 0x6F) // Krait(300) is 0x6F, Scorpion is 0x4D bIDIVa = bIDIVt = true; // These two require ARMv8 or higher bFP = CheckCPUFeature("fp"); bASIMD = CheckCPUFeature("asimd"); num_cores = GetCoreCount(); #endif // On android, we build a separate library for ARMv7 so this is fine. // TODO: Check for ARMv7 on other platforms. #if defined(__ARM_ARCH_7A__) bArmV7 = true; #else bArmV7 = false; #endif }