path: root/os/os-windows.h
AgeCommit message (Collapse)Author
2020-12-26windows: drop XP supportSitsofe Wheeler
Windows 2003 has been EOL since 2015 and Windows XP has been EOL since 2014. Technically fio hasn't been properly targetting XP anyway - (see 16d40a15783f9181d64082fc00a970dff485798f 'configure: be explicit about "XP" Windows API version'). - Strip out support for XP and change the documentation to no longer mention it - Stop targetting XP in the CI 32 bit build Next stop, Windows 7... Signed-off-by: Sitsofe Wheeler <>
2020-03-01filesetup: fix win raw disk access and improve dir creation failure msgSitsofe Wheeler
The commit df18600fd06258b96ae6f6b530ecdff541c2a82d ("filesetup: fix directory creation issues") broke Windows raw/physical disk access because Windows doesn't consider a path that only consists of a namespace (such as the device namespace "\\.\" - see for information on Windows' namespaces) to exist as a directory(!). Workaround the issue for raw devices by explicitly considering the device namespace subcomponent to always be valid. Further, intermediate path components in UNC paths or paths starting with a namespace might also not "exist" so introduce backwards scanning for the longest pre-existing directory to sidestep this. The function doing this is made available for non-windows platforms so a similar code path is used everywhere. Tests done: Windows: > ./fio.exe --name=dtest --thread --size=16k --rw=write ` --filename 'fio.tmp' > ./fio.exe --name=dtest --thread --size=16k --rw=write ` --filename '\\?\C\:\Windows\Temp\fio\fio.tmp' > Clear-Disk 1 -RemoveData -Confirm:$false # Destroys partition data! > ./fio.exe --name=dtest --thread --size=16k --rw=write ` --filename '\\.\PhysicalDrive1' > ./fio.exe --name=dtest --thread --size=16k --rw=write ` --filename '\fio.tmp' > ./fio.exe --name=dtest --thread --size=16k --rw=write ` --filename '\\LOCALHOST\Users\User\fio\fio.tmp' macOS: $ rm -rf /tmp/fio $ ./fio --name=dtest --size=16k --filename /tmp/fio/fio.tmp \ --rw=write Finally, change the directory creation error message to give a human error message rather than just an errno. Fixes: Signed-off-by: Sitsofe Wheeler <>
2020-01-06Windows: Uninline CPU affinity functionsBart Van Assche
None of the CPU affinity functions is in the hot path. Reduce the build time by uninlining these functions. Signed-off-by: Bart Van Assche <>
2020-01-06Windows: Remove more unused OS dependent codeBart Van Assche
Since commit 46bfd4e5170e ("Remove old OS dependent (unused) random code") rand_r() is no longer used. Hence remove its definition. Signed-off-by: Bart Van Assche <>
2019-12-18filesetup: fix directory creation issuesSitsofe Wheeler
- Fix double directory prefix concatenation that was happening after 95af8dd57a7a9a564f99492bb1e04bb6d13b95b1 ("filesetup: don't call create_work_dirs() for ioengine with FIO_DISKLESSIO") refactored some code - Stop always using '/' and switch to using FIO_OS_PATH_SEPARATOR when concatenating the directory value to the filename in set_name_idx() - Change the permissions directories are created with to have the execute bit so they can be entered(!) - Fix bug where filenames that were absolute unix paths would prevent the creation of intermediate directories - Remove the configure mkdir test and introduce fio_mkdir to hide mkdir platform differences - Make Windows mkdir emulation more robust against multiple slashes after the drive letter and when dealing dealing with with paths containing drive letters in general This commit makes the following work on Windows: ./fio --thread --name=doubleslashtest \ --filename='C\:\\Windows\Temp\fio.tmp' --size=4k --bs=4k --rw=read The next example now works when D:\1\ exists but D:\1\2\ doesn't: ./fio --thread --name=mkdirtest --directory='D\:\1' \ --filename='2\fio.tmp' --size=4k --bs=4k --rw=read The following now works on macOS/Linux when /tmp/1/ exists but /tmp/1/2/ doesn't: ./fio --name=mkdirtest --directory='/tmp/1' \ --filename='2/fio.tmp' --size=4k --bs=4k --rw=read Fixes , and Tested-by: Astolfo Rueda <> Signed-off-by: Sitsofe Wheeler <>
2019-05-22configure: add gettid() testJens Axboe
Apparently some newer glibcs now have it, decades after the fact. Signed-off-by: Jens Axboe <>
2019-04-17rand: fix truncated rand_seed on WindowsMing-Hung Tsai
The long data type is 32-bit on LLP64 platforms
2018-10-08Remove old OS dependent (unused) random codeJens Axboe
Signed-off-by: Jens Axboe <>
2018-08-03platforms/windows: Add S_ISSOCK macro.Adam Kupczyk
Signed-off-by: Adam Kupczyk <>
2018-03-27windows: target Windows 7 and add support for more than 64 CPUsSitsofe Wheeler
Introduce support for targeting the build to either Windows XP or Windows 7 (the default). When targeting Windows 7 this allows us to use the process group APIs which are required are required to support more than 64 CPUs. These changes mean if you want a Windows binary that supports versions of Windows below Windows 7/Windows Server 2008 R2 you will need to explicitly use the --target-win-ver=xp configure option at build time. Such builds will lack features (such as the ability to access CPUs beyond those in fio's default process group) that are dependent on recent Windows APIs. Signed-off-by: Sitsofe Wheeler <>
2018-03-27windows: prepare for Windows build splitSitsofe Wheeler
Signed-off-by: Sitsofe Wheeler <>
2017-11-16os: make fio_cpu_isset() return a boolJens Axboe
Signed-off-by: Jens Axboe <>
2017-11-16os-windows: fix cpumask operationsRobert Elliott
Fix cpumask manipulation on (64-bit) Windows systems. cpus_allowed=nn values greater than 32 does not work, due to * the compiler not promoting expressions like "1 << cpu" to 64 bits * the clear function clearing the wrong bit (using "cpu - 1"), * the clear function using XOR to clear (which only works if the bit was previously set) * the check function returning a 64-bit value through a 32-bit return value Example problems (from extra debug prints): * setting CPU 32 really sets bit 0 (CPU 0) Set mask of 0000000000000000 to add 0000000000000001 (32) * setting CPU 63 really sets bit 31 (CPU 31) Set mask of 0000000000000000 to add 0000000080000000 (63) * clearing CPU 0 really clears bit 63 (CPU 63) Clear mask of 0000000055555555 to remove 8000000000000000 (0) * clearing CPU 2 really clears bit 2 (CPU 2) Clear mask of 0000000055555555 to remove 0000000000000002 (2) * checking claims CPU 32 is not in a mask of CPUs {32,34,36,38} for 0000005500000000 check if bit 32 is set ==> FALSE Tested with x86_64-w64-mingw32-gcc 6.4.0 from cygwin on a system with 64 CPU cores (all fitting in one Windows processor group). Signed-off-by: Jens Axboe <>
2017-10-11Fix broken path separator definition on WindowsJens Axboe
Fixes: 53a7af851836 ("convert FIO_OS_PATH_SEPARATOR to a character") Signed-off-by: Jens Axboe <>
2017-10-11convert FIO_OS_PATH_SEPARATOR to a characterJosef Bacik
Instead of a string let's use this as a character so we can search for it in path names. Signed-off-by: Josef Bacik <> Signed-off-by: Jens Axboe <>
2017-05-23Drop struct thread_data dependency from os headersTomohiro Kusumi
Since os/os.h is included by fio.h before other functions/structures are even defined, it's better for os/os*.h not to have dependency on those (in this case it's struct thread_data and duplicated td_fill_ rand_seeds() prototypes) unless really needed. os/os*.h are basically collections of small wrappers over syscalls/etc whose idea is similar but with difference interface among supported platforms, thus they normally don't need to have dependency on fio functions/structures, and in fact they're normally designed that way. This commit gets rid of struct thread_data argument from an inlined function init_random_state(), which was needed only to call another function td_fill_rand_seeds(td). This can simply be called from setup_random_seeds() after init_random_state() without making any functional difference. Also rename init_random_state() to init_random_seeds() as it only initializes random seeds now. With this commit, struct thread_data is completely gone from os/. struct fio_file is still there, but this is needed by Windows where the idea of fd differs from unix like in general. Signed-off-by: Tomohiro Kusumi <> Signed-off-by: Jens Axboe <>
2017-03-13Use ENOTSUP if OS doesn't support blkdev page cache invalidationTomohiro Kusumi
The return value of blockdev_invalidate_cache() has been platform dependent (some pretend success, others return EINVAL) while Linux is the only one actually supports this via Linux specific ioctl. This commit makes all the rest return a consistent value ENOTSUP, so __file_invalidate_cache() prints a blkdev invalidation failure message that is consistent and makes sense. Signed-off-by: Tomohiro Kusumi <> Signed-off-by: Jens Axboe <>
2016-07-27Make return value type of fio_getaffinity() consistentTomohiro Kusumi
Return type of fio_getaffinity() isn't consistent among supported OS. Windows and DragonFlyBSD return void while FreeBSD version is int. The default version for those that don't support is do{}while(0). Linux version is a macro for sched_getaffinity(2) which returns 0 on success and -1 otherwise, so others should basically follow that. Note that I haven't compiled this on Windows, but it shouldn't fail. Signed-off-by: Tomohiro Kusumi <> Signed-off-by: Jens Axboe <>
2016-01-22Fix Windows build: define rand_r()Bruce Cran
2015-11-30Move conditional lib files to oslib/Jens Axboe
Signed-off-by: Jens Axboe <>
2015-10-08Fix Windows build by using lib/strcasestr.{c,h}Bruce Cran
Signed-off-by: Jens Axboe <>
2015-05-07Fix compiler warning and test progs linker errors on WindowsBruce Cran
Add prototype for ctime_r to os-windows.h to avoid compiler warning. Link in os/windows/posix.o and lib/hweight.o to allow test progs to build on Windows. Signed-off-by: Jens Axboe <>
2014-03-12stat: fixup fio-dump-status file locationJens Axboe
Don't use /tmp in the actual file name. And kill unused Windows os_get_tmpdir(). Signed-off-by: Jens Axboe <>
2014-02-28cpus_allowed_policy fixupsJens Axboe
- Make 'split' roundrobin the CPUs, if we have more threads than CPUs in the set. - Properly use a CPU index, don't assume a sequential set of CPUs. Signed-off-by: Jens Axboe <>
2014-02-27windows: fix fio_cpu_count() definitionJens Axboe
Don't take a 'cpu' argument, that's a leftover when this was (temporarily) fio_cpu_isset(). Signed-off-by: Jens Axboe <>
2014-02-27windows: add proper header for hweight64()Jens Axboe
Signed-off-by: Jens Axboe <>
2014-02-27Add support for cpus_allowed_policyJens Axboe
Two policies are supported: shared cpumask is shared between all threads. This is the original behavior. split cpumask is split between threads, each thread gets a unique CPU. Signed-off-by: Jens Axboe <>
2013-11-01Update Windows code to fix build breakageBruce Cran
MinGW has been updated: this causes problems due to changes in header files, including COM stuff being pulled in resulting in 'interface' being a reserved keyword, and changes to a few POSIX definitions. Signed-off-by: Jens Axboe <>
2013-04-23Fix Windows build warnings.Bruce Cran
winsock2.h needs to be included before windows.h. Separate declarations and code. Signed-off-by: Jens Axboe <>
2013-02-07Windows: fix sysconf(_SC_PHYS_PAGES).Bruce Cran
sysconf(_SC_PHYS_PAGES) was returning the number of bytes of memory instead of the number of pages. Also improve some error messages in sysconf(). Update os_phys_mem() to use sysconf(). Signed-off-by: Jens Axboe <>
2013-01-30configure: add SCHED_IDLE checkJens Axboe
We can't consider it always available on Linux. It fails on Debian 6.x, for instance. Signed-off-by: Jens Axboe <>
2013-01-30Add support for idletime profilingHuadong Liu
Idletime profiling allows a benchmark to run while filling the idle cycles on the server, hence giving you some metric of how much pressure the system is under. This is useful to be able to profile and compare changes in a setup or driver, for instance. Signed-off-by: Jens Axboe <>
2013-01-24configure: kill windows FIO_HAVE_FDATASYNCJens Axboe
Signed-off-by: Jens Axboe <>
2013-01-24configure: solaris and windowsaio fixupsJens Axboe
Signed-off-by: Jens Axboe <>
2013-01-24Correct ifdef checks for posix and linux fallocateJens Axboe
Signed-off-by: Jens Axboe <>
2013-01-23Fix compile warnings on WindowsJens Axboe
Signed-off-by: Jens Axboe <>
2013-01-23configure: add endian checkJens Axboe
Will remove guesswork and manual hacking in the OS headers. Signed-off-by: Jens Axboe <>
2013-01-18Windows: fix off-by-one error in fio_cpu_set and add affinity error messages.Bruce Cran
Signed-off-by: Jens Axboe <>
2013-01-10Add configure scriptJens Axboe
Get rid of all the fragile guessing and checking of features, and roll a configure script instead. Signed-off-by: Jens Axboe <>
2012-12-06Fix windows out-of-memory handlingBruce Cran
Signed-off-by: Jens Axboe <>
2012-04-16Windows build fixesBruce Cran
Bruce writes: SIGUSR1 isn't defined on Windows so I've defined it. Also, MSI packages need a version string of x.x.x.x where x is between 0 and 65535 so we can't include the git hash. It's easier just to go back to hard-coding the version for now, and I'll update it (and the product GUID) when I create a new package (it doesn't need checked in each time). Also, Cygwin doesn't like $(SHELL_PATH) but $(SHELL) seems to work - does $(SHELL) cause a problem on other platforms? Signed-off-by: Jens Axboe <>
2012-04-04Windows fixesBruce Cran
Only return from fio_windowsaio_getevents if the minimum number of IOs has completed. Add posix_fallocate implementation to avoid extending the file during the test. Move call to ResetEvent into windowsaio_getevents where other reset code is located. Fix tabs vs. spaces in windowsaio.c and the installer sources. Signed-off-by: Jens Axboe <>
2012-02-20Move Windows port to MinGWBruce Cran
- Add calls to WSAStartup in the network code as required by Winsock. - Add Windows-specific init_random_state function which uses the Crypto API. - Move Windows port to MinGW and update build system to create a 64-bit binary by default. - Install text files as .rtf so they won't open in Notepad by default (Wordpad understands Unix line endings; Notepad doesn't). - Simplify WiX installer code. Signed-off-by: Jens Axboe <>
2011-10-08Fix Windows issue with socklen_tBruce Cran
Signed-off-by: Jens Axboe <>
2011-10-07Pass arch/os in probeJens Axboe
Signed-off-by: Jens Axboe <>
2011-10-04More endianness for platformsJens Axboe
Signed-off-by: Jens Axboe <>
2011-07-14Windows affinity fix for thread based jobsBruce Cran
Signed-off-by: Jens Axboe <>
2011-07-14Add CPU affinity support to WindowsBruce Cran
Signed-off-by: Jens Axboe <>
2011-01-19Define OS preferred IO engineJens Axboe
Signed-off-by: Jens Axboe <>
2011-01-08Various fixes/updatesBruce Cran
- Update HOWTO to note that directio and fallocate don't work with ZFS on Solaris. Refactor the Makefile's to add CPPFLAGS and LIBS. - Add -fno-omit-frame-pointer from Linux Makefile to every platform - Change undefined $(ALL_CFLAGS) to $(CFLAGS) - Pass -std=gnu99, without which OS X fails to build. - Add -D__EXTENSIONS__ on Solaris since some functions we need are behind it. - Pull in <limits.h> in fio.c to get PTHREAD_STACK_MIN. - NetBSD doesn't define PTHREAD_STACK_MIN so set it to 4k in os-netbsd.h - If we have posix_fallocate don't error out if it fails during mutex and malloc operations since it will fail on Solaris with a ZFS filesystem. As I understand it these aren't performance-critical operations so do they need to be considered critical? - Remove fio_unused from os-* files since it's defined in fio.h and we don't really need it. - FreeBSD has an idprio command but not the API so don't claim it does. - OS X doesn't have the timer_* API so emulate it using setitimer/sigaction. - NetBSD and Solaris don't support CLOCK_MONOTONIC in timer_create so remove FIO_HAVE_CLOCK_MONOTONIC from their os-* files. I've noticed that a change I made a while ago to use fmin/fmax could cause issues on older OSes - I had a CD with NetBSD 5.0.2 and found they had only been implemented in 5.1 so I'm not sure if I should revert it. Signed-off-by: Jens Axboe <>