posix_fallocate() looks like a better fit when increasing allocation size but you'd need to check the file size first, which introduces a race condition. posix_fallocate() will also increase the file size if the file is truncated by another thread.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7115#note_93690
--
v2: wined3d: Remove FOGVERTEXMODE handling from find_ps_compile_args().
wined3d: Remove the redundant per_vertex_point_size from vs_compile_args.
wined3d: Do not toggle point sprite.
wined3d: Do not disable point sprite in wined3d_context_gl_apply_blit_state().
https://gitlab.winehq.org/wine/wine/-/merge_requests/7260
This PR updates the behaviour of `NtQueryDirectoryFile`, bringing it in line with current Windows behaviour. The need for this update was discovered when attempting to build the Unreal Engine with MSVC under Wine. In certain cases conditional include statements do not behave as expected, due to MSVC depending on undocumented behaviour of `NtQueryDirectoryFile`.
We ran tests on multiple versions of Windows, and discovered that the behaviour has changed since the original Wine implementation, but the documentation has not. The source code for our test tool, and a set of results can be found [here](https://github.com/TensorWorks/NtQueryDirectoryFile-Test). As of Windows 8, calling `NtQueryDirectoryFile` with a re-used handle, a new mask, and setting the `RestartScan` flag to True, causes the cached results to be erased and a new scan to be performed with the updated mask. Currently, Wine performs as did earlier versions of Windows, where the changed mask is ignored, and the cache is reused. This can cause `NtQueryDirectoryFile` under Wine to falsely report that files exist, when they do not.
This PR corrects this behaviour, invalidating the cache when required. Implementing this exposed further undocumented behaviour of `NtQueryDirectoryFile`, where a search for a non-existent file will return either `STATUS_NO_MORE_FILES` or `STATUS_NO_SUCH_FILE`, depending on whether or not the handle had been previously used regardless of the value of `RestartScan`. This was reflected in a `winetest` which allowed for the response to be either `STATUS_SUCCESS` or `STATUS_NO_MORE_FILES`.
This patch also adds unit tests for the new behaviour of `NtQueryDirectoryFile`. These tests pass when running `winetest` under Windows, and under Wine with these changes in place, but they will fail under older versions of Wine. If run under older versions of Windows the test suite will detect that this functionality is not supported, and will not run the updated tests.
--
v11: ntdll.dll: Update NtQueryDirectoryFile to align with current Windows behaviour
https://gitlab.winehq.org/wine/wine/-/merge_requests/6904
"DIR /o" (no order specifier after /o) hasn't functioned the same as it does on Windows. This change makes the functionality of /o by itself equivalent to behavior on Windows.
--
v22: programs/cmd: Cleanup DIR /O logic and remove @todo_wine@ from working tests.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7131
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
--
v3: windowscodecs: Remove redundant guid-to-string conversion when writing readers registration entries.
windowscodecs: Fix a typo in metadata readers registration helper.
windowscodecs/metadata: Add a stub for WICIfdMetadataWriter.
windowscodecs/metadata: Add a stub for WICExifMetadataWriter.
windowscodecs/metadata: Add a stub for WICGpsMetadataWriter.
windowscodecs/metadata: Add a stub for WICUnknownMetadataWriter.
windowscodecs/metadata: Add registration information for the "Unknown" writer.
windowscodecs: Add a stub for IWICMetadataWriterInfo.
windowscodecs: Move an hkey handle to the component info base structure.
windowscodecs: Move component info registry key cleanup to a common failure path.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7254
"DIR /o" (no order specifier after /o) hasn't functioned the same as it does on Windows. This change makes the functionality of /o by itself equivalent to behavior on Windows.
--
v20: programs/cmd: Remove @todo_wine@ from working tests.
programs/cmd: Cleanup DIR /O logic.
programs/cmd: Add tests patch from @epo.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7131
On Tue Feb 4 17:55:14 2025 +0000, Tim Clem wrote:
> I think this calls for a quick comment (or at least a note in the commit
> message) as to why we're using this function.
Added a comment, explaining the rationale there.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7256#note_93649
`mach_continuous_approximate_time()` has the necessary precision for win32 ticks and can be up to 4x faster than `mach_continuous_time()`.
Also `clock_gettime( CLOCK_REALTIME, &ts )` calls always end up in `__commpage_gettimeofday( struct timeval *tp )`:
```
* frame #0: 0x00007ff806788763 libsystem_kernel.dylib`__commpage_gettimeofday
frame #1: 0x00007ff8066709a3 libsystem_c.dylib`gettimeofday + 45
frame #2: 0x00007ff806678b31 libsystem_c.dylib`clock_gettime + 117
```
These extra calls, setup and converting from one struct format to another costs another 60 CPU cycles and in my testing makes `NtQuerySystemTime` approximately 30% faster as well with this MR. This is a fairly hot code path (especially when using certain out-of-tree in process synchronization patch sets), so probably worth the optimization here.
All of these APIs are available since 10.12.
--
v2: ntdll: Replace '0' with 'NULL' in gettimeofday() calls.
ntdll: Use __commpage_gettimeofday in NtQuerySystemTime on macOS.
ntdll: Always use mach_continuous_approximate_time on macOS.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7256
`mach_continuous_approximate_time()` has the necessary precision for win32 ticks and can be up to 4x faster than `mach_continuous_time()`.
Also `clock_gettime( CLOCK_REALTIME, &ts )` calls always end up in `__commpage_gettimeofday( struct timeval *tp )`:
```
* frame #0: 0x00007ff806788763 libsystem_kernel.dylib`__commpage_gettimeofday
frame #1: 0x00007ff8066709a3 libsystem_c.dylib`gettimeofday + 45
frame #2: 0x00007ff806678b31 libsystem_c.dylib`clock_gettime + 117
```
These extra calls, setup and converting from one struct format to another costs another 60 CPU cycles and in my testing makes `NtQuerySystemTime` approximately 30% faster as well with this MR. This is a fairly hot code path (especially when using certain out-of-tree in process synchronization patch sets), so probably worth the optimization here.
All of these APIs are available since 10.12.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7256
@julliard Thanks for taking the time to review.
About the file size increase, it sounds like a direct consequence of what this function is supposed to do, since it shall allocate some space for a file. Can you detail your thoughts about it?
About the tests, I guess you mean unit tests, right? Or did you mean tests on the parameters (say check that size is aligned with cluster size, or > to current size)? In the first case, I'm gonna try to add something, as digging a bit more the code showed that there is a basis.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7115#note_93641
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
--
v2: windowscodecs: Fix a typo in metadata readers registration helper.
windowscodecs/metadata: Add a stub for WICIfdMetadataWriter.
windowscodecs/metadata: Add a stub for WICExifMetadataWriter.
windowscodecs/metadata: Add a stub for WICGpsMetadataWriter.
windowscodecs/metadata: Add a stub for WICUnknownMetadataWriter.
windowscodecs/metadata: Add registration information for the "Unknown" writer.
windowscodecs: Add a stub for IWICMetadataWriterInfo.
windowscodecs: Move an hkey handle to the component info base structure.
windowscodecs: Move component info registry key cleanup to a common failure path.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7254