X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=os%2Fos-dragonfly.h;h=713046f53543442a89d21c55ace2cbcd05839d4b;hb=f23ff35ed3db83db98ac2909eeec5144a181811e;hp=5e94855cac5faef440a72492093944c0ffc0c3fa;hpb=f0ac17190989b4ada1d4d74be8d7a4ef3a76dfbb;p=fio.git diff --git a/os/os-dragonfly.h b/os/os-dragonfly.h index 5e94855c..713046f5 100644 --- a/os/os-dragonfly.h +++ b/os/os-dragonfly.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -14,6 +15,7 @@ #include #include "../file.h" +#include "../lib/types.h" #define FIO_HAVE_ODIRECT #define FIO_USE_GENERIC_RAND @@ -24,8 +26,7 @@ #define FIO_HAVE_GETTID #define FIO_HAVE_CPU_AFFINITY #define FIO_HAVE_IOPRIO -/* Only have attach-to-open-removed when kern.ipc.shm_allow_removed is 1 */ -#undef FIO_HAVE_SHM_ATTACH_REMOVED +#define FIO_HAVE_SHM_ATTACH_REMOVED #define OS_MAP_ANON MAP_ANON @@ -107,12 +108,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) @@ -185,7 +183,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) @@ -216,7 +214,7 @@ static inline unsigned long long get_fs_free_size(const char *path) return ret; } -static inline int os_trim(int fd, unsigned long long start, +static inline int os_trim(struct fio_file *f, unsigned long long start, unsigned long long len) { off_t range[2]; @@ -224,7 +222,7 @@ static inline int os_trim(int fd, unsigned long long start, range[0] = start; range[1] = len; - if (!ioctl(fd, IOCTLTRIM, range)) + if (!ioctl(f->fd, IOCTLTRIM, range)) return 0; return errno; @@ -234,4 +232,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