fio: Get it to build on Android.

-Add Android.mk.
-Fix byteswap instances in os/os-android.

Change-Id: Ifa136a0a4de7759b908215da0567919c4eb4cf74
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..69267b9
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,96 @@
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS_32 += -DBITS_PER_LONG=32 -DCONFIG_64BIT
+LOCAL_CFLAGS_64 += -DBITS_PER_LONG=64 -DCONFIG_32BIT
+
+main_src_files := gettime.c fio.c ioengines.c init.c stat.c log.c time.c \
+                  filesetup.c eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
+                  smalloc.c filehash.c helpers.c profile.c debug.c backend.c \
+                  cconv.c client.c filelock.c flow.c gettime-thread.c idletime.c io_u_queue.c \
+                  iolog.c json.c libfio.c memalign.c profiles/act.c profiles/tiobench.c server.c \
+                  td_error.c diskutil.c blktrace.c trim.c fifo.c cgroup.c \
+
+lib_src_files := lib/rbtree.c lib/flist_sort.c lib/getrusage.c lib/hweight.c lib/ieee754.c lib/lfsr.c \
+                 lib/num2str.c lib/prio_tree.c lib/rand.c lib/zipf.c lib/inet_aton.c lib/axmap.c \
+
+crc_src_files := crc/crc7.c crc/crc16.c crc/crc32.c crc/crc64.c crc/crc32c.c crc/crc32c-intel.c \
+                 crc/sha1.c crc/sha256.c crc/sha512.c crc/md5.c crc/test.c crc/xxhash.c \
+
+engines_src_files := engines/cpu.c engines/mmap.c engines/sync.c engines/null.c engines/net.c \
+                     engines/sg.c engines/binject.c
+
+LOCAL_SRC_FILES := $(main_src_files) \
+                   $(lib_src_files) \
+                   $(crc_src_files) \
+                   $(engines_src_files)
+
+LOCAL_MODULE := fio
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := debug
+
+LOCAL_SHARED_LIBRARIES := libdl
+LOCAL_STATIC_LIBRARIES := libcutils libz
+
+LOCAL_C_INCLUDES += external/zlib
+
+LOCAL_LDLIBS += -ldl
+LOCAL_CFLAGS += -DFIO_VERSION="\"fio-2.1.8-80-g890b\"" \
+                -DCONFIG_3ARG_AFFINITY \
+                -DCONFIG_CLOCK_GETTIME \
+                -DCONFIG_CLOCK_MONOTONIC \
+                -DCONFIG_FDATASYNC \
+                -DCONFIG_GETOPT_LONG_ONLY \
+                -DCONFIG_GETTIMEOFDAY \
+                -DCONFIG_IPV6 \
+                -DCONFIG_LINUX_FALLOCATE \
+                -DCONFIG_LITTLE_ENDIAN \
+                -DCONFIG_POSIX_FALLOCATE \
+                -DCONFIG_RLIMIT_MEMLOCK \
+                -DCONFIG_RUSAGE_THREAD \
+                -DCONFIG_SCHED_IDLE \
+                -DCONFIG_SETVBUF \
+                -DCONFIG_SFAA \
+                -DCONFIG_SOCKLEN_T \
+                -DCONFIG_STRCASESTR \
+                -DCONFIG_STRSEP \
+                -DCONFIG_TCP_NODELAY \
+                -DCONFIG_TLS_THREAD \
+                -DCONFIG_ZLIB \
+                -DFIO_HAVE_CGROUPS \
+                -DFIO_INC_DEBUG \
+                -DFIO_INTERNAL \
+                -DNO_GETMNTENT_R \
+                -DNO_INET_NETWORK \
+                -D_FILE_OFFSET_BITS=64 \
+                -D_FORTIFY_SOURCE=2 \
+                -D_GNU_SOURCE \
+                -D_LARGEFILE_SOURCE \
+                -D__ANDROID__ \
+                -O3 \
+                -Wall \
+                -Wdeclaration-after-statement \
+                -Wwrite-strings \
+                -ffast-math \
+                -fno-omit-frame-pointer \
+                -g \
+                -rdynamic \
+                -std=gnu99 \
+
+include $(BUILD_EXECUTABLE)
diff --git a/os/os-android.h b/os/os-android.h
index 954178d..c30f62e 100644
--- a/os/os-android.h
+++ b/os/os-android.h
@@ -11,9 +11,9 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <sched.h>
-#include <linux/unistd.h>
 #include <linux/major.h>
 #include <asm/byteorder.h>
+#include <byteswap.h>
 
 #include "binject.h"
 #include "../file.h"
@@ -208,9 +208,9 @@
 #define FIO_O_NOATIME	0
 #endif
 
-#define fio_swap16(x)	__bswap_16(x)
-#define fio_swap32(x)	__bswap_32(x)
-#define fio_swap64(x)	__bswap_64(x)
+#define fio_swap16(x)	bswap_16(x)
+#define fio_swap32(x)	bswap_32(x)
+#define fio_swap64(x)	bswap_64(x)
 
 #define CACHE_LINE_FILE	\
 	"/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size"