[PATCH] fio: prepare to make it more cross platform
authorJens Axboe <axboe@suse.de>
Mon, 5 Dec 2005 14:13:48 +0000 (15:13 +0100)
committerJens Axboe <axboe@suse.de>
Mon, 5 Dec 2005 14:13:48 +0000 (15:13 +0100)
arch.h
fio.c
os-linux.h [new file with mode: 0644]
os.h [new file with mode: 0644]

diff --git a/arch.h b/arch.h
index 3138a8e937381fe922978ca2cf4ff4033bd8c4d1..c503e51bdcb306d8185dabdbbde384a24496c4d9 100644 (file)
--- 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 33f1b07f73e382ae114fd614eb9fd8fa3dd1e33e..1d124584f11383fe069ff814baee0389af5228a6 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -41,6 +41,7 @@
 #include <asm/unistd.h>
 
 #include "fio.h"
+#include "os.h"
 
 #define MASK   (4095)
 
diff --git a/os-linux.h b/os-linux.h
new file mode 100644 (file)
index 0000000..1a0b08e
--- /dev/null
@@ -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 (file)
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