summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2005-12-05 15:13:48 +0100
committerJens Axboe <axboe@suse.de>2005-12-05 15:13:48 +0100
commitfa78facdda07e37a77741ff148ef2abd34cf1bb9 (patch)
tree6303827809829dc5140f665fda0aad4ea8159252
parent3f91ddf9de26dd27018c36b350ffc1674443b2fa (diff)
[PATCH] fio: prepare to make it more cross platform
-rw-r--r--arch.h12
-rw-r--r--fio.c1
-rw-r--r--os-linux.h20
-rw-r--r--os.h21
4 files changed, 42 insertions, 12 deletions
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 <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
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