X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=os%2Fos-freebsd.h;h=0cb7ae5e5ca079380e20a514f1f0f1b9df3748c2;hp=01c5ce917b57d9501774cd80d8a84e82b6df6b35;hb=ecc314ba7c5f02b7e90ac1dfbce1a74cd4e6d6fe;hpb=317b95d07d4921d2594a1be6e014c9c2d062fe75 diff --git a/os/os-freebsd.h b/os/os-freebsd.h index 01c5ce91..0cb7ae5e 100644 --- a/os/os-freebsd.h +++ b/os/os-freebsd.h @@ -1,30 +1,41 @@ #ifndef FIO_OS_FREEBSD_H #define FIO_OS_FREEBSD_H +#include #include +#include -#undef FIO_HAVE_LIBAIO #define FIO_HAVE_POSIXAIO -#undef FIO_HAVE_FADVISE -#undef FIO_HAVE_CPU_AFFINITY -#undef FIO_HAVE_DISK_UTIL -#undef FIO_HAVE_SGIO #define FIO_HAVE_ODIRECT +#define FIO_HAVE_IOPRIO +#define FIO_HAVE_STRSEP +#define FIO_USE_GENERIC_RAND +#define FIO_HAVE_CHARDEV_SIZE +#define FIO_HAVE_CLOCK_MONOTONIC -#define OS_MAP_ANON (MAP_ANON) +#define OS_MAP_ANON MAP_ANON -typedef unsigned long os_cpu_mask_t; -typedef unsigned int os_random_state_t; +typedef off_t off64_t; -/* - * FIXME - */ -static inline int blockdev_size(int fd, unsigned long long *bytes) +static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) { - return EINVAL; + off_t size; + + if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) { + *bytes = size; + return 0; + } + + *bytes = 0; + return errno; +} + +static inline int chardev_size(struct fio_file *f, unsigned long long *bytes) +{ + return blockdev_size(f->fd, bytes); } -static inline int blockdev_invalidate_cache(int fd) +static inline int blockdev_invalidate_cache(struct fio_file *f) { return EINVAL; } @@ -39,24 +50,8 @@ static inline unsigned long long os_phys_mem(void) return mem; } -static inline void os_random_seed(unsigned long seed, os_random_state_t *rs) -{ - srand(seed); -} - -static inline long os_random_long(os_random_state_t *rs) -{ - long val; - - val = rand_r(rs); - return val; -} - -static inline double os_random_double(os_random_state_t *rs) -{ - double val; +#ifdef MADV_FREE +#define FIO_MADV_FREE MADV_FREE +#endif - val = (double) rand_r(rs); - return val; -} #endif