support to build in Android

Change-Id: I17a0a37bb8f5824732aa01868df3008fbed7c98d
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..8e2b7c3
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,52 @@
+LOCAL_PATH := $(call my-dir)
+
+######################################################
+###                     iozone                     ###
+######################################################
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := \
+                   src/current/libbif.c \
+                   src/current/iozone.c \
+
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := iozone
+
+LOCAL_CFLAGS += -Wall \
+                -O3 \
+                -Dunix \
+                -Dlinux \
+                -DHAVE_ANSIC_C \
+                -DHAVE_PREAD \
+                -DNAME='"Android"' \
+                -DLINUX_ARM \
+
+#                -DNO_THREADS \
+#LOCAL_MULTILIB := both
+#LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+#LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+
+include $(BUILD_EXECUTABLE)
+
+######################################################
+###                     fileop                     ###
+######################################################
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := \
+                   src/current/fileop.c \
+
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := fileop
+LOCAL_CFLAGS += -Wall -O3 -Dunix -Dlinux
+include $(BUILD_EXECUTABLE)
+
+######################################################
+###                     pit_server                 ###
+######################################################
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := \
+                   src/current/pit_server.c \
+
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := pit_server
+LOCAL_CFLAGS += -Wall -O3 -Dunix -Dlinux
+include $(BUILD_EXECUTABLE)
diff --git a/src/current/iozone.c b/src/current/iozone.c
index 65c51a3..ea45a6b 100644
--- a/src/current/iozone.c
+++ b/src/current/iozone.c
@@ -92,6 +92,10 @@
 #include <pthread.h>
 #endif
 
+#if defined(ANDROID)
+#include <time.h>
+#endif
+
 #if defined(HAVE_ANSIC_C) && defined(linux)
 #include <stdlib.h>
 #include <sys/wait.h>
@@ -360,6 +364,7 @@
 #ifndef SCO_Unixware_gcc
 #ifndef UWIN
 #ifndef __DragonFly__
+#ifndef ANDROID
 typedef long long off64_t;
 #endif
 #endif
@@ -369,6 +374,7 @@
 #endif
 #endif
 #endif
+#endif
 
 #ifdef __AIX__
 #include <fcntl.h>
@@ -980,8 +986,10 @@
 #endif
 static void update_burst_sleep(int, long long, double *);
 #ifndef NO_THREADS
+#ifndef ANDROID
 static void count_burst(double* burst_acc_time_sec, long long stream_id);
 #endif
+#endif
 static double time_so_far1();	/* time since start of program    */
 void get_resolution();
 void get_rusage_resolution();
@@ -1043,6 +1051,8 @@
 void end_async();
 void async_init();
 #else
+int async_read();
+int async_read_no_copy();
 size_t async_write();
 size_t async_write_no_copy();
 void async_release();
@@ -1378,11 +1388,13 @@
 long long burst_sleep_duration_msec = -1;  /* the sleep duration between burst */
 long long written_this_burst = 0;          /* How much data was writen so far in this burst*/
 #ifndef NO_THREADS
+#ifndef ANDROID
 pthread_barrierattr_t barrier_attr;
 pthread_barrier_t *barrier;
 off64_t burst_size_per_child = 0;
 long long burst_written_so_far[MAXSTREAMS] = {0};  /* How much data was written so far in this burst per stream (thread/process)*/
 #endif
+#endif
 
 char bif_filename [MAXNAMESIZE];           /* name of biff file      */
 char filename [MAXNAMESIZE];               /* name of temporary file */
@@ -3187,6 +3199,7 @@
 	}
 
 #ifndef NO_THREADS
+#ifndef ANDROID
 #if defined( _HPUX_SOURCE ) || defined ( linux )
 	if(ioz_processor_bind)
 	{
@@ -3205,6 +3218,7 @@
 	}
 #endif
 #endif
