Merge branch 'doc-Clarify_Runtime_Param' of https://github.com/horshack-dpreview/fio
[fio.git] / os / os-dragonfly.h
index 423b2369a071bd2de9096178ee2d3c118decabb2..5b37a37e19fde5f1b328612968cee9975dd79065 100644 (file)
 #include <sys/sysctl.h>
 #include <sys/statvfs.h>
 #include <sys/diskslice.h>
-#include <sys/ioctl_compat.h>
 #include <sys/usched.h>
 #include <sys/resource.h>
 
+/* API changed during "5.3 development" */
+#if __DragonFly_version < 500302
+#include <sys/ioctl_compat.h>
+#define DAIOCTRIM      IOCTLTRIM
+#else
+#include <bus/cam/scsi/scsi_daio.h>
+#endif
+
 #include "../file.h"
+#include "../lib/types.h"
 
 #define FIO_HAVE_ODIRECT
-#define FIO_USE_GENERIC_RAND
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
 #define FIO_HAVE_FS_STAT
 #define FIO_HAVE_TRIM
@@ -40,7 +47,6 @@
 /* This is supposed to equal (sizeof(cpumask_t)*8) */
 #define FIO_MAX_CPUS   SMP_MAXCPU
 
-typedef off_t off64_t;
 typedef cpumask_t os_cpu_mask_t;
 
 /*
@@ -86,6 +92,12 @@ typedef cpumask_t os_cpu_mask_t;
 /* No CPU_COUNT(), but use the default function defined in os/os.h */
 #define fio_cpu_count(mask)             CPU_COUNT((mask))
 
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask)  \
+       pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
 {
        CPUMASK_ASSZERO(*mask);
@@ -107,12 +119,9 @@ static inline void fio_cpu_set(os_cpu_mask_t *mask, int cpu)
        CPUMASK_ORBIT(*mask, cpu);
 }
 
-static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
+static inline bool fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
 {
-       if (CPUMASK_TESTBIT(*mask, cpu))
-               return 1;
-
-       return 0;
+       return CPUMASK_TESTBIT(*mask, cpu) != 0;
 }
 
 static inline int fio_setaffinity(int pid, os_cpu_mask_t mask)
@@ -162,6 +171,7 @@ static inline int fio_getaffinity(int pid, os_cpu_mask_t *mask)
  * ioprio_set() with 4 arguments, so define fio's ioprio_set() as a macro.
  * Note that there is no idea of class within ioprio_set(2) unlike Linux.
  */
+#define ioprio_value(ioprio_class, ioprio)     (ioprio)
 #define ioprio_set(which, who, ioprio_class, ioprio)   \
        ioprio_set(which, who, ioprio)
 
@@ -198,10 +208,12 @@ static inline unsigned long long os_phys_mem(void)
        return mem;
 }
 
+#ifndef CONFIG_HAVE_GETTID
 static inline int gettid(void)
 {
        return (int) lwp_gettid();
 }
+#endif
 
 static inline unsigned long long get_fs_free_size(const char *path)
 {
@@ -224,7 +236,7 @@ static inline int os_trim(struct fio_file *f, unsigned long long start,
        range[0] = start;
        range[1] = len;
 
-       if (!ioctl(f->fd, IOCTLTRIM, range))
+       if (!ioctl(f->fd, DAIOCTRIM, range))
                return 0;
 
        return errno;