X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=os%2Fos-freebsd.h;h=c55a7c315ca2efc2ab609f5d60019da0805f46b3;hb=619adf9c5aa472904eec3a62f13030e6b261ea25;hp=e517ec0f261f5ae618ac1395a52d581c3a15b541;hpb=617a2013384ae474177a8a9c151468e3d3fd8944;p=fio.git diff --git a/os/os-freebsd.h b/os/os-freebsd.h index e517ec0f..c55a7c31 100644 --- a/os/os-freebsd.h +++ b/os/os-freebsd.h @@ -1,32 +1,49 @@ #ifndef FIO_OS_FREEBSD_H #define FIO_OS_FREEBSD_H +#define FIO_OS os_freebsd + #include #include +#include +#include +#include + +#include "../file.h" -#define FIO_HAVE_POSIXAIO #define FIO_HAVE_ODIRECT +#define FIO_USE_GENERIC_RAND +#define FIO_USE_GENERIC_INIT_RANDOM_STATE +#define FIO_HAVE_CHARDEV_SIZE +#define FIO_HAVE_GETTID #define OS_MAP_ANON MAP_ANON -typedef unsigned long os_cpu_mask_t; -typedef unsigned int os_random_state_t; +#define fio_swap16(x) bswap16(x) +#define fio_swap32(x) bswap32(x) +#define fio_swap64(x) bswap64(x) + +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) { - off_t end = lseek(fd, 0, SEEK_END); + off_t size; - if (end < 0) - return errno; + if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) { + *bytes = size; + return 0; + } - *bytes = end; - return 0; + *bytes = 0; + return errno; +} + +static inline int chardev_size(struct fio_file *f, unsigned long long *bytes) +{ + return blockdev_size(f, bytes); } -static inline int blockdev_invalidate_cache(int fd) +static inline int blockdev_invalidate_cache(struct fio_file *f) { return EINVAL; } @@ -41,17 +58,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) +static inline int gettid(void) { - srand(seed); -} - -static inline long os_random_long(os_random_state_t *rs) -{ - long val; + long lwpid; - val = rand_r(rs); - return val; + thr_self(&lwpid); + return (int) lwpid; } +#ifdef MADV_FREE +#define FIO_MADV_FREE MADV_FREE +#endif + #endif