X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=os%2Fos-mac.h;h=a073300c40c5ed6fea8c2ec2ff4933776ef7066d;hb=07a2919d7a86607d42f5fb69f1f0ba98097d4d98;hp=0903a6fec5c4cd508ff5fefeca69a7e0b9652063;hpb=25f8227d25a77d3bc41a2044d2e662e635fa32cd;p=fio.git diff --git a/os/os-mac.h b/os/os-mac.h index 0903a6fe..a073300c 100644 --- a/os/os-mac.h +++ b/os/os-mac.h @@ -16,10 +16,10 @@ #include "../file.h" -#define FIO_USE_GENERIC_RAND #define FIO_USE_GENERIC_INIT_RANDOM_STATE #define FIO_HAVE_GETTID #define FIO_HAVE_CHARDEV_SIZE +#define FIO_HAVE_NATIVE_FALLOCATE #define OS_MAP_ANON MAP_ANON @@ -40,9 +40,9 @@ typedef unsigned int clockid_t; #endif #define FIO_OS_DIRECTIO -static inline int fio_set_odirect(int fd) +static inline int fio_set_odirect(struct fio_file *f) { - if (fcntl(fd, F_NOCACHE, 1) == -1) + if (fcntl(f->fd, F_NOCACHE, 1) == -1) return errno; return 0; } @@ -77,7 +77,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) @@ -90,10 +90,12 @@ static inline unsigned long long os_phys_mem(void) return mem; } +#ifndef CONFIG_HAVE_GETTID static inline int gettid(void) { return mach_thread_self(); } +#endif /* * For some reason, there's no header definition for fdatasync(), even @@ -101,4 +103,15 @@ static inline int gettid(void) */ extern int fdatasync(int fd); +static inline bool fio_fallocate(struct fio_file *f, uint64_t offset, uint64_t len) +{ + fstore_t store = {F_ALLOCATEALL, F_PEOFPOSMODE, offset, len}; + if (fcntl(f->fd, F_PREALLOCATE, &store) != -1) { + if (ftruncate(f->fd, len) == 0) + return true; + } + + return false; +} + #endif