[RFC PATCH 1/8] cmd/cyclic: Use div64 macros for division and remainder

Stefan Roese sr at denx.de
Mon Aug 29 08:23:06 CEST 2022


Use the do_div etc for divisions to fix the compile breakage seen on
edison:

cmd/cyclic.c:70: undefined reference to `__udivmoddi4'

and for e.g. MIPS netgear_cg3100d_ram:

cmd/cyclic.c:(.text.do_cyclic_list+0x180): undefined reference to `__umoddi3'

Signed-off-by: Stefan Roese <sr at denx.de>
---
 cmd/cyclic.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/cmd/cyclic.c b/cmd/cyclic.c
index d936f3b8d099..6d14c22e4215 100644
--- a/cmd/cyclic.c
+++ b/cmd/cyclic.c
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <command.h>
 #include <cyclic.h>
+#include <div64.h>
 #include <malloc.h>
 #include <linux/delay.h>
 
@@ -67,10 +68,10 @@ static int do_cyclic_list(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	list_for_each_entry_safe(cyclic, tmp, &cyclic_list, list) {
 		cnt = cyclic->run_cnt * 1000000ULL * 100ULL;
-		freq = cnt / (timer_get_us() - cyclic->start_time_us);
-		printf("function: %s, cpu-time: %lld us, frequency: %lld.%02lld times/s\n",
+		freq = lldiv(cnt, timer_get_us() - cyclic->start_time_us);
+		printf("function: %s, cpu-time: %lld us, frequency: %lld.%02d times/s\n",
 		       cyclic->name, cyclic->cpu_time_us,
-		       freq / 100, freq % 100);
+		       lldiv(freq, 100), do_div(freq, 100));
 	}
 
 	return 0;
-- 
2.37.2



More information about the U-Boot mailing list