mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:14:37 +02:00
39 lines
893 B
C
39 lines
893 B
C
#pragma once
|
|
|
|
#ifndef FF_INCLUDED_common_time
|
|
#define FF_INCLUDED_common_time
|
|
|
|
#include <stdint.h>
|
|
#ifdef _WIN32
|
|
#include <synchapi.h>
|
|
#include <profileapi.h>
|
|
#else
|
|
#include <time.h>
|
|
#endif
|
|
|
|
static inline uint64_t ffTimeGetTick() //In msec
|
|
{
|
|
#ifdef _WIN32
|
|
LARGE_INTEGER frequency;
|
|
QueryPerformanceFrequency(&frequency);
|
|
LARGE_INTEGER start;
|
|
QueryPerformanceCounter(&start);
|
|
return (uint64_t)(start.QuadPart * 1000 / frequency.QuadPart);
|
|
#else
|
|
struct timespec timeNow;
|
|
clock_gettime(CLOCK_MONOTONIC, &timeNow);
|
|
return (uint64_t)((timeNow.tv_sec * 1000) + (timeNow.tv_nsec / 1000000));
|
|
#endif
|
|
}
|
|
|
|
static inline void ffTimeSleep(uint32_t msec)
|
|
{
|
|
#ifdef _WIN32
|
|
SleepEx(msec, TRUE);
|
|
#else
|
|
nanosleep(&(struct timespec){ msec / 1000, (msec % 1000) * 1000000 }, NULL);
|
|
#endif
|
|
}
|
|
|
|
#endif
|