]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/m68hc11/dv-m68hc11tim.c
sim: m68hc11: fix up cycle buffer printing
[thirdparty/binutils-gdb.git] / sim / m68hc11 / dv-m68hc11tim.c
index 41915ed8159c223680db798faa52231ad85fe66b..d7bcac3fecadeaabdf2804ae1b0e617bb3af42f2 100644 (file)
@@ -1,5 +1,5 @@
 /*  dv-m68hc11tim.c -- Simulation of the 68HC11 timer devices.
-    Copyright (C) 1999-2013 Free Software Foundation, Inc.
+    Copyright (C) 1999-2021 Free Software Foundation, Inc.
     Written by Stephane Carrez (stcarrez@nerim.fr)
     (From a driver model Contributed by Cygnus Solutions.)
 
@@ -236,7 +236,7 @@ enum event_type
   COMPARE_EVENT
 };
 
-void
+static void
 m68hc11tim_timer_event (struct hw *me, void *data)
 {
   SIM_DESC sd;
@@ -479,7 +479,8 @@ cycle_to_string (sim_cpu *cpu, signed64 t, int flags)
 {
   char time_buf[32];
   char cycle_buf[32];
-  static char buf[64];
+  /* Big enough to handle 64-bit t, time_buf, and cycle_buf.  */
+  static char buf[128];
 
   time_buf[0] = 0;
   cycle_buf[0] = 0;
@@ -500,10 +501,7 @@ cycle_to_string (sim_cpu *cpu, signed64 t, int flags)
     sprintf (cycle_buf, " cycle%s",
              (t > 1 ? "s" : ""));
 
-  if (t < LONG_MAX)
-    sprintf (buf, "%9lu%s%s", (unsigned long) t, cycle_buf, time_buf);
-  else
-    sprintf (buf, "%llu%s%s", t, cycle_buf, time_buf);
+  sprintf (buf, "%9" PRIi64 "%s%s", t, cycle_buf, time_buf);
   return buf;
 }
 
@@ -521,7 +519,7 @@ m68hc11tim_print_timer (struct hw *me, const char *name,
   else
     {
       signed64 t;
-      sim_cpucpu;
+      sim_cpu *cpu;
 
       cpu = STATE_CPU (sd, 0);