From 9674ba888ff8c4d3b2e013b51fc18c4ca96d30e1 Mon Sep 17 00:00:00 2001 From: vthoang Date: Thu, 6 Dec 2018 23:42:36 +0000 Subject: [PATCH] Source date/time displayed values from CLOCK_REALTIME --- cgminer.c | 7 +++++-- logging.c | 2 +- util.c | 9 +++++++++ util.h | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cgminer.c b/cgminer.c index 54739e4139..c2f81f050c 100644 --- a/cgminer.c +++ b/cgminer.c @@ -5415,7 +5415,7 @@ static void set_curblock(const char *hexstr, const unsigned char *bedata) int ofs; cg_wlock(&ch_lock); - cgtime(&block_timeval); + cgtime_real(&block_timeval); strcpy(current_hash, hexstr); cg_memcpy(current_block, bedata, 32); get_timestamp(blocktime, sizeof(blocktime), &block_timeval); @@ -10718,10 +10718,13 @@ int main(int argc, char *argv[]) total_tv_start_sys=sInfo.uptime; } #endif + + cgtime_real(&total_tv_start); + get_datestamp(datestamp, sizeof(datestamp), &total_tv_start); + cgtime(&total_tv_start); cgtime(&total_tv_end); cgtime(&tv_hashmeter); - get_datestamp(datestamp, sizeof(datestamp), &total_tv_start); watchpool_thr_id = 2; thr = &control_thr[watchpool_thr_id]; diff --git a/logging.c b/logging.c index 6f401efeae..6e9164878f 100644 --- a/logging.c +++ b/logging.c @@ -64,7 +64,7 @@ void _applog(int prio, const char *str, bool force) struct timeval tv = {0, 0}; struct tm *tm; - cgtime(&tv); + cgtime_real(&tv); const time_t tmp_time = tv.tv_sec; int ms = (int)(tv.tv_usec / 1000); diff --git a/util.c b/util.c index 70f7a82fa7..8957b28e29 100644 --- a/util.c +++ b/util.c @@ -1413,6 +1413,15 @@ void cgcond_time(struct timespec *abstime) clock_gettime(CLOCK_REALTIME, abstime); } +/* Get CLOCK_REALTIME for display purposes */ +void cgtime_real(struct timeval *tv) +{ + struct timespec tp; + clock_gettime(CLOCK_REALTIME, &tp); + tv->tv_sec = tp.tv_sec; + tv->tv_usec = tp.tv_nsec / 1000; +} + #ifdef WIN32 /* Mingw32 has no strsep so create our own custom one */ diff --git a/util.h b/util.h index cb7e957cc3..71d95f41e8 100644 --- a/util.h +++ b/util.h @@ -122,6 +122,7 @@ unsigned char *ser_string(char *s, int *slen); int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg); void thr_info_cancel(struct thr_info *thr); void cgcond_time(struct timespec *abstime); +void cgtime_real(struct timeval *tv); void cgtime(struct timeval *tv); void subtime(struct timeval *a, struct timeval *b); void addtime(struct timeval *a, struct timeval *b);