1 #ifndef FIO_OS_WINDOWS_H
\r
2 #define FIO_OS_WINDOWS_H
\r
4 #include <sys/types.h>
\r
8 #include "../smalloc.h"
\r
12 #define FIO_HAVE_ODIRECT
\r
13 #define FIO_USE_GENERIC_RAND
\r
14 #define FIO_HAVE_CHARDEV_SIZE
\r
15 #define FIO_USE_GENERIC_RAND
\r
17 #define FIO_HAVE_FALLOCATE
\r
18 #define FIO_HAVE_FDATASYNC
\r
19 #define FIO_HAVE_WINDOWSAIO
\r
21 #define OS_MAP_ANON MAP_ANON
\r
23 #define OS_CLOCK CLOCK_REALTIME
\r
25 #define FIO_PREFERRED_ENGINE "windowsaio"
\r
27 typedef off_t off64_t;
\r
30 LARGE_INTEGER Length;
\r
31 } GET_LENGTH_INFORMATION;
\r
33 #define IOCTL_DISK_GET_LENGTH_INFO 0x7405C
\r
35 static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
\r
40 if (f->hFile == NULL) {
\r
41 hFile = CreateFile(f->file_name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
\r
42 NULL, OPEN_EXISTING, 0, NULL);
\r
47 GET_LENGTH_INFORMATION info;
\r
51 if (DeviceIoControl(hFile, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &info, sizeof(info), &outBytes, NULL))
\r
52 *bytes = info.Length.QuadPart;
\r
56 /* If we were passed a POSIX fd,
\r
57 * close the HANDLE we created via CreateFile */
\r
58 if (hFile != INVALID_HANDLE_VALUE && f->hFile == NULL)
\r
64 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
\r
66 return blockdev_size(f, bytes);
\r
69 static inline int blockdev_invalidate_cache(struct fio_file *f)
\r
71 /* There's no way to invalidate the cache in Windows
\r
72 * so just pretend to succeed */
\r
76 static inline unsigned long long os_phys_mem(void)
\r
78 SYSTEM_INFO sysInfo;
\r
80 GetSystemInfo(&sysInfo);
\r
81 addr = (unsigned long)sysInfo.lpMaximumApplicationAddress;
\r
85 static inline void os_get_tmpdir(char *path, int len)
\r
87 GetTempPath(len, path);
\r
91 #define FIO_MADV_FREE MADV_FREE
\r
94 #endif /* FIO_OS_WINDOWS_H */
\r