mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-04 04:04:17 +01:00
Uptime: reads (System|Interrupt)Time directly from SharedUserData
This commit is contained in:
+3
-12
@@ -4,17 +4,9 @@
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#ifdef _WIN32
|
||||
#include <ntdef.h>
|
||||
#include <ntstatus.h>
|
||||
#include "common/windows/nt.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
|
||||
@@ -40,8 +32,7 @@ static inline double ffTimeGetTick(void) //In msec
|
||||
static inline uint64_t ffTimeGetNow(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
uint64_t timeNow;
|
||||
GetSystemTimeAsFileTime((FILETIME*) &timeNow);
|
||||
uint64_t timeNow = ffKSystemTimeToUInt64(&SharedUserData->SystemTime);
|
||||
return (timeNow - 116444736000000000ull) / 10000ull;
|
||||
#elif defined(__HAIKU__)
|
||||
return (uint64_t) real_time_clock_usecs() / 1000u;
|
||||
@@ -58,7 +49,7 @@ static inline bool ffTimeSleep(uint32_t msec)
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER interval;
|
||||
interval.QuadPart = -(int64_t) msec * 10000; // Relative time in 100-nanosecond intervals
|
||||
return NtDelayExecution(TRUE, &interval) == STATUS_SUCCESS;
|
||||
return NT_SUCCESS(NtDelayExecution(TRUE, &interval));
|
||||
#else
|
||||
return nanosleep(&(struct timespec){ msec / 1000, (long) (msec % 1000) * 1000000 }, NULL) == 0;
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <winternl.h>
|
||||
#include <winnt.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
enum {
|
||||
SystemModuleInformation = 11,
|
||||
@@ -423,6 +425,8 @@ typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION
|
||||
_Field_size_bytes_(TableBufferLength) UCHAR TableBuffer[];
|
||||
} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION;
|
||||
|
||||
NTSTATUS NTAPI NtDelayExecution(_In_ BOOLEAN Alertable, _In_ PLARGE_INTEGER DelayInterval);
|
||||
|
||||
/**
|
||||
* The KSYSTEM_TIME structure represents interrupt time, system time, and time zone bias.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user