Commit graph

6760 commits

Author SHA1 Message Date
Alexandre Julliard 501ac4d496 ntdll: Match a timezone change happening at 23:59:59 with the following day.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53595
2022-12-19 22:25:15 +01:00
Huw Davies c28258039b ntdll: Only compile get_current_teb() on linux. 2022-12-19 11:10:43 +01:00
Eric Pouech 84cf6aa20d ntdll: Implement RtlU(short|long)ByteSwap() using fastcall bits.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-12-16 18:48:30 +01:00
Eric Pouech 4708bb7453 ntdll/tests: Add tests for RtlU(long|short)ByteSwap().
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-12-16 18:48:30 +01:00
Eric Pouech 495711c251 ntdll: Fix export and calling convention of RtlUlonglongByteSwap().
The RtlU*ByteSwap() family:
- has FASTCALL calling convention
- is only exported from ntdll and ntoskrnl.exe in 32bit mode
  (didn't check ARM though)

Wine's support for RtlUlonglongByteSwap() doesn't follow these constraints.
Note: in __fastcall, 64bit paramaters are passed on the stack, to
RtlUlonglongByteSwap() calling convention acts as __stdcall.

So:
- fix ntdll.spec (resp. ntoskrnl.exe.spec) to only export
  (resp. forward) RtlUlonglongByteSwap for i386
- always provide an inline implementation in winternl.h
- reimplement ntdll.RtlUlonglongByteSwap() for i386 with
  __fastcall calling convention.
- fix ntdll/tests/rtl.c to use correct calling convention.
- add test in ntdll/tests/rtl.c for inlined version.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53536
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-12-16 18:48:30 +01:00
Torge Matthies 1480d0f376 ntdll: Make sure xmm6-xmm15 are always restored in unix call dispatcher.
Signed-off-by: Torge Matthies <tmatthies@codeweavers.com>
2022-12-12 23:12:42 +01:00
Alexandre Julliard 4619a45f62 ntdll: Consistently use %I printf format for ULONG_PTR values. 2022-12-09 17:52:25 +01:00
Alexandre Julliard 1909f1565e ntdll: Fix printf format warnings on ARM platforms. 2022-12-08 18:11:23 +01:00
Zhiyi Zhang fc3b2ebaf4 Revert "ntdll: Call usleep() instead of NtYieldExecution() in NtDelayExecution().".
Manual tests on Windows 10 show that calling Sleep(0) or NtDelayExecution() with zero timeout in a
loop do consume 100% of a CPU core, which is closer to the behavior of NtYieldExecution() than
usleep(0). usleep(0) gives up the remaining timeslices even if there are no other threads to switch
to, causing low utilization of CPU and performance issues.

The original patch is b1a79c6 and the idea is to use usleep(0) to avoid a thread taking 100% of a
CPU core for StarCraft 2 and Shadow of the Tomb Raider. However with wine-7.22, reverting the
usleep(0) patch causes no behavior changes. For Shadow of the Tomb Raider, the 100% CPU issue is
gone with or without the patch. For StarCraft 2, there is always a thread taking 100% CPU even with
the patch. After discussing with Matteo, we decided it's better to revert the patch.

Fix Mortal Kombat X performance drop during tower selection and Ragnarok Online bad performance.

This reverts commit e86b4015ff.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53327
2022-12-07 17:10:30 +01:00
Alexandre Julliard 0538557512 ntdll: Initialize Unix calls early during startup. 2022-12-04 22:01:38 +01:00
Alexandre Julliard bef0969722 ntdll: Move the .so module initialization to winecrt0.
Use new ELF tag ids to avoid breaking backwards compatibility.
2022-12-04 22:00:43 +01:00
Alexandre Julliard 0aae4b0563 ntdll: Use ret instead of jmp to return from syscall dispatchers. 2022-12-03 00:05:16 +01:00
Alexandre Julliard 3242676e2e ntdll: Only build the wow64 function table on 64-bit. 2022-12-02 11:57:16 +01:00
Brendan Shanks 9645beb5c0 configure: Remove check for IOKit (always present on macOS). 2022-12-02 11:04:46 +01:00
Zebediah Figura e2c081a8eb ntdll: Trace the name of critical sections which are released while not acquired. 2022-12-02 11:04:45 +01:00
Rémi Bernon c2bff6b65f ntdll: Keep subheap parent heap pointer and check for mismatches. 2022-12-02 11:04:45 +01:00
Rémi Bernon 4502c1daa9 ntdll: Move the insertion of the first block out of create_subheap. 2022-12-02 11:04:45 +01:00
Rémi Bernon 2e8b19ec27 ntdll: Split create_free_block into block_init_free / insert_free_block. 2022-12-02 11:04:45 +01:00
Rémi Bernon 911e1f378c ntdll: Merge prev and next free heap blocks in heap_free_block.
As create_free_block is only called in other places where it is not
possible to have a free block either before or after.
2022-12-02 11:04:45 +01:00
Rémi Bernon bece622b8e ntdll: Split heap blocks before creating or resizing used block. 2022-12-02 11:04:45 +01:00
Rémi Bernon a540b4b246 ntdll: Clear BLOCK_FLAG_PREV_FREE flag out of shrink_used_block. 2022-12-02 11:04:45 +01:00
Rémi Bernon 99388f74c7 ntdll: Move heap allocation and initialization into RtlCreateHeap.
And rename HEAP_CreateSubHeap to create_subheap.
2022-12-02 11:04:45 +01:00
Rémi Bernon dd037455ca ntdll: Split heap region memory allocation to allocate_region helper. 2022-12-02 11:04:45 +01:00
Alexandre Julliard ee147d9216 ntdll: Replace the __wine_unix_call() syscall by a function calling through the dispatcher. 2022-12-01 20:36:04 +01:00
Alexandre Julliard a6bb3662dc ntdll: Implement a faster Unix call dispatcher on ARM. 2022-12-01 20:36:04 +01:00
Alexandre Julliard 2332fe7935 ntdll: Implement a faster Unix call dispatcher on ARM64. 2022-12-01 20:36:04 +01:00
Alexandre Julliard 5277c75406 ntdll: Implement a faster Unix call dispatcher on x86_64.
Inspired by a patch from Rémi Bernon.
2022-12-01 20:36:02 +01:00
Alexandre Julliard 911789e757 ntdll: Implement a faster Unix call dispatcher on i386.
Inspired by a patch from Rémi Bernon.
2022-12-01 20:35:47 +01:00
Alexandre Julliard 90adeb125f ntdll: Export the Unix call dispatcher function pointer. 2022-12-01 11:38:23 +01:00
Rémi Bernon a51e2a3f94 ntdll: Move delayed free support out of heap_free. 2022-11-30 20:38:27 +01:00
Rémi Bernon cbe3fb89d2 ntdll: Move large block free out of heap_free. 2022-11-30 20:38:27 +01:00
Rémi Bernon 523d4cc416 ntdll: Move large block alloc out of heap_allocate. 2022-11-30 20:38:27 +01:00
Rémi Bernon a7fda2f8cb ntdll: Make realloc implementation more generic.
Either resizing a block in place, or reallocating through RtlHeap calls.
2022-11-30 20:38:27 +01:00
Rémi Bernon ce450253bd ntdll: Return the old data size from heap_reallocate. 2022-11-30 20:38:27 +01:00
Rémi Bernon 4334c5b0c1 ntdll: Move large block resize in heap_reallocate. 2022-11-30 20:38:27 +01:00
Rémi Bernon 0c5f9e8d4e ntdll: Merge next free block before resizing in heap_reallocate. 2022-11-30 20:38:27 +01:00
Alexandre Julliard d406de1828 ntdll: Also fixup the delay import directory when mapping a .so dll. 2022-11-29 19:11:19 +01:00
Huw Davies 905821fc69 ntdll: Fix -Wformat warnings on macOS. 2022-11-29 13:15:34 +01:00
Jacek Caban ac5e7fab1f ntdll: Detect ntdll module also by module path comparison. 2022-11-28 21:06:47 +01:00
Rémi Bernon 871d2b9443 ntdll: Reallocate a new block if we failed to commit. 2022-11-28 21:02:40 +01:00
Rémi Bernon d0b46b2a18 ntdll: Inverse the control flow in heap_reallocate. 2022-11-28 21:02:40 +01:00
Rémi Bernon efc6a8f42c ntdll: Stop locking heap to access block-local data.
This moves unsafe_block_from_ptr calls outside of the heap lock.

We assume here that concurrent call to another heap function on a block
being freed is undefined, and it should then be safe to do so:

* The block type or base offset never change after a block has been
  allocated and until it is freed.

* Block flags such as BLOCK_FLAG_LARGE, or BLOCK_FLAG_USER_INFO also
  never change after a block has been allocated.

* Other block flags are only read and modified inside the heap lock.
2022-11-28 21:02:37 +01:00
Rémi Bernon 708462f6aa ntdll: Avoid clearing BLOCK_FLAG_USER_INFO in heap_reallocate. 2022-11-28 21:02:37 +01:00
Rémi Bernon 2f6b763fa9 ntdll: Find heap block region from its base offset. 2022-11-28 21:02:37 +01:00
Rémi Bernon fd8e52b4e7 ntdll: Keep the region base offset in the block header. 2022-11-28 21:02:37 +01:00
Jacek Caban 68eee4053c ntdll: Call init_handler in usr1_handler.
It's needed before is_inside_syscall accesses TEB.
2022-11-28 21:01:55 +01:00
Jacek Caban e7accd7c0f ntdll: Get TEB from signal stack pointer in init_handler.
We can't use NtCurrentTeb before setting %fs base.
2022-11-28 21:01:55 +01:00
Rémi Bernon 63b6ec5af3 ntdll: Pass a heap block pointer to initialize_block. 2022-11-24 22:20:20 +01:00
Rémi Bernon 1526ac755f ntdll: Compute block size before calling heap_(re)allocate. 2022-11-24 22:20:20 +01:00
Rémi Bernon e7827fc853 ntdll: Compute effective flags in unsafe_heap_from_handle. 2022-11-24 22:20:20 +01:00