Merge branch 'minor_fixes' of https://github.com/sitsofe/fio
[fio.git] / os / os-dragonfly.h
index d4a9579958ffcd16856b495e9fc79766f2feef69..8d15833562785ba4db31f1d31bd0e45c30587550 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <errno.h>
 #include <unistd.h>
+#include <sys/endian.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <sys/statvfs.h>
@@ -24,6 +25,7 @@
 #define FIO_HAVE_GETTID
 #define FIO_HAVE_CPU_AFFINITY
 #define FIO_HAVE_IOPRIO
+#define FIO_HAVE_SHM_ATTACH_REMOVED
 
 #define OS_MAP_ANON            MAP_ANON
 
@@ -81,6 +83,9 @@ typedef cpumask_t os_cpu_mask_t;
 #define USCHED_GET_CPUMASK     5
 #endif
 
+/* No CPU_COUNT(), but use the default function defined in os/os.h */
+#define fio_cpu_count(mask)             CPU_COUNT((mask))
+
 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
 {
        CPUMASK_ASSZERO(*mask);
@@ -110,17 +115,6 @@ static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
        return 0;
 }
 
-static inline int fio_cpu_count(os_cpu_mask_t *mask)
-{
-       int i, n = 0;
-
-       for (i = 0; i < FIO_MAX_CPUS; i++)
-               if (CPUMASK_TESTBIT(*mask, i))
-                       n++;
-
-       return n;
-}
-
 static inline int fio_setaffinity(int pid, os_cpu_mask_t mask)
 {
        int i, firstcall = 1;
@@ -191,7 +185,7 @@ static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
 
 static inline int blockdev_invalidate_cache(struct fio_file *f)
 {
-       return EINVAL;
+       return ENOTSUP;
 }
 
 static inline unsigned long long os_phys_mem(void)
@@ -240,4 +234,15 @@ static inline int os_trim(int fd, unsigned long long start,
 #define FIO_MADV_FREE  MADV_FREE
 #endif
 
+static inline int shm_attach_to_open_removed(void)
+{
+       int x;
+       size_t len = sizeof(x);
+
+       if (sysctlbyname("kern.ipc.shm_allow_removed", &x, &len, NULL, 0) < 0)
+               return 0;
+
+       return x > 0 ? 1 : 0;
+}
+
 #endif