X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=os%2Fos-windows.h;h=09f9c5438d2ff1580d16ab2b5586da488866b648;hp=18de83987d635281329cfffe98816616e26a737d;hb=cab2440c23426b06e7e8327c5353fbd8373dcb5a;hpb=0dcebdf4a70ef0d8144b8fcba763ae87e7fc74b5 diff --git a/os/os-windows.h b/os/os-windows.h index 18de8398..09f9c543 100644 --- a/os/os-windows.h +++ b/os/os-windows.h @@ -15,12 +15,11 @@ #include "../file.h" #include "../log.h" +#include "windows/posix.h" + #define FIO_HAVE_ODIRECT #define FIO_HAVE_CPU_AFFINITY #define FIO_HAVE_CHARDEV_SIZE -#define FIO_HAVE_FDATASYNC -#define FIO_HAVE_WINDOWSAIO -#define FIO_HAVE_FALLOCATE #define FIO_HAVE_GETTID #define FIO_USE_GENERIC_RAND @@ -36,9 +35,6 @@ #define fio_swap32(x) _byteswap_ulong(x) #define fio_swap64(x) _byteswap_uint64(x) -typedef off_t off64_t; -typedef int clockid_t; - typedef DWORD_PTR os_cpu_mask_t; #define CLOCK_REALTIME 1 @@ -155,12 +151,14 @@ static inline int blockdev_invalidate_cache(struct fio_file *f) static inline unsigned long long os_phys_mem(void) { - SYSTEM_INFO sysInfo; - uintptr_t addr; + long pagesize, pages; - GetSystemInfo(&sysInfo); - addr = (uintptr_t)sysInfo.lpMaximumApplicationAddress; - return (unsigned long long)addr; + pagesize = sysconf(_SC_PAGESIZE); + pages = sysconf(_SC_PHYS_PAGES); + if (pages == -1 || pagesize == -1) + return 0; + + return (unsigned long long) pages * (unsigned long long) pagesize; } static inline void os_get_tmpdir(char *path, int len) @@ -251,4 +249,11 @@ static inline int init_random_state(struct thread_data *td, unsigned long *rand_ } +static inline int fio_set_sched_idle(void) +{ + /* SetThreadPriority returns nonzero for success */ + return (SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE))? 0 : -1; +} + + #endif /* FIO_OS_WINDOWS_H */