提交 49661746 编写于 作者: H hedaoyuan

Fix android-16 compile.

上级 47eb8691
...@@ -65,8 +65,8 @@ if(NOT CMAKE_BUILD_TYPE) ...@@ -65,8 +65,8 @@ if(NOT CMAKE_BUILD_TYPE)
endif() endif()
if(ANDROID) if(ANDROID)
if(${CMAKE_SYSTEM_VERSION} VERSION_LESS "21") if(${CMAKE_SYSTEM_VERSION} VERSION_LESS "16")
message(FATAL_ERROR "Unsupport standalone toolchains with Android API level lower than 21") message(FATAL_ERROR "Unsupport standalone toolchains with Android API level lower than 16")
endif() endif()
set(WITH_GPU OFF CACHE STRING set(WITH_GPU OFF CACHE STRING
......
...@@ -320,6 +320,9 @@ void loadFileList(const std::string& fileListFileName, ...@@ -320,6 +320,9 @@ void loadFileList(const std::string& fileListFileName,
} }
double getMemoryUsage() { double getMemoryUsage() {
#if defined(__ANDROID__)
return 0.0;
#else
FILE* fp = fopen("/proc/meminfo", "r"); FILE* fp = fopen("/proc/meminfo", "r");
CHECK(fp) << "failed to fopen /proc/meminfo"; CHECK(fp) << "failed to fopen /proc/meminfo";
size_t bufsize = 256 * sizeof(char); size_t bufsize = 256 * sizeof(char);
...@@ -357,6 +360,7 @@ double getMemoryUsage() { ...@@ -357,6 +360,7 @@ double getMemoryUsage() {
delete[] buf; delete[] buf;
double usedMem = 1.0 - 1.0 * (freeMem + bufMem + cacheMem) / totalMem; double usedMem = 1.0 - 1.0 * (freeMem + bufMem + cacheMem) / totalMem;
return usedMem; return usedMem;
#endif
} }
SyncThreadPool* getGlobalSyncThreadPool() { SyncThreadPool* getGlobalSyncThreadPool() {
......
...@@ -33,6 +33,13 @@ limitations under the License. */ ...@@ -33,6 +33,13 @@ limitations under the License. */
#include "Flags.h" #include "Flags.h"
#include "hl_gpu.h" #include "hl_gpu.h"
#if defined(__ANDROID__) && (__ANDROID_API__ < 21)
inline int rand_r(unsigned int* seedp) {
(void)seedp;
return rand();
}
#endif
/** /**
* Loop over the elements in a container * Loop over the elements in a container
* TODO(yuyang18): It's this foreach useful? Why not use C++ 11 foreach, * TODO(yuyang18): It's this foreach useful? Why not use C++ 11 foreach,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册