Common: updates ffTimeSleep to return true on success

This commit is contained in:
李通洲
2026-01-12 15:10:16 +08:00
parent 2f1e37bb7c
commit 1c066bc69a
2 changed files with 27 additions and 15 deletions
+16 -4
View File
@@ -1,11 +1,20 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#ifdef _WIN32
#include <synchapi.h>
#include <ntdef.h>
#include <ntstatus.h>
#include <profileapi.h>
#include <sysinfoapi.h>
NTSYSCALLAPI
NTSTATUS
NTAPI
NtDelayExecution(
_In_ BOOLEAN Alertable,
_In_ PLARGE_INTEGER DelayInterval);
#elif defined(__HAIKU__)
#include <OS.h>
#endif
@@ -49,12 +58,15 @@ static inline uint64_t ffTimeGetNow(void)
#endif
}
static inline void ffTimeSleep(uint32_t msec)
// Returns true if not interrupted
static inline bool ffTimeSleep(uint32_t msec)
{
#ifdef _WIN32
SleepEx(msec, TRUE);
LARGE_INTEGER interval;
interval.QuadPart = -(int64_t) msec * 10000; // Relative time in 100-nanosecond intervals
return NtDelayExecution(TRUE, &interval) == STATUS_SUCCESS;
#else
nanosleep(&(struct timespec){ msec / 1000, (long) (msec % 1000) * 1000000 }, NULL);
return nanosleep(&(struct timespec){ msec / 1000, (long) (msec % 1000) * 1000000 }, NULL) == 0;
#endif
}
+11 -11
View File
@@ -237,14 +237,14 @@ NTSYSCALLAPI
NTSTATUS
NTAPI
NtQueryDirectoryFile(
IN HANDLE FileHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass,
IN BOOLEAN ReturnSingleEntry,
IN PUNICODE_STRING FileName OPTIONAL,
IN BOOLEAN RestartScan);
IN HANDLE FileHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass,
IN BOOLEAN ReturnSingleEntry,
IN PUNICODE_STRING FileName OPTIONAL,
IN BOOLEAN RestartScan);