Index: src/platform-linux.cc |
=================================================================== |
--- src/platform-linux.cc (revision 3292) |
+++ src/platform-linux.cc (working copy) |
@@ -89,7 +89,9 @@ |
} |
-bool OS::fgrep_vfp(const char* file_name, const char* string) { |
+bool OS::ArmCpuHasFeature(OS::CpuFeature feature) { |
+ const char* search_string = NULL; |
+ 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 |
@@ -100,13 +102,20 @@ |
// and not using STL string and ifstream because, |
// on Linux, it's reading from a (non-mmap-able) |
// character special device. |
+ switch (feature) { |
+ case VFP: |
+ search_string = "vfp"; |
+ break; |
+ default: |
+ UNREACHABLE(); |
+ } |
FILE* f = NULL; |
+ const char* what = search_string; |
if (NULL == (f = fopen(file_name, "r"))) |
return false; |
- const char* what = string; |
int k; |
while (EOF != (k = fgetc(f))) { |
if (k == *what) { |
@@ -118,13 +127,13 @@ |
fclose(f); |
return true; |
} else { |
- what = string; |
+ what = search_string; |
} |
} |
} |
fclose(f); |
- // Did not find string in the file file_name. |
+ // Did not find string in the proc file. |
return false; |
} |