1*26bdd445SBrad BishopFrom 20e2c61fc04a291250acee649c2523d2546cedea Mon Sep 17 00:00:00 2001 21a4b7ee2SBrad BishopFrom: Andrea Adami <andrea.adami@gmail.com> 31a4b7ee2SBrad BishopDate: Tue, 17 Apr 2018 13:14:12 +0200 41a4b7ee2SBrad BishopSubject: [PATCH] vmcore-dmesg.c: work around missing imaxdiv() 51a4b7ee2SBrad Bishop 61a4b7ee2SBrad BishopConvert to integer arithmetic for klibc. 71a4b7ee2SBrad Bishop 81a4b7ee2SBrad BishopFix 91a4b7ee2SBrad Bishop 101a4b7ee2SBrad Bishop vmcore-dmesg.c: In function 'dump_dmesg_structured': 111a4b7ee2SBrad Bishop vmcore-dmesg.c:578:2: error: unknown type name 'imaxdiv_t' 121a4b7ee2SBrad Bishop 131a4b7ee2SBrad BishopUpstream-Status: Inappropriate [klibc specific] 141a4b7ee2SBrad BishopSigned-off-by: Andrea Adami <andrea.adami@gmail.com> 151a4b7ee2SBrad Bishop 161a4b7ee2SBrad Bishop--- 171a4b7ee2SBrad Bishop vmcore-dmesg/vmcore-dmesg.c | 13 ++++++++++++- 181a4b7ee2SBrad Bishop 1 file changed, 12 insertions(+), 1 deletion(-) 191a4b7ee2SBrad Bishop 201a4b7ee2SBrad Bishopdiff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c 21*26bdd445SBrad Bishopindex 7972788..c63ac4f 100644 221a4b7ee2SBrad Bishop--- a/vmcore-dmesg/vmcore-dmesg.c 231a4b7ee2SBrad Bishop+++ b/vmcore-dmesg/vmcore-dmesg.c 241a4b7ee2SBrad Bishop@@ -575,8 +575,11 @@ static void dump_dmesg_structured(int fd) 251a4b7ee2SBrad Bishop ssize_t ret; 261a4b7ee2SBrad Bishop char *msg; 271a4b7ee2SBrad Bishop uint16_t text_len; 281a4b7ee2SBrad Bishop+#ifndef __KLIBC__ 291a4b7ee2SBrad Bishop imaxdiv_t imaxdiv_sec, imaxdiv_usec; 301a4b7ee2SBrad Bishop- 311a4b7ee2SBrad Bishop+#else 321a4b7ee2SBrad Bishop+ int64_t imaxdiv_sec, imaxdiv_usec; 331a4b7ee2SBrad Bishop+#endif 341a4b7ee2SBrad Bishop if (!log_buf_vaddr) { 351a4b7ee2SBrad Bishop fprintf(stderr, "Missing the log_buf symbol\n"); 361a4b7ee2SBrad Bishop exit(60); 371a4b7ee2SBrad Bishop@@ -645,12 +648,20 @@ static void dump_dmesg_structured(int fd) 381a4b7ee2SBrad Bishop exit(65); 391a4b7ee2SBrad Bishop } 401a4b7ee2SBrad Bishop ts_nsec = struct_val_u64(buf, log_offset_ts_nsec); 411a4b7ee2SBrad Bishop+#ifndef __KLIBC__ 421a4b7ee2SBrad Bishop imaxdiv_sec = imaxdiv(ts_nsec, 1000000000); 431a4b7ee2SBrad Bishop imaxdiv_usec = imaxdiv(imaxdiv_sec.rem, 1000); 441a4b7ee2SBrad Bishop 451a4b7ee2SBrad Bishop len += sprintf(out_buf + len, "[%5llu.%06llu] ", 461a4b7ee2SBrad Bishop (long long unsigned int)imaxdiv_sec.quot, 471a4b7ee2SBrad Bishop (long long unsigned int)imaxdiv_usec.quot); 481a4b7ee2SBrad Bishop+#else 491a4b7ee2SBrad Bishop+ imaxdiv_sec = ts_nsec / 1000000000; 501a4b7ee2SBrad Bishop+ imaxdiv_usec = (ts_nsec % 1000000000) / 1000; 511a4b7ee2SBrad Bishop+ len += sprintf(out_buf + len, "[%5llu.%06llu] ", 521a4b7ee2SBrad Bishop+ (long long unsigned int)imaxdiv_sec, 531a4b7ee2SBrad Bishop+ (long long unsigned int)imaxdiv_usec); 541a4b7ee2SBrad Bishop+#endif 551a4b7ee2SBrad Bishop 561a4b7ee2SBrad Bishop /* escape non-printable characters */ 571a4b7ee2SBrad Bishop text_len = struct_val_u16(buf, log_offset_text_len); 58