+#endif
 	orig_size=kilobytes64;
 	if(trflag){
 	    (void)multi_throughput_test(mint,maxt);
@@ -3669,6 +3683,7 @@
 		unit="kB";
 
 #ifndef NO_THREADS
+#ifndef ANDROID
 	/*Init barriers*/
 	if(use_thread)
 	{
@@ -3686,6 +3701,7 @@
 	if (burst_size_kb_64 != -1)
 		burst_size_per_child = burst_size_kb_64 * 1024 / num_child;
 #endif
+#endif
 
 	if(!haveshm)
 	{
@@ -6952,9 +6968,11 @@
 	}
 
 #ifndef NO_THREADS
+#ifndef ANDROID
 	/* Destroy the barrier */
 	pthread_barrier_destroy(barrier);
 #endif
+#endif
 
 	/********************************************************/
 	/* End of cleanup					*/
@@ -8076,7 +8094,7 @@
 			exit(48);
 		}
 #else
-		if((stream=(FILE *)I_FOPEN(filename,how)) == 0)
+		if((stream=I_FOPEN(filename,how)) == 0)
 		{
 #ifdef NO_PRINT_LLD
 			printf("\nCan not fdopen temp file: %s %d\n", 
@@ -8294,7 +8312,7 @@
 			exit(51);
 		}
 #else
-		if((stream=(FILE *)I_FOPEN(filename,"r")) == 0)
+		if((stream=I_FOPEN(filename,"r")) == 0)
 		{
 			printf("\nCan not fdopen temp file: %s\n", 
 				filename);
@@ -12597,6 +12615,7 @@
 	}
 #endif
 #ifndef NO_THREADS
+#ifndef ANDROID
 #if defined(_HPUX_SOURCE) || defined(linux)
 	if(ioz_processor_bind)
 	{
@@ -12616,6 +12635,7 @@
 	}
 #endif
 #endif
+#endif
 	if(use_thread)
 		nbuff=barray[xx];
 	else
@@ -12971,8 +12991,10 @@
 		      wval=write(fd, nbuff, (size_t) reclen);
 
 #ifndef NO_THREADS
+#ifndef ANDROID
 		      count_burst(&burst_acc_time_sec, xx);
 #endif
+#endif
 
 #if defined(Windows)
 		      }
@@ -13311,6 +13333,7 @@
 	}
 #endif
 #ifndef NO_THREADS
+#ifndef ANDROID
 #if defined( _HPUX_SOURCE ) || defined ( linux )
 	if(ioz_processor_bind)
 	{
@@ -13329,6 +13352,7 @@
 	}
 #endif
 #endif
+#endif
 	if(use_thread)
 		nbuff=barray[xx];
 	else
@@ -13949,6 +13973,7 @@
 	}
 #endif
 #ifndef NO_THREADS
+#ifndef ANDROID
 #if defined( _HPUX_SOURCE ) || defined ( linux )
 	if(ioz_processor_bind)
 	{
@@ -13967,6 +13992,7 @@
 	}
 #endif
 #endif
+#endif
 	if(use_thread)
 		nbuff=barray[xx];
 	else
@@ -14263,8 +14289,10 @@
 			   wval=write(fd, nbuff, (size_t) reclen);
 
 #ifndef NO_THREADS
+#ifndef ANDROID
 			   count_burst(&burst_acc_time_sec, xx);
 #endif
+#endif
 			   if(wval != reclen)
 			   {
 				if(*stop_flag)
@@ -14547,6 +14575,7 @@
 	}
 #endif
 #ifndef NO_THREADS
+#ifndef ANDROID
 #if defined( _HPUX_SOURCE ) || defined ( linux )
 	if(ioz_processor_bind)
 	{
@@ -14566,6 +14595,7 @@
 	}
 #endif
 #endif
+#endif
 	if(use_thread)
 		nbuff=barray[xx];
 	else
@@ -15663,6 +15693,7 @@
 	}
 #endif
 #ifndef NO_THREADS
+#ifndef ANDROID
 #if defined( _HPUX_SOURCE ) || defined ( linux )
 	if(ioz_processor_bind)
 	{
@@ -15682,6 +15713,7 @@
 	}
 #endif
 #endif
+#endif
 	if(use_thread)
 		nbuff=barray[xx];
 	else
@@ -16231,6 +16263,7 @@
 	}
 #endif
 #ifndef NO_THREADS
+#ifndef ANDROID
 #if defined( _HPUX_SOURCE ) || defined ( linux )
 	if(ioz_processor_bind)
 	{
@@ -16250,6 +16283,7 @@
 	}
 #endif
 #endif
