Helper Functions: Added time_ms functions

This function return the current time in miliseconds
Source: https://stackoverflow.com/questions/2831841/how-to-get-the-time-in-milliseconds-in-c
This commit is contained in:
Moss 2022-09-13 01:54:44 -04:00
parent bc74baaffd
commit d5433c348b
1 changed files with 23 additions and 0 deletions

View File

@ -15,6 +15,29 @@ static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *use
return size * nmemb;
}
#if defined(__WIN32__)
#include <windows.h>
msec_t time_ms(void)
{
return timeGetTime();
}
#else
#include <sys/time.h>
long time_ms()
{
timeval tv;
gettimeofday(&tv, nullptr);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
#endif
int clear_icanon()
{
struct termios settings{};