Landing for Rodolph Perfetta.
Improve V8 VFPv3 runtime detection, to address issue 914. This patch will check for the exact word vfpv3 as well as 0xc08 (CortexA8 part number) as some earlier kernel didn't report vfpv3 for A8. Codereview URL: http://codereview.chromium.org/4103013/show git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5751 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
42b6151247
commit
ef06d71229
@ -99,30 +99,12 @@ uint64_t OS::CpuFeaturesImpliedByPlatform() {
|
||||
|
||||
|
||||
#ifdef __arm__
|
||||
bool OS::ArmCpuHasFeature(CpuFeature feature) {
|
||||
const char* search_string = NULL;
|
||||
static bool CPUInfoContainsString(const char * search_string) {
|
||||
const char* file_name = "/proc/cpuinfo";
|
||||
// Simple detection of VFP at runtime for Linux.
|
||||
// It is based on /proc/cpuinfo, which reveals hardware configuration
|
||||
// to user-space applications. According to ARM (mid 2009), no similar
|
||||
// facility is universally available on the ARM architectures,
|
||||
// so it's up to individual OSes to provide such.
|
||||
//
|
||||
// This is written as a straight shot one pass parser
|
||||
// and not using STL string and ifstream because,
|
||||
// on Linux, it's reading from a (non-mmap-able)
|
||||
// character special device.
|
||||
switch (feature) {
|
||||
case VFP3:
|
||||
search_string = "vfp";
|
||||
break;
|
||||
case ARMv7:
|
||||
search_string = "ARMv7";
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
FILE* f = NULL;
|
||||
const char* what = search_string;
|
||||
|
||||
@ -149,6 +131,43 @@ bool OS::ArmCpuHasFeature(CpuFeature feature) {
|
||||
// Did not find string in the proc file.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OS::ArmCpuHasFeature(CpuFeature feature) {
|
||||
const int max_items = 2;
|
||||
const char* search_strings[max_items] = { NULL, NULL };
|
||||
int search_items = 0;
|
||||
// Simple detection of VFP at runtime for Linux.
|
||||
// It is based on /proc/cpuinfo, which reveals hardware configuration
|
||||
// to user-space applications. According to ARM (mid 2009), no similar
|
||||
// facility is universally available on the ARM architectures,
|
||||
// so it's up to individual OSes to provide such.
|
||||
switch (feature) {
|
||||
case VFP3:
|
||||
search_strings[0] = "vfpv3";
|
||||
// Some old kernels will report vfp for A8, not vfpv3, so we check for
|
||||
// A8 explicitely. The cpuinfo file report the CPU Part which for Cortex
|
||||
// A8 is 0xc08.
|
||||
search_strings[1] = "0xc08";
|
||||
search_items = 2;
|
||||
ASSERT(search_items <= max_items);
|
||||
break;
|
||||
case ARMv7:
|
||||
search_strings[0] = "ARMv7" ;
|
||||
search_items = 1;
|
||||
ASSERT(search_items <= max_items);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
for (int i = 0; i < search_items; ++i) {
|
||||
if (CPUInfoContainsString(search_strings[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif // def __arm__
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user