From: Andrew Waterman Date: Thu, 25 Apr 2013 23:36:25 +0000 (-0700) Subject: use inttypes macros to print uint64_t X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b363c55cfe345764e5aa5e9be2169b546837c69a;p=riscv-isa-sim.git use inttypes macros to print uint64_t --- diff --git a/riscv/interactive.cc b/riscv/interactive.cc index 98e4bb9..da8e5bd 100644 --- a/riscv/interactive.cc +++ b/riscv/interactive.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -160,7 +161,7 @@ reg_t sim_t::get_freg(const std::vector& args) void sim_t::interactive_reg(const std::string& cmd, const std::vector& 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& args) void sim_t::interactive_mem(const std::string& cmd, const std::vector& 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& args) diff --git a/riscv/processor.cc b/riscv/processor.cc index e124820..74a98a8 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -5,11 +5,12 @@ #include "config.h" #include "sim.h" #include "disasm.h" -#include +#include #include #include #include #include +#include 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)