From b6da69bb3e38ca27b5826bb36f68fd6426f9e688 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Fri, 12 Jul 2013 18:22:25 -0700 Subject: [PATCH] Favor procs.size() over num_cores() --- riscv/sim.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/riscv/sim.cc b/riscv/sim.cc index 805429a..8df943c 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -40,13 +40,15 @@ sim_t::sim_t(int _nprocs, int mem_mb, const std::vector& args) mmu = new mmu_t(mem, memsz); - for(size_t i = 0; i < num_cores(); i++) + if (_nprocs == 0) + _nprocs = 1; + for (size_t i = 0; i < _nprocs; i++) procs[i] = new processor_t(this, new mmu_t(mem, memsz), i); } sim_t::~sim_t() { - for(size_t i = 0; i < num_cores(); i++) + for (size_t i = 0; i < procs.size(); i++) { mmu_t* pmmu = &procs[i]->mmu; delete procs[i]; @@ -58,7 +60,7 @@ sim_t::~sim_t() void sim_t::send_ipi(reg_t who) { - if(who < num_cores()) + if (who < procs.size()) procs[who]->deliver_ipi(); } -- 2.30.2