mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-09 20:24:14 +00:00
[host/common] windows: provide delayExecution
via nsleep
This change moves this platform specific sleep to `common` as the OS agnostic `nsleep` function. Ref PR #661
This commit is contained in:
@@ -8,6 +8,25 @@ include_directories(
|
||||
# allow use of functions for Windows 7 or later
|
||||
add_compile_definitions(WINVER=0x0601 _WIN32_WINNT=0x0601)
|
||||
|
||||
if (MINGW)
|
||||
# Build our own ntdll.dll import library
|
||||
# This tricks MinGW into not linking stuff like memcpy from ntdll.dll instead of mscvrt.dll
|
||||
if(NOT CMAKE_DLLTOOL)
|
||||
# cmake older than 3.16 doesn't know how to find dlltool
|
||||
find_program(CMAKE_DLLTOOL NAMES "x86_64-w64-mingw32-dlltool" "dlltool.exe" DOC "dlltool executable")
|
||||
endif()
|
||||
add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/ntdll.a"
|
||||
COMMAND "${CMAKE_DLLTOOL}" -d "${PROJECT_SOURCE_DIR}/ntdll.def" -l "${PROJECT_BINARY_DIR}/ntdll.a"
|
||||
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/ntdll.def"
|
||||
COMMENT "Building import library ntdll.a"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(ntdll_target DEPENDS "${PROJECT_BINARY_DIR}/ntdll.a")
|
||||
add_library(ntdll STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(ntdll ntdll_target)
|
||||
set_target_properties(ntdll PROPERTIES IMPORTED_LOCATION "${PROJECT_BINARY_DIR}/ntdll.a")
|
||||
endif()
|
||||
|
||||
add_library(lg_common_platform_code STATIC
|
||||
debug.c
|
||||
crash.c
|
||||
@@ -22,6 +41,7 @@ add_library(lg_common_platform_code STATIC
|
||||
target_link_libraries(lg_common_platform_code
|
||||
lg_common
|
||||
setupapi
|
||||
ntdll
|
||||
)
|
||||
|
||||
if (ENABLE_BACKTRACE)
|
||||
|
7
common/src/platform/windows/ntdll.def
Normal file
7
common/src/platform/windows/ntdll.def
Normal file
@@ -0,0 +1,7 @@
|
||||
; This file is used to trick MinGW to not like stuff like memcpy from ntdll.dll.
|
||||
; See CMakeLists.txt for how this is compiled.
|
||||
|
||||
LIBRARY "ntdll.dll"
|
||||
EXPORTS
|
||||
NtDelayExecution
|
||||
NtSetTimerResolution
|
@@ -71,3 +71,16 @@ void lgTimerDestroy(LGTimer * timer)
|
||||
|
||||
free(timer);
|
||||
}
|
||||
|
||||
NTSYSCALLAPI NTSTATUS NTAPI NtSetTimerResolution(
|
||||
_In_ ULONG DesiredTime,
|
||||
_In_ BOOLEAN SetResolution,
|
||||
_Out_ PULONG ActualTime
|
||||
);
|
||||
|
||||
void windowsSetTimerResolution(void)
|
||||
{
|
||||
ULONG actualResolution;
|
||||
NtSetTimerResolution(1, true, &actualResolution);
|
||||
DEBUG_INFO("System timer resolution: %.1f μs", actualResolution / 10.0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user