X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=os%2Fos-freebsd.h;h=2a7b7b327a83f6fb50eb7f1839108ca108b9e1ef;hp=01c5ce917b57d9501774cd80d8a84e82b6df6b35;hb=e65a950ab73d7d91f267ad7f7b084d94e266fcb0;hpb=317b95d07d4921d2594a1be6e014c9c2d062fe75 diff --git a/os/os-freebsd.h b/os/os-freebsd.h index 01c5ce91..2a7b7b32 100644 --- a/os/os-freebsd.h +++ b/os/os-freebsd.h @@ -1,30 +1,59 @@ #ifndef FIO_OS_FREEBSD_H #define FIO_OS_FREEBSD_H +#define FIO_OS os_freebsd + +#include #include +#include +#include +#include +#include + +#include "../file.h" -#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_STRSEP +#define FIO_USE_GENERIC_RAND +#define FIO_USE_GENERIC_INIT_RANDOM_STATE +#define FIO_HAVE_CHARDEV_SIZE +#define FIO_HAVE_GETTID +#define FIO_HAVE_CLOCK_MONOTONIC + +#define OS_MAP_ANON MAP_ANON + +#if BYTE_ORDER == LITTLE_ENDIAN +#define FIO_LITTLE_ENDIAN +#else +#define FIO_BIG_ENDIAN +#endif -#define OS_MAP_ANON (MAP_ANON) +#define fio_swap16(x) bswap16(x) +#define fio_swap32(x) bswap32(x) +#define fio_swap64(x) bswap64(x) -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 blockdev_invalidate_cache(int fd) +static inline int chardev_size(struct fio_file *f, unsigned long long *bytes) +{ + return blockdev_size(f, bytes); +} + +static inline int blockdev_invalidate_cache(struct fio_file *f) { return EINVAL; } @@ -39,24 +68,16 @@ 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) +static inline int gettid(void) { - long val; + long lwpid; - val = rand_r(rs); - return val; + thr_self(&lwpid); + return (int) lwpid; } -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