blob: 8bc473cb00110233e9f79fa233ec95b8077b9a68 [file] [log] [blame]
Brad Bishop26bdd442019-08-16 17:08:17 -04001From 20e2c61fc04a291250acee649c2523d2546cedea Mon Sep 17 00:00:00 2001
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002From: Andrea Adami <andrea.adami@gmail.com>
3Date: Tue, 17 Apr 2018 13:14:12 +0200
4Subject: [PATCH] vmcore-dmesg.c: work around missing imaxdiv()
5
6Convert to integer arithmetic for klibc.
7
8Fix
9
10 vmcore-dmesg.c: In function 'dump_dmesg_structured':
11 vmcore-dmesg.c:578:2: error: unknown type name 'imaxdiv_t'
12
13Upstream-Status: Inappropriate [klibc specific]
14Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
15
16---
17 vmcore-dmesg/vmcore-dmesg.c | 13 ++++++++++++-
18 1 file changed, 12 insertions(+), 1 deletion(-)
19
20diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
Brad Bishop26bdd442019-08-16 17:08:17 -040021index 7972788..c63ac4f 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022--- a/vmcore-dmesg/vmcore-dmesg.c
23+++ b/vmcore-dmesg/vmcore-dmesg.c
24@@ -575,8 +575,11 @@ static void dump_dmesg_structured(int fd)
25 ssize_t ret;
26 char *msg;
27 uint16_t text_len;
28+#ifndef __KLIBC__
29 imaxdiv_t imaxdiv_sec, imaxdiv_usec;
30-
31+#else
32+ int64_t imaxdiv_sec, imaxdiv_usec;
33+#endif
34 if (!log_buf_vaddr) {
35 fprintf(stderr, "Missing the log_buf symbol\n");
36 exit(60);
37@@ -645,12 +648,20 @@ static void dump_dmesg_structured(int fd)
38 exit(65);
39 }
40 ts_nsec = struct_val_u64(buf, log_offset_ts_nsec);
41+#ifndef __KLIBC__
42 imaxdiv_sec = imaxdiv(ts_nsec, 1000000000);
43 imaxdiv_usec = imaxdiv(imaxdiv_sec.rem, 1000);
44
45 len += sprintf(out_buf + len, "[%5llu.%06llu] ",
46 (long long unsigned int)imaxdiv_sec.quot,
47 (long long unsigned int)imaxdiv_usec.quot);
48+#else
49+ imaxdiv_sec = ts_nsec / 1000000000;
50+ imaxdiv_usec = (ts_nsec % 1000000000) / 1000;
51+ len += sprintf(out_buf + len, "[%5llu.%06llu] ",
52+ (long long unsigned int)imaxdiv_sec,
53+ (long long unsigned int)imaxdiv_usec);
54+#endif
55
56 /* escape non-printable characters */
57 text_len = struct_val_u16(buf, log_offset_text_len);