path: root/os/windows/posix.c
AgeCommit message (Collapse)Author
2020-09-12windows: fix DWORD format string complaintsSitsofe Wheeler
Printing DWORD variables causes Windows clang to grumble about types: os/windows/cpu-affinity.c:263:5: error: format specifies type 'int' but the argument has type 'DWORD' (aka 'unsigned long') [-Werror,-Wformat] GetLastError()); ^~~~~~~~~~~~~~ Since a DWORD is defined to be an unsigned 32 bit integer and is declared to be an unsigned long ( ) just use long as the format specifier. When printing the cpu mask in hex on legacy Windows builds, cast to unsigned long long which should be safe because there won't be more than 64 CPUs with old versions of Windows. (As some format strings are longer than the wrapping width, make an exception and avoid splitting/preserve them to make greping easier) Suggested-by: Bart Van Assche <> Signed-off-by: Sitsofe Wheeler <>
2020-07-04os/windows/posix.c: Use INVALID_SOCKET instead of < 0Bart Van Assche
From "Because the SOCKET type is unsigned, compiling existing source code from, for example, a UNIX environment may lead to compiler warnings about signed/unsigned data type mismatches. This means, for example, that checking for errors when the socket and accept functions return should not be done by comparing the return value with -1, or seeing if the value is negative (both common and legal approaches in UNIX). Instead, an application should use the manifest constant INVALID_SOCKET as defined in the Winsock2.h header file." This patch fixes the following build error for the latest version of the MinGW64 cross-compiler on Cygwin: os/windows/posix.c:886:17: error: comparison of unsigned expression < 0 is always false Signed-off-by: Bart Van Assche <>
2020-07-04os/windows/posix.c: Strip trailing whitespaceBart Van Assche
Signed-off-by: Bart Van Assche <>
2020-01-06Windows: Use snprintf() instead of StringCch*()Bart Van Assche
Use ANSI C functions instead of Windows-specific functions. Signed-off-by: Bart Van Assche <>
2018-09-12windows: make win_to_posix_error() more resilientJens Axboe
If we pass in ERROR_SUCCESS, we should get a zero back. Signed-off-by: Jens Axboe <>
2018-09-11windows: fix the most egregious posix.c style errorsJens Axboe
Signed-off-by: Jens Axboe <>
2018-09-11windows: handle ERROR_NOT_READYJens Axboe
The windows-to-posix error translation doesn't include ERROR_NOT_READY, add that. Also add a default case that catches if we don't know what an error is, and return EIO. That seems much safer than just returning the Windows error directly, since the caller expects an errno. Signed-off-by: Jens Axboe <>
2018-07-23Add support for >= 4G block sizesJeff Furlong
For trims, it's useful to be able to support larger than (or equal to) 4GB. This extends the block sizes support for that. Change from Jeff, various little fixups from me. Signed-off-by: Jens Axboe <>
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-21Use POSIX path for poll.h and fcntl.h headersSitsofe Wheeler
musl complains when using include paths like <sys/poll.h> rather than POSIX's <poll.h> so change the poll.h include path and update the windows poll.h compatibility shim to match. Allegedly sys/poll.h was needed for GLIBCs that were older than 2.3 according to but I can still see that path in an ancient Red Hat 5.0 glibc-devel-2.0.7-32.i386.rpm ... Signed-off-by: Sitsofe Wheeler <>
2017-12-14Fix Windows local timeJeff Furlong
The fio summary output shows when the job completed, but references system time on Windows. On Linux, local time (such as with time zone specifics) is referenced. This patch converts Windows system time to local time. Before: fio-3.2-72-ge80d-dirty Starting 1 thread Jobs: 1 (f=0): [f(1)][100.0%][r=69.6MiB/s,w=0KiB/s][r=17.8k,w=0 IOPS][eta 00m:00s] test: (groupid=0, jobs=1): err= 0: pid=1360: Wed Dec 13 23:21:16 2017 <--System Time After: fio-3.2-72-ge80d-dirty Starting 1 thread Jobs: 1 (f=0): [f(1)][100.0%][r=73.2MiB/s,w=0KiB/s][r=18.7k,w=0 IOPS][eta 00m:00s] test: (groupid=0, jobs=1): err= 0: pid=8088: Wed Dec 13 15:22:07 2017 <--Local Time Signed-off-by: Jens Axboe <>
2017-09-18fix strncpy(3) copy lengthTomohiro Kusumi
0 terminate the last byte, and copy at most size-1. (or 0 terminate the last byte after copying upto size bytes) Signed-off-by: Tomohiro Kusumi <> Signed-off-by: Jens Axboe <>
2017-06-21nanosecond: initial commit changing timeval to timespecVincent Fu
struct timeval has usec resolution whereas struct timespec has nsec resolution. This commit changes several dozen instances of struct timeval to struct timespec. All of the output is unchanged. The ticks to nsec conversion in this patch is broken but fixed in a later patch.
2017-02-19Silence Cygwin warning "'vsprintf_s' redeclared without dllimport..."Tomohiro Kusumi
Silence a compiler warning which used to didn't show up with some old version of Cygwin. ad9c0fbc in 2012 added this, but it seems this prototype should have been declared by an appropriate header that's already been included here, so drop this prototype. It also sounds what this message means according to Google. Feel free to drop this if this is really needed for some reason. os/windows/posix.c:43:5: warning: 'vsprintf_s' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] int vsprintf_s( ^ Signed-off-by: Tomohiro Kusumi <> Signed-off-by: Jens Axboe <>
2017-02-13Windows: re-enable the mmap ioengine and fix static assertsRebecca Cran
Windows supports mmap functionality via the CreateFileMapping and MapViewOfFile functions. Update posix.c and re-enable the mmap ioengine in the Makefile. Also, enable the built-in static asserts, without which the build breaks when configured with --disable-optimizations. Signed-off-by: Jens Axboe <>
2016-10-12Implement nice() for WindowsBruce Cran
Map the following ranges for the "nice" option: Less than -15: High -1 through -15: Above normal 0: Normal 1 through 15: Below normal More than 15: Low/Idle Signed-off-by: Jens Axboe <>
2016-09-20os/windows/posix.c: ensure that ctime_r() adds a newlineJens Axboe
The normal POSIX versions do that. And as fio proper strips the newline, we end up losing the last digit if the Windows version does not add the newline. Signed-off-by: Jens Axboe <>
2016-09-19Windows: fix Time_tToSystemTime function to be 64-bit compliantJosh Sinykin
Use LONGLONG instead of LARGE_INTEGER to avoid problems on 64-bit systems causing a crash. Signed-off-by: Jens Axboe <>
2016-05-16Windows crash in ctime_r()Michael Schoberg (mschoberg)
I think I found an issue in os\windows\posix.c that results in a FIO crash (on Windows.) I'm including a patch that resolves the crash for us, but includes another (optional) fix. Crash issue: possix.c - ctime_r() will reference a negative array index on Sunday. SYSTEMTIME states the days of the week as: "0=Sunday, .. , 6=Saturday." The "fix" can likely be dialed back to safely assume the days/months will adhere to how they're documented. Optional - StringCchPrintfA() calls should allow for the string plus a NULL character. Instead, the value getting passed in is for the entire string size. os/windows/posix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Signed-off-by: Jens Axboe <>
2015-05-07Add Windows ctime_r implementation and add empty ioctl.h headerBruce Cran
stat.c now uses ctime_r(), so add an implementation for Windows. It's expected that ioctl.h exists on each platform, even if it's not used: add an empty file on Windows. Signed-off-by: Jens Axboe <>
2013-11-01Implement writev on WindowsBruce Cran
The network code depends on writev(), so implement it for Windows. 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-05-29posix_fadvise is now provided in helpers.c: remove it from the Windows posix.cBruce Cran
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 mlock, remove ftruncate and fix error handling.Bruce Cran
Functions in posix.c need to use win_to_posix_err to convert errors from Windows API calls to their equivalent POSIX error code so perror etc. work: move it into posix.c and add the prototype to posix.h. Fix error handling so -1 is always returned on error and errno is set. Fix mlock to work with sizes greater than about 1MB: the working set size needs to be increased for the new allocation. Remove ftruncate from posix.c, since MinGW already provides it. 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-02-06Get rid of fallocate on WindowsJens Axboe
Fallocate is only useful if it is a fast operation, helping the file system allocate and setup meta data for the given size. So don't punt to zero filling the entire thing. Signed-off-by: Jens Axboe <>
2013-01-24Use RUSAGE_THREAD, if availableHuadong Liu
Signed-off-by: Jens Axboe <>
2013-01-23windows: don't provide strsep(), fio already has oneJens Axboe
Signed-off-by: Jens Axboe <>
2013-01-21windows: use hweight64(), it's a 64-bit typeJens Axboe
Courtesy of Bruce. Signed-off-by: Jens Axboe <>
2013-01-21Fix _SC_NPROCESSORS_ONLN on WindowsBruce Cran
_SC_NPROCESSORS_ONLN was returning the wrong value on Windows because GetLogicalProcessorInformation() returns data about caches, nodes and packages in addition to processors. Modified by Jens to use hweight32() 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-10-10Windows: avoid large writes during file layout.Bruce Cran
Avoid large buffered writes during file layout by flushing changes to disk by calling _commit() after each write. Signed-off-by: Jens Axboe <>
2012-10-10fio patch: Windows netio fixesBruce Cran
Jens, I've attached a patch to fix netio on Windows: Add call to WSAStartup() to engines\net.c. Fix NULL dereference in poll(). Add inet_aton(). -- Bruce Cran Signed-off-by: Jens Axboe <>
2012-10-03XP/2003 compatability fixBruce Cran
The attached patch fixes the bug that on XP fio fails with: "The procedure entry point vsprintf_s could not be located in the dynamic link library msvcrt.dll". Only Vista and newer have the 'secure' functions, so we need to use vsprintf to maintain compatibility with XP. Signed-off-by: Jens Axboe <>
2012-09-06windows: reduce block size used in posix_fallocate()Bruce Cran
Reduce the buffer size in posix_fallocate() to avoid compatability problems. Signed-off-by: Jens Axboe <>
2012-08-21Windows fio: implement some more POSIX functionsBruce Cran
Implement opendir, closedir, readdir, and basic openlog, closelog and syslog functionality on Windows. Remove inet_aton since it wasn't being used. Remove warning that msync isn't implemented - just return an error. Signed-off-by: Jens Axboe <>
2012-08-17Windows fio fixesBruce Cran
Here's the latest set of Windows fio fixes: Windows posix.c fixes Reset the file pointer at the end of posix_fallocate(). Use 64-bit versions of tell() and seek(). Fix basename(). Use uint64_t instead of unsigned long long. Signed-off-by: Jens Axboe <>
2012-08-16fix 32-bit Windows fio (overflow in getusage and gettimeofday)Bruce Cran
Fix overflow in getrusage and gettimeofday for 32-bit versions of fio on Windows. Signed-off-by: Jens Axboe <>
2012-08-15fio: add nanosleep() to WindowsBruce Cran
I've attached a patch which adds an implementation of nanosleep() to Windows, fixing rate-limiting. Signed-off-by: Jens Axboe <>
2012-06-08Windows 32-bit fio fixesBruce Cran
Fix no-op shift in shmget by casting to 64-bit. Generate a new Product GUID for fio 2.0.8. Add the 32-bit MinGW-w64 compiler executable name in Makefile. 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-22Implement sigaction for Windows.Bruce Cran
Signed-off-by: Jens Axboe <>
2012-02-20Fix tabbing and comment characters in Windows code.Bruce Cran
Update syslog.h with proper flag values. Signed-off-by: Jens Axboe <>
2012-02-20Add missing os/windows/posix.c file.Bruce Cran
Signed-off-by: Jens Axboe <>