Implement DetectNumberOfCores on Android and make it consistent on Linux and Android

TEST=Number of cpu cores on Linux and Android is right
R=fischman@webrtc.org, niklas.enbom@webrtc.org

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

Patch from Jeremy Mao <yujie.mao@intel.com>.

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4185 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
fischman@webrtc.org 2013-06-05 16:37:42 +00:00
parent db24995680
commit 2b3a29a1fa

View File

@ -15,11 +15,8 @@
#elif defined(WEBRTC_MAC)
#include <sys/sysctl.h>
#include <sys/types.h>
#elif defined(WEBRTC_ANDROID)
// Not implemented yet, might be possible to use Linux implementation
#else // defined(WEBRTC_LINUX)
#include <sys/sysinfo.h>
#include <unistd.h> // required for get_nprocs() with uClibc
#else // defined(WEBRTC_LINUX) or defined(WEBRTC_ANDROID)
#include <unistd.h>
#endif
#include "webrtc/system_wrappers/interface/trace.h"
@ -37,8 +34,8 @@ uint32_t CpuInfo::DetectNumberOfCores() {
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
"Available number of cores:%d", number_of_cores_);
#elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID)
number_of_cores_ = get_nprocs();
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
number_of_cores_ = static_cast<uint32_t>(sysconf(_SC_NPROCESSORS_ONLN));
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
"Available number of cores:%d", number_of_cores_);