需求如题,从网上下载了memtest源码压缩包,准备放到系统源码编译,然后push到板子上执行,结果,编译出来一堆问题,报build err。
做如下代码改动:
external/memtester-4.5.1/Android.mk | 16 ++++++++++++++++
external/memtester-4.5.1/memtester.c | 8 ++++----
2 files changed, 20 insertions(+), 4 deletions(-)
create mode 100644 external/memtester-4.5.1/Android.mk
diff --git a/external/memtester-4.5.1/Android.mk b/external/memtester-4.5.1/Android.mk
new file mode 100644
index 0000000000..86cf6d8935
--- /dev/null
+++ b/external/memtester-4.5.1/Android.mk
@@ -0,0 +1,16 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := memtester.c tests.c
+
+LOCAL_MODULE := memtester
+
+LOCAL_CFLAGS += -Wall -Wno-unused-parameter
+
+LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
+
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)
+
+include $(BUILD_EXECUTABLE)
diff --git a/external/memtester-4.5.1/memtester.c b/external/memtester-4.5.1/memtester.c
index 44d331e2cf..e6d86635e2 100755
--- a/external/memtester-4.5.1/memtester.c
+++ b/external/memtester-4.5.1/memtester.c
@@ -117,7 +117,7 @@ int main(int argc, char **argv) {
ulv *bufa, *bufb;
int do_mlock = 1, done_mem = 0;
int exit_code = 0;
- int memfd, opt, memshift;
+ int memfd, opt, memshift = 0;
size_t maxbytes = -1; /* addressable memory, in bytes */
size_t maxmb = (maxbytes >> 20) + 1; /* addressable memory, in MB */
/* Device to mmap memory from with -p, default is normal core */
@@ -139,7 +139,7 @@ int main(int argc, char **argv) {
/* If MEMTESTER_TEST_MASK is set, we use its value as a mask of which
tests we run.
*/
- if (env_testmask = getenv("MEMTESTER_TEST_MASK")) {
+ if (env_testmask == getenv("MEMTESTER_TEST_MASK")) {
errno = 0;
testmask = strtoul(env_testmask, 0, 0);
if (errno) {
@@ -310,7 +310,7 @@ int main(int argc, char **argv) {
fflush(stdout);
if ((size_t) buf % pagesize) {
/* printf("aligning to page -- was 0x%tx\n", buf); */
- aligned = (void volatile *) ((size_t) buf & pagesizemask) + pagesize;
+ aligned = (void volatile *) (((size_t) buf & pagesizemask) + pagesize);
/* printf(" now 0x%tx -- lost %d bytes\n", aligned,
* (size_t) aligned - (size_t) buf);
*/
@@ -363,7 +363,7 @@ int main(int argc, char **argv) {
define out the use of mlock() (cough HP/UX 10 cough). */
if ((size_t) buf % pagesize) {
/* printf("aligning to page -- was 0x%tx\n", buf); */
- aligned = (void volatile *) ((size_t) buf & pagesizemask) + pagesize;
+ aligned = (void volatile *) (((size_t) buf & pagesizemask) + pagesize);
/* printf(" now 0x%tx -- lost %d bytes\n", aligned,
* (size_t) aligned - (size_t) buf);
*/
--
编译好后push到android设备里面,测试前需先在android看里面设置环境变量
export MEMTESTER_TEST_MASK=0
执行memtester输出结果如下:
Mark。