linux time lib improvements

stop watch other function used (more precise for linux)
This commit is contained in:
2020-05-29 02:23:14 +02:00
parent ccf79ab5b6
commit 3d2935ac69
4 changed files with 31 additions and 27 deletions

View File

@ -1,11 +1,13 @@
#include <sys/time.h>
#include <time.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/timemanager/Clock.h>
extern "C" {
#include <sys/time.h>
#include <sys/sysinfo.h>
#include <linux/sysinfo.h>
#include <time.h>
#include <unistd.h>
}
//#include <fstream>
uint16_t Clock::leapSeconds = 0;
@ -65,6 +67,15 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
return HasReturnvaluesIF::RETURN_OK;
}
timeval Clock::getUptime() {
timeval uptime;
auto result = getUptime(&uptime);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Clock::getUptime: Error getting uptime" << std::endl;
}
return uptime;
}
ReturnValue_t Clock::getUptime(timeval* uptime) {
//TODO This is not posix compatible and delivers only seconds precision
struct sysinfo sysInfo;