mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-04 11:42:28 +00:00
Improve Windows sleep accuracy from 15ms to 15µs
This commit is contained in:
parent
b40140e6c5
commit
b490e23d63
16 changed files with 189 additions and 67 deletions
|
@ -751,6 +751,7 @@ imp 'NtQuerySecurityObject' NtQuerySecurityObject ntdll 5
|
|||
imp 'NtQuerySymbolicLinkObject' NtQuerySymbolicLinkObject ntdll 3
|
||||
imp 'NtQuerySystemInformation' NtQuerySystemInformation ntdll 4
|
||||
imp 'NtQuerySystemTime' NtQuerySystemTime ntdll 1
|
||||
imp 'NtQueryTimerResolution' NtQueryTimerResolution ntdll 3
|
||||
imp 'NtQueryValueKey' NtQueryValueKey ntdll 6
|
||||
imp 'NtQueryVirtualMemory' NtQueryVirtualMemory ntdll 6
|
||||
imp 'NtQueryVolumeInformationFile' NtQueryVolumeInformationFile ntdll 5
|
||||
|
@ -767,6 +768,7 @@ imp 'NtSetInformationFile' NtSetInformationFile ntdll 5
|
|||
imp 'NtSetInformationThread' NtSetInformationThread ntdll 4
|
||||
imp 'NtSetIntervalProfile' NtSetIntervalProfile ntdll 2
|
||||
imp 'NtSetTimer' NtSetTimer ntdll 7
|
||||
imp 'NtSetTimerResolution' NtSetTimerResolution ntdll 3
|
||||
imp 'NtSetValueKey' NtSetValueKey ntdll 6
|
||||
imp 'NtSignalAndWaitForSingleObject' NtSignalAndWaitForSingleObject ntdll 4
|
||||
imp 'NtStartProfile' NtStartProfile ntdll 1
|
||||
|
|
|
@ -224,6 +224,16 @@ NtStatus RtlUnlockHeap(int64_t heap);
|
|||
NtStatus RtlGetProcessHeaps(uint32_t count, void **out_Heaps);
|
||||
NtStatus RtlWalkHeap(int64_t heap, void *out_Info);
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § new technology » beyond the pale » i am the time lorde ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
NtStatus NtSetTimerResolution(uint32_t DesiredResolution, bool32 SetResolution,
|
||||
uint32_t *out_CurrentResolution);
|
||||
NtStatus NtQueryTimerResolution(uint32_t *out_MinimumResolution,
|
||||
uint32_t *out_MaximumResolution,
|
||||
uint32_t *out_CurrentResolution);
|
||||
|
||||
#if ShouldUseMsabiAttribute()
|
||||
#include "libc/nt/thunk/ntdll.inc"
|
||||
#endif /* ShouldUseMsabiAttribute() */
|
||||
|
|
18
libc/nt/ntdll/NtQueryTimerResolution.S
Normal file
18
libc/nt/ntdll/NtQueryTimerResolution.S
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "libc/nt/ntdllimport.h"
|
||||
.ntimp NtQueryTimerResolution,NtQueryTimerResolution
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
NtQueryTimerResolution:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov __imp_NtQueryTimerResolution(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
ret
|
||||
#endif
|
||||
.endfn NtQueryTimerResolution,globl
|
||||
.previous
|
18
libc/nt/ntdll/NtSetTimerResolution.S
Normal file
18
libc/nt/ntdll/NtSetTimerResolution.S
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "libc/nt/ntdllimport.h"
|
||||
.ntimp NtSetTimerResolution,NtSetTimerResolution
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
NtSetTimerResolution:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov __imp_NtSetTimerResolution(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
ret
|
||||
#endif
|
||||
.endfn NtSetTimerResolution,globl
|
||||
.previous
|
Loading…
Add table
Add a link
Reference in a new issue