From: Jens Axboe Date: Mon, 5 Dec 2005 14:13:48 +0000 (+0100) Subject: [PATCH] fio: prepare to make it more cross platform X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=fa78facdda07e37a77741ff148ef2abd34cf1bb9;p=disktools.git [PATCH] fio: prepare to make it more cross platform --- diff --git a/arch.h b/arch.h index 3138a8e..c503e51 100644 --- a/arch.h +++ b/arch.h @@ -48,18 +48,6 @@ static inline int ioprio_set(int which, int who, int ioprio) return syscall(__NR_ioprio_set, which, who, ioprio); } -/* - * we want fadvise64 really, but it's so tangled... later - */ -static inline int fadvise(int fd, loff_t offset, size_t len, int advice) -{ -#if 0 - return syscall(__NR_fadvise64, fd, offset, offset >> 32, len, advice); -#else - return posix_fadvise(fd, (off_t) offset, len, advice); -#endif -} - enum { IOPRIO_WHO_PROCESS = 1, IOPRIO_WHO_PGRP, diff --git a/fio.c b/fio.c index 33f1b07..1d12458 100644 --- a/fio.c +++ b/fio.c @@ -41,6 +41,7 @@ #include #include "fio.h" +#include "os.h" #define MASK (4095) diff --git a/os-linux.h b/os-linux.h new file mode 100644 index 0000000..1a0b08e --- /dev/null +++ b/os-linux.h @@ -0,0 +1,20 @@ +#ifndef FIO_OS_LINUX_H +#define FIO_OS_LINUX_H + +#define FIO_HAVE_LIBAIO (1) +#define FIO_HAVE_POSIXAIO (1) +#define FIO_HAVE_FADVISE (1) + +/* + * we want fadvise64 really, but it's so tangled... later + */ +static int fadvise(int fd, loff_t offset, size_t len, int advice) +{ +#if 0 + return syscall(__NR_fadvise64, fd, offset, offset >> 32, len, advice); +#else + return posix_fadvise(fd, (off_t) offset, len, advice); +#endif +} + +#endif diff --git a/os.h b/os.h new file mode 100644 index 0000000..e7cb53d --- /dev/null +++ b/os.h @@ -0,0 +1,21 @@ +#ifndef FIO_OS_H +#define FIO_OS_H + +#if defined(__linux__) +#include "os-linux.h" +#else +#error "unsupported os" +#endif + +#ifndef FIO_HAVE_FADVISE +static int fadvise(int fd, loff_t offset, size_t len, int advice) +{ + return 0; +} + +#define POSIX_FADV_DONTNEED (0) +#define POSIX_FADV_SEQUENTIAL (0) +#define POSIX_FADV_RANDOM (0) +#endif /* FIO_HAVE_FADVISE */ + +#endif