diff options
author | Thadeu Lima de Souza Cascardo <cascardo@debian.org> | 2018-12-17 14:33:33 -0200 |
---|---|---|
committer | Thadeu Lima de Souza Cascardo <cascardo@debian.org> | 2018-12-17 14:33:33 -0200 |
commit | 13f9280ff590b138cd97b922e4f7b632ae31ae32 (patch) | |
tree | a716d92cfc67cc85772d50755b250e1bc4689c46 /print_info.c | |
parent | a9f6c6d8f2a6564f59787a92b5c38399ccae9e18 (diff) |
New upstream version 1.6.5
Diffstat (limited to 'print_info.c')
-rw-r--r-- | print_info.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/print_info.c b/print_info.c index 6bfcd11..0be12ea 100644 --- a/print_info.c +++ b/print_info.c @@ -19,6 +19,8 @@ #define PROGRESS_MAXLEN "50" +#define NSEC_PER_SEC 1000000000L + int message_level; int flag_strerr_message; int flag_ignore_r_char; /* 0: '\r' is effective. 1: not effective. */ @@ -298,7 +300,7 @@ print_usage(void) MSG(" necessary to specify [-x VMLINUX] or [-i VMCOREINFO].\n"); MSG("\n"); MSG(" [--mem-usage]:\n"); - MSG(" This option is only for x86_64.\n"); + MSG(" This option is currently supported on x86_64, arm64, ppc64 and s390x.\n"); MSG(" This option is used to show the page numbers of current system in different\n"); MSG(" use. It should be executed in 1st kernel. By the help of this, user can know\n"); MSG(" how many pages is dumpable when different dump_level is specified. It analyzes\n"); @@ -338,16 +340,16 @@ print_usage(void) MSG("\n"); } -static void calc_delta(struct timeval *tv_start, struct timeval *delta) +static void calc_delta(struct timespec *ts_start, struct timespec *delta) { - struct timeval tv_end; + struct timespec ts_end; - gettimeofday(&tv_end, NULL); - delta->tv_sec = tv_end.tv_sec - tv_start->tv_sec; - delta->tv_usec = tv_end.tv_usec - tv_start->tv_usec; - if (delta->tv_usec < 0) { + clock_gettime(CLOCK_MONOTONIC, &ts_end); + delta->tv_sec = ts_end.tv_sec - ts_start->tv_sec; + delta->tv_nsec = ts_end.tv_nsec - ts_start->tv_nsec; + if (delta->tv_nsec < 0) { delta->tv_sec--; - delta->tv_usec += 1000000; + delta->tv_nsec += NSEC_PER_SEC; } } @@ -371,14 +373,14 @@ static int eta_to_human_short (unsigned long secs, char* msg) void -print_progress(const char *msg, unsigned long current, unsigned long end, struct timeval *start) +print_progress(const char *msg, unsigned long current, unsigned long end, struct timespec *start) { unsigned progress; /* in promilles (tenths of a percent) */ time_t tm; static time_t last_time = 0; static unsigned int lapse = 0; static const char *spinner = "/|\\-"; - struct timeval delta; + struct timespec delta; unsigned long eta; char eta_msg[16] = " "; @@ -393,7 +395,7 @@ print_progress(const char *msg, unsigned long current, unsigned long end, struct if (start != NULL && progress != 0) { calc_delta(start, &delta); - eta = 1000 * delta.tv_sec + delta.tv_usec / 1000; + eta = 1000 * delta.tv_sec + delta.tv_nsec / (NSEC_PER_SEC / 1000); eta = eta / progress - delta.tv_sec; eta_to_human_short(eta, eta_msg); } @@ -411,12 +413,12 @@ print_progress(const char *msg, unsigned long current, unsigned long end, struct } void -print_execution_time(char *step_name, struct timeval *tv_start) +print_execution_time(char *step_name, struct timespec *ts_start) { - struct timeval delta; + struct timespec delta; - calc_delta(tv_start, &delta); + calc_delta(ts_start, &delta); REPORT_MSG("STEP [%s] : %ld.%06ld seconds\n", - step_name, delta.tv_sec, delta.tv_usec); + step_name, delta.tv_sec, delta.tv_nsec / 1000); } |