From 20e2c61fc04a291250acee649c2523d2546cedea Mon Sep 17 00:00:00 2001
|
From: Andrea Adami <andrea.adami@gmail.com>
|
Date: Tue, 17 Apr 2018 13:14:12 +0200
|
Subject: [PATCH] vmcore-dmesg.c: work around missing imaxdiv()
|
|
Convert to integer arithmetic for klibc.
|
|
Fix
|
|
vmcore-dmesg.c: In function 'dump_dmesg_structured':
|
vmcore-dmesg.c:578:2: error: unknown type name 'imaxdiv_t'
|
|
Upstream-Status: Inappropriate [klibc specific]
|
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
|
|
---
|
vmcore-dmesg/vmcore-dmesg.c | 13 ++++++++++++-
|
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
|
index 7972788..c63ac4f 100644
|
--- a/vmcore-dmesg/vmcore-dmesg.c
|
+++ b/vmcore-dmesg/vmcore-dmesg.c
|
@@ -575,8 +575,11 @@ static void dump_dmesg_structured(int fd)
|
ssize_t ret;
|
char *msg;
|
uint16_t text_len;
|
+#ifndef __KLIBC__
|
imaxdiv_t imaxdiv_sec, imaxdiv_usec;
|
-
|
+#else
|
+ int64_t imaxdiv_sec, imaxdiv_usec;
|
+#endif
|
if (!log_buf_vaddr) {
|
fprintf(stderr, "Missing the log_buf symbol\n");
|
exit(60);
|
@@ -645,12 +648,20 @@ static void dump_dmesg_structured(int fd)
|
exit(65);
|
}
|
ts_nsec = struct_val_u64(buf, log_offset_ts_nsec);
|
+#ifndef __KLIBC__
|
imaxdiv_sec = imaxdiv(ts_nsec, 1000000000);
|
imaxdiv_usec = imaxdiv(imaxdiv_sec.rem, 1000);
|
|
len += sprintf(out_buf + len, "[%5llu.%06llu] ",
|
(long long unsigned int)imaxdiv_sec.quot,
|
(long long unsigned int)imaxdiv_usec.quot);
|
+#else
|
+ imaxdiv_sec = ts_nsec / 1000000000;
|
+ imaxdiv_usec = (ts_nsec % 1000000000) / 1000;
|
+ len += sprintf(out_buf + len, "[%5llu.%06llu] ",
|
+ (long long unsigned int)imaxdiv_sec,
|
+ (long long unsigned int)imaxdiv_usec);
|
+#endif
|
|
/* escape non-printable characters */
|
text_len = struct_val_u16(buf, log_offset_text_len);
|