Add basic DragonFly support
authorJens Axboe <axboe@fb.com>
Wed, 5 Nov 2014 02:53:04 +0000 (19:53 -0700)
committerJens Axboe <axboe@fb.com>
Wed, 5 Nov 2014 02:53:04 +0000 (19:53 -0700)
Saw the build failing in their logs, and it hurt my feelings.

Signed-off-by: Jens Axboe <axboe@fb.com>
Makefile
libfio.c
os/os-dragonfly.h [new file with mode: 0644]
os/os.h

index 55a93fc247ff0908018963254bb9e3ad7ca32201..8a28f62c0fb850838aa638b0dd21bf2a588f03f9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -136,6 +136,10 @@ ifeq ($(CONFIG_TARGET_OS), NetBSD)
   LIBS  += -lpthread -lrt
   LDFLAGS += -rdynamic
 endif
+ifeq ($(CONFIG_TARGET_OS), DragonFly)
+  LIBS  += -lpthread -lrt
+  LDFLAGS += -rdynamic
+endif
 ifeq ($(CONFIG_TARGET_OS), AIX)
   LIBS  += -lpthread -ldl -lrt
   CPPFLAGS += -D_LARGE_FILES -D__ppc__
index 1abf39a84edff09b4cdf571361c6356d7706641f..57ce725be06757df2358e45bcabaaf4cff619573 100644 (file)
--- a/libfio.c
+++ b/libfio.c
@@ -58,6 +58,7 @@ static const char *fio_os_strings[os_nr] = {
        "Solaris",
        "Windows",
        "Android",
+       "DragonFly",
 };
 
 static const char *fio_arch_strings[arch_nr] = {
diff --git a/os/os-dragonfly.h b/os/os-dragonfly.h
new file mode 100644 (file)
index 0000000..cc3de31
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef FIO_OS_DRAGONFLY_H
+#define FIO_OS_DRAGONFLY_H
+
+#define        FIO_OS  os_dragonfly
+
+#include <errno.h>
+#include <sys/param.h>
+/* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */
+#define        rb_node _rb_node
+#include <sys/sysctl.h>
+#undef rb_node
+#undef rb_left
+#undef rb_right
+
+#include "../file.h"
+
+#define FIO_HAVE_ODIRECT
+#define FIO_USE_GENERIC_BDEV_SIZE
+#define FIO_USE_GENERIC_RAND
+#define FIO_USE_GENERIC_INIT_RANDOM_STATE
+#define FIO_HAVE_GETTID
+
+#undef FIO_HAVE_CPU_AFFINITY   /* XXX notyet */
+
+#define OS_MAP_ANON            MAP_ANON
+
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+
+#define fio_swap16(x)  bswap16(x)
+#define fio_swap32(x)  bswap32(x)
+#define fio_swap64(x)  bswap64(x)
+
+typedef off_t off64_t;
+
+static inline int blockdev_invalidate_cache(struct fio_file *f)
+{
+       return EINVAL;
+}
+
+static inline unsigned long long os_phys_mem(void)
+{
+       int mib[2] = { CTL_HW, HW_PHYSMEM };
+       uint64_t mem;
+       size_t len = sizeof(mem);
+
+       sysctl(mib, 2, &mem, &len, NULL, 0);
+       return mem;
+}
+
+static inline int gettid(void)
+{
+       return (int) lwp_gettid();
+}
+
+#ifdef MADV_FREE
+#define FIO_MADV_FREE  MADV_FREE
+#endif
+
+#endif
diff --git a/os/os.h b/os/os.h
index df706ab7be4150d8589b2130e96e5c4ef1b09bb6..7cb8121120ecd5c98c78d8d3e31b76997172c6da 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -21,6 +21,7 @@ enum {
        os_solaris,
        os_windows,
        os_android,
+       os_dragonfly,
 
        os_nr,
 };
@@ -45,6 +46,8 @@ enum {
 #include "os-hpux.h"
 #elif defined(WIN32)
 #include "os-windows.h"
+#elif defined (__DragonFly__)
+#include "os-dragonfly.h"
 #else
 #error "unsupported os"
 #endif