From 239b2882f467676b232e9e20b72c287b77bd3daa Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 4 Nov 2014 19:53:04 -0700 Subject: [PATCH] Add basic DragonFly support Saw the build failing in their logs, and it hurt my feelings. Signed-off-by: Jens Axboe --- Makefile | 4 ++++ libfio.c | 1 + os/os-dragonfly.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++ os/os.h | 3 +++ 4 files changed, 69 insertions(+) create mode 100644 os/os-dragonfly.h diff --git a/Makefile b/Makefile index 55a93fc2..8a28f62c 100644 --- 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__ diff --git a/libfio.c b/libfio.c index 1abf39a8..57ce725b 100644 --- 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 index 00000000..cc3de31e --- /dev/null +++ b/os/os-dragonfly.h @@ -0,0 +1,61 @@ +#ifndef FIO_OS_DRAGONFLY_H +#define FIO_OS_DRAGONFLY_H + +#define FIO_OS os_dragonfly + +#include +#include +/* XXX hack to avoid confilcts between rbtree.h and */ +#define rb_node _rb_node +#include +#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 df706ab7..7cb81211 100644 --- 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 -- 2.25.1