+#endif
 	if(use_thread)
 		nbuff=barray[xx];
 	else
@@ -16767,6 +16801,7 @@
 	}
 #endif
 #ifndef NO_THREADS
+#ifndef ANDROID
 #if defined( _HPUX_SOURCE ) || defined ( linux )
 	if(ioz_processor_bind)
 	{
@@ -16786,6 +16821,7 @@
 	}
 #endif
 #endif
+#endif
 	if(use_thread)
 		nbuff=barray[xx];
 	else
@@ -17438,6 +17474,7 @@
 	}
 #endif
 #ifndef NO_THREADS
+#ifndef ANDROID
 #if defined( _HPUX_SOURCE ) || defined ( linux )
 	if(ioz_processor_bind)
 	{
@@ -17457,6 +17494,7 @@
 	}
 #endif
 #endif
+#endif
 	if(use_thread)
 		nbuff=barray[xx];
 	else
@@ -18072,6 +18110,7 @@
 	}
 #endif
 #ifndef NO_THREADS
+#ifndef ANDROID
 #if defined( _HPUX_SOURCE ) || defined ( linux )
 	if(ioz_processor_bind)
 	{
@@ -18091,6 +18130,7 @@
 	}
 #endif
 #endif
+#endif
 	if(use_thread)
 		nbuff=barray[xx];
 	else
@@ -18400,8 +18440,10 @@
 		      wval = write(fd, nbuff, (size_t) reclen);
 
 #ifndef NO_THREADS
+#ifndef ANDROID
 		      count_burst(&burst_acc_time_sec, xx);
 #endif
+#endif
 
 		      if(wval != reclen)
 		      {
@@ -23852,7 +23894,7 @@
 	time_t t;
 	char *value;
 	t=time(0);
-	value=(char *)ctime(&t);
+	value=ctime(&t);
 	strcpy(where,value);
 }
 
@@ -24873,7 +24915,7 @@
                 exit(48);
         }
 #else
-       if((stream=(FILE *)I_FOPEN(filename,how)) == 0)
+       if((stream=I_FOPEN(filename,how)) == 0)
         {
 #ifdef NO_PRINT_LLD
                 printf("\nCan not fdopen temp file: %s %d\n",
@@ -25007,8 +25049,10 @@
                 }
 
 #ifndef NO_THREADS
+#ifndef ANDROID
 		      count_burst(&burst_acc_time_sec, xx);
 #endif
+#endif
 
 		if(hist_summary)
 		{
@@ -25326,7 +25370,7 @@
 		exit(51);
 	}
 #else
-	if((stream=(FILE *)I_FOPEN(filename,"r")) == 0)
+	if((stream=I_FOPEN(filename,"r")) == 0)
 	{
 		printf("\nCan not fdopen temp file: %s\n",
 			filename);
@@ -25644,6 +25688,7 @@
 }
 
 #ifndef NO_THREADS
+#ifndef ANDROID
 static void count_burst(double* burst_acc_time_sec, long long stream_id)
 {
 	double burst_start_time_sec;
@@ -25680,4 +25725,5 @@
 	}
 }
 #endif
+#endif
 
diff --git a/src/current/libasync.c b/src/current/libasync.c
index 663b9d0..81961c6 100644
--- a/src/current/libasync.c
+++ b/src/current/libasync.c
@@ -95,7 +95,7 @@
  */
 
 #include <sys/types.h>
-#include <aio.h>
+//#include <aio.h>
 #if defined(solaris) || defined(linux) || defined(SCO_Unixware_gcc) || defined(__NetBSD__)
 #else
 #include <sys/timers.h>
diff --git a/src/current/libbif.c b/src/current/libbif.c
index 0f40a36..3bfe134 100644
--- a/src/current/libbif.c
+++ b/src/current/libbif.c
@@ -17,7 +17,7 @@
 #include <sys/types.h>
 #include <stdio.h>
 #include <sys/file.h>
-#if defined(__AIX__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#if defined(__AIX__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(ANDROID)
 #include <fcntl.h>
 #else
 #include <sys/fcntl.h>