X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=os%2Fos-windows.h;h=243edc676fd94ac15194eb5f8da0d061a15a9039;hp=3a8563744af6fefb1235d9c868af5890e09f419b;hb=a1fc70fbb0497a4e0dc061bd8fc35c8d4d29d2dd;hpb=97ac992c99d89eed8cdf9249bb038ac4d7b709b9 diff --git a/os/os-windows.h b/os/os-windows.h index 3a856374..243edc67 100644 --- a/os/os-windows.h +++ b/os/os-windows.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -14,14 +15,17 @@ #include "../smalloc.h" #include "../file.h" #include "../log.h" +#include "../lib/hweight.h" #include "windows/posix.h" +#ifndef PTHREAD_STACK_MIN +#define PTHREAD_STACK_MIN 65535 +#endif + #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_GETTID #define FIO_USE_GENERIC_RAND @@ -39,9 +43,6 @@ typedef DWORD_PTR os_cpu_mask_t; -#define CLOCK_REALTIME 1 -#define CLOCK_MONOTONIC 2 - #define _SC_PAGESIZE 0x1 #define _SC_NPROCESSORS_ONLN 0x2 #define _SC_PHYS_PAGES 0x4 @@ -114,6 +115,8 @@ static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) { int rc = 0; HANDLE hFile; + GET_LENGTH_INFORMATION info; + DWORD outBytes; if (f->hFile == NULL) { hFile = CreateFile(f->file_name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -122,10 +125,6 @@ static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) hFile = f->hFile; } - GET_LENGTH_INFORMATION info; - DWORD outBytes; - LARGE_INTEGER size; - size.QuadPart = 0; if (DeviceIoControl(hFile, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &info, sizeof(info), &outBytes, NULL)) *bytes = info.Length.QuadPart; else @@ -153,12 +152,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; + + pagesize = sysconf(_SC_PAGESIZE); + pages = sysconf(_SC_PHYS_PAGES); + if (pages == -1 || pagesize == -1) + return 0; - GetSystemInfo(&sysInfo); - addr = (uintptr_t)sysInfo.lpMaximumApplicationAddress; - return (unsigned long long)addr; + return (unsigned long long) pages * (unsigned long long) pagesize; } static inline void os_get_tmpdir(char *path, int len) @@ -214,6 +215,11 @@ static inline void fio_cpu_set(os_cpu_mask_t *mask, int cpu) *mask |= 1 << cpu; } +static inline int fio_cpu_count(os_cpu_mask_t *mask) +{ + return hweight64(*mask); +} + static inline int fio_cpuset_init(os_cpu_mask_t *mask) { *mask = 0; @@ -249,4 +255,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 */