use inttypes macros to print uint64_t
authorAndrew Waterman <waterman@cs.berkeley.edu>
Thu, 25 Apr 2013 23:36:25 +0000 (16:36 -0700)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Thu, 25 Apr 2013 23:36:25 +0000 (16:36 -0700)
riscv/interactive.cc
riscv/processor.cc

index 98e4bb92154045c375d7521f09bfd12490e84720..da8e5bdc85f9021ed708033ec0f411fef2b6725d 100644 (file)
@@ -6,6 +6,7 @@
 #include <map>
 #include <iostream>
 #include <climits>
+#include <cinttypes>
 #include <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -160,7 +161,7 @@ reg_t sim_t::get_freg(const std::vector<std::string>& args)
 
 void sim_t::interactive_reg(const std::string& cmd, const std::vector<std::string>& args)
 {
-  printf("0x%016llx\n",(unsigned long long)get_reg(args));
+  printf("0x%016" PRIx64 "\n", get_reg(args));
 }
 
 union fpr
@@ -225,7 +226,7 @@ reg_t sim_t::get_mem(const std::vector<std::string>& args)
 
 void sim_t::interactive_mem(const std::string& cmd, const std::vector<std::string>& args)
 {
-  printf("0x%016llx\n",(unsigned long long)get_mem(args));
+  printf("0x%016" PRIx64 "\n", get_mem(args));
 }
 
 void sim_t::interactive_str(const std::string& cmd, const std::vector<std::string>& args)
index e12482015b3ce436e7781f9d152df975597e6914..74a98a8661c8f8799593d1d13b4e1f9eb678890b 100644 (file)
@@ -5,11 +5,12 @@
 #include "config.h"
 #include "sim.h"
 #include "disasm.h"
-#include <inttypes.h>
+#include <cinttypes>
 #include <cmath>
 #include <cstdlib>
 #include <iostream>
 #include <assert.h>
+#include <limits.h>
 
 processor_t::processor_t(sim_t* _sim, mmu_t* _mmu, uint32_t _id)
   : sim(*_sim), mmu(*_mmu), id(_id), utidx(0)
@@ -176,11 +177,11 @@ void processor_t::take_trap(reg_t t, bool noisy)
   if(noisy)
   {
     if ((sreg_t)t < 0)
-      printf("core %3d: interrupt %lld, pc 0x%016llx\n",
-             id, (long long)(t << 1 >> 1), (unsigned long long)pc);
+      printf("core %3d: interrupt %d, epc 0x%016" PRIx64 "\n",
+             id, uint8_t(t), pc);
     else
-      printf("core %3d: trap %s, pc 0x%016llx\n",
-             id, trap_name(trap_t(t)), (unsigned long long)pc);
+      printf("core %3d: trap %s, epc 0x%016" PRIx64 "\n",
+             id, trap_name(trap_t(t)), pc);
   }
 
   // switch to supervisor, set previous supervisor bit, disable traps
@@ -201,8 +202,8 @@ void processor_t::disasm(insn_t insn, reg_t pc)
 {
   // the disassembler is stateless, so we share it
   static disassembler disasm;
-  printf("core %3d: 0x%016llx (0x%08x) %s\n", id, (unsigned long long)pc,
-         insn.bits, disasm.disassemble(insn).c_str());
+  printf("core %3d: 0x%016" PRIx64 " (0x%08" PRIx32 ") %s\n",
+         id, pc, insn.bits, disasm.disassemble(insn).c_str());
 }
 
 void processor_t::set_pcr(int which, reg_t val)