cOMS/platform/linux/TimeUtils.h
Dennis Eichhorn dc9f37b726
Some checks failed
CodeQL / Analyze (${{ matrix.language }}) (autobuild, c-cpp) (push) Has been cancelled
Microsoft C++ Code Analysis / Analyze (push) Has been cancelled
update
2025-04-06 10:34:47 +00:00

39 lines
870 B
C
Executable File

/**
* Jingga
*
* @copyright Jingga
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
#ifndef COMS_PLATFORM_LINUX_TIME_UTILS_H
#define COMS_PLATFORM_LINUX_TIME_UTILS_H
#include <time.h>
#include <sys/time.h>
#include "../../stdlib/Types.h"
uint64 system_time() {
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
return (uint64_t) ts.tv_sec * 1000000ULL + (uint64_t) ts.tv_nsec / 1000ULL;
}
// Used as initializer for 64bit random number generators instead of time()
inline
uint64 time_index() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint64) ts.tv_sec * 1000000ULL + (uint64) (ts.tv_nsec / 1000);
}
uint64 time_mu() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint64) ts.tv_sec * 1000000ULL + (uint64) (ts.tv_nsec / 1000);
}
#endif