FIO on Android
Hi,
Attached is a patch to support Android. It's implemented as a different OS, so most of the changes are in os/os-android.h
To build, do something like:
make UNAME=Android
CROSS_COMPILE=/path/to/android/toolchain/bin/arm-linux-androideabi-
Yes, it's pretty ugly all round, but fio isn't designed for cross compile and Android's libc is busted, so we have to make do.
Note that this is basically untested. Works for a few basic tests but YMMV. If someone wants to look at the splice build warning, that would be great.
Cheers,
-- Aaron
Makefile | 10 ++- backend.c | 2 + init.c | 2 + memory.c | 2 + os/os-android.h | 234 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ os/os.h | 16 ++++- 6 files changed, 263 insertions(+), 3 deletions(-)
Makefile +9 -1
@@ -1,5 +1,5 @@ ifneq ($(origin CC), environment) -CC = gcc +CC = $(CROSS_COMPILE)gcc endif DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
@@ -28,6 +28,14 @@ ifeq ($(UNAME), Linux) LIBS += -lpthread -ldl -lrt -laio LDFLAGS += -rdynamic endif +ifeq ($(UNAME), Android) + SOURCE += diskutil.c fifo.c blktrace.c helpers.c trim.c \ + engines/splice.c profiles/tiobench.c engines/falloc.c \ + engines/e4defrag.c + LIBS += -ldl + LDFLAGS += -rdynamic + CPPFLAGS += -DFIO_NO_HAVE_SHM_H +endif ifeq ($(UNAME), SunOS) SOURCE += fifo.c lib/strsep.c helpers.c engines/posixaio.c \ engines/solarisaio.c
backend.c +2 -0
@@ -34,7 +34,9 @@#include <sys/stat.h> #include <sys/wait.h> #include <sys/ipc.h> +#ifndef FIO_NO_HAVE_SHM_H #include <sys/shm.h> +#endif #include <sys/mman.h> #include "fio.h"
init.c +2 -0
@@ -9,7 +9,9 @@#include <string.h> #include <errno.h> #include <sys/ipc.h> +#ifndef FIO_NO_HAVE_SHM_H #include <sys/shm.h> +#endif #include <sys/types.h> #include <sys/stat.h>
memory.c +2 -0
@@ -5,7 +5,9 @@#include <sys/stat.h> #include <fcntl.h> #include <unistd.h> +#ifndef FIO_NO_HAVE_SHM_H #include <sys/shm.h> +#endif #include <sys/mman.h> #include "fio.h"
os/os-android.h new file +234 -0
234 lines not on this page · raw message
os/os.h +14 -2
@@ -17,11 +17,14 @@ enum { os_netbsd, os_solaris, os_windows, + os_android, os_nr, }; -#if defined(__linux__) +#if defined(__ANDROID__) +#include "os-android.h" +#elif defined(__linux__)#include "os-linux.h" #elif defined(__FreeBSD__)#include "os-freebsd.h"
@@ -66,7 +69,14 @@ typedef struct aiocb os_aiocb_t;#endif #ifndef FIO_HAVE_FADVISE -#define posix_fadvise (fd, off, len, advice) (0) +static inline int posix_fadvise (int fd,int off,int len,int advice) +{ + (void )fd; + (void )off; + (void )len; + (void )advice; +return 0 ; +}#ifndef POSIX_FADV_DONTNEED #define POSIX_FADV_DONTNEED (0)
@@ -171,6 +181,7 @@ static inline uint64_t fio_swap64(uint64_t val) }#endif +#ifndef FIO_HAVE_BYTEORDER_FUNCS #ifdef FIO_LITTLE_ENDIAN #define __le16_to_cpu (x) (x)#define __le32_to_cpu (x) (x)
@@ -186,6 +197,7 @@ static inline uint64_t fio_swap64(uint64_t val)#define __cpu_to_le32 (x) fio_swap32(x)#define __cpu_to_le64 (x) fio_swap64(x)#endif +#endif /* FIO_HAVE_BYTEORDER_FUNCS */ #define le16_to_cpu (val) ({ \ uint16_t *__val = &(val); \
Quoted 10 lines · Aaron Carroll
Hi,
Attached is a patch to support Android. It's implemented as a different OS, so most of the changes are in
os/os-android.hTo build, do something like:
make UNAME=Android CROSS_COMPILE=/path/to/android/toolchain/bin/arm-linux-androideabi-
Quoted 6 lines
Yes, it's pretty ugly all round, but fio isn't designed for cross compile and Android's libc is busted, so we have to make do.
Note that this is basically untested. Works for a few basic tests but YMMV. If someone wants to look at the splice build warning, that would be great.
Nifty! Applied, thanks.
Signature · 1 line
Jens Axboe