Commit 91dc3edd authored by fbarchard@google.com's avatar fbarchard@google.com

Fix C89 compile error for cpu detect. Make mips detection assume DSP if cpuinfo…

Fix C89 compile error for cpu detect.  Make mips detection assume DSP if cpuinfo file can not be opened, so that if run in a sandbox, DSP is assumed true, like the arm version.
BUG=303
TESTED=cl /c /TC /Iinclude source/cpu_id.cc
R=tpsiaki@google.com

Review URL: https://webrtc-codereview.appspot.com/10549004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@986 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent efc5d9b9
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 985
Version: 986
License: BSD
License File: LICENSE
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 985
#define LIBYUV_VERSION 986
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
......@@ -120,13 +120,13 @@ void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info) {
// For Arm, but public to allow testing on any CPU
LIBYUV_API SAFEBUFFERS
int ArmCpuCaps(const char* cpuinfo_name) {
char cpuinfo_line[512];
FILE* f = fopen(cpuinfo_name, "r");
if (!f) {
// Assume Neon if /proc/cpuinfo is unavailable.
// This will occur for Chrome sandbox for Pepper or Render process.
return kCpuHasNEON;
}
char cpuinfo_line[512];
while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) {
if (memcmp(cpuinfo_line, "Features", 8) == 0) {
char* p = strstr(cpuinfo_line, " neon");
......@@ -142,10 +142,14 @@ int ArmCpuCaps(const char* cpuinfo_name) {
#if defined(__mips__) && defined(__linux__)
static int MipsCpuCaps(const char* search_string) {
char cpuinfo_line[512];
const char* file_name = "/proc/cpuinfo";
char cpuinfo_line[256];
FILE* f = NULL;
if ((f = fopen(file_name, "r")) != NULL) {
FILE* f = fopen(file_name, "r");
if (!f) {
// Assume DSP if /proc/cpuinfo is unavailable.
// This will occur for Chrome sandbox for Pepper or Render process.
return kCpuHasMIPS_DSP;
}
while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f) != NULL) {
if (strstr(cpuinfo_line, search_string) != NULL) {
fclose(f);
......@@ -153,8 +157,6 @@ static int MipsCpuCaps(const char* search_string) {
}
}
fclose(f);
}
/* Did not find string in the proc file, or not Linux ELF. */
return 0;
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment