X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=os%2Fos-dragonfly.h;h=3c460ae2f33105574769450cba7fe817362c66a6;hp=d4a9579958ffcd16856b495e9fc79766f2feef69;hb=ce4d13ca162df4127ec3b5911553802c53396705;hpb=2c6772e2fca6803ee91bc6680eaa60433681e30c diff --git a/os/os-dragonfly.h b/os/os-dragonfly.h index d4a95799..3c460ae2 100644 --- a/os/os-dragonfly.h +++ b/os/os-dragonfly.h @@ -5,18 +5,26 @@ #include #include +#include #include #include #include #include -#include #include #include +/* API changed during "5.3 development" */ +#if __DragonFly_version < 500302 +#include +#define DAIOCTRIM IOCTLTRIM +#else +#include +#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 @@ -24,6 +32,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 +90,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); @@ -102,23 +114,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; -} - -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; + return CPUMASK_TESTBIT(*mask, cpu) != 0; } static inline int fio_setaffinity(int pid, os_cpu_mask_t mask) @@ -191,7 +189,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) @@ -204,10 +202,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) { @@ -222,7 +222,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]; @@ -230,7 +230,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, DAIOCTRIM, range)) return 0; return errno; @@ -240,4 +240,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