From 90c381334033f2ac376affda81adf6088cc7e03a Mon Sep 17 00:00:00 2001 From: Blaise Tine Date: Mon, 17 Feb 2020 15:02:06 -0500 Subject: [PATCH] fixed all C++ extra + pedantic errors --- emulator/enc.cpp | 4 ++-- emulator/include/mem.h | 2 +- emulator/include/obj.h | 4 ++-- emulator/instruction.cpp | 12 ++++++------ emulator/mem.cpp | 6 +++--- emulator/qsim-harp.cpp | 2 +- simX/Makefile | 8 ++++++-- simX/core.cpp | 37 +++++++++++++++++++++++++++++++------ simX/enc.cpp | 22 +++++++++++----------- simX/include/archdef.h | 2 +- simX/include/args.h | 2 +- simX/include/asm-tokens.h | 2 +- simX/include/core.h | 19 ++++++++++--------- simX/include/enc.h | 7 +++++-- simX/include/harpfloat.h | 4 ++-- simX/include/help.h | 4 ++-- simX/include/instruction.h | 2 +- simX/include/mem.h | 27 ++++++++++++++------------- simX/include/obj.h | 6 +++--- simX/include/types.h | 2 +- simX/include/util.h | 2 +- simX/instruction.cpp | 28 ++++++++++++++-------------- simX/mem.cpp | 9 +++++---- simX/simX.cpp | 24 ++++++++++++++++-------- simX/util.cpp | 2 +- 25 files changed, 141 insertions(+), 98 deletions(-) diff --git a/emulator/enc.cpp b/emulator/enc.cpp index 11bea0fe..24a2b857 100644 --- a/emulator/enc.cpp +++ b/emulator/enc.cpp @@ -24,7 +24,7 @@ ByteDecoder::ByteDecoder(const ArchDef &ad) { static void decodeError(string msg) { cout << "Instruction decoder error: " << msg << '\n'; - exit(1); + std::abort(); } void Encoder::encodeChunk(DataChunk &dest, const TextChunk &src) { @@ -386,7 +386,7 @@ Instruction *WordDecoder::decode(const std::vector &v, Size &idx) { break; defualt: cout << "Unrecognized argument class in word decoder.\n"; - exit(1); + std::abort(); } if (haveRefs && usedImm && refMap.find(idx-n/8) != refMap.end()) { diff --git a/emulator/include/mem.h b/emulator/include/mem.h index f3b072f1..3d1776ac 100644 --- a/emulator/include/mem.h +++ b/emulator/include/mem.h @@ -359,7 +359,7 @@ namespace Harp { char* content = new char[size]; int x = fread(content, 1, size, fp); - if (!x) { std::cout << "COULD NOT READ FILE\n"; exit(1);} + if (!x) { std::cout << "COULD NOT READ FILE\n"; std::abort();} int offset = 0; char* line = content; diff --git a/emulator/include/obj.h b/emulator/include/obj.h index d0ee4357..d39a09bd 100644 --- a/emulator/include/obj.h +++ b/emulator/include/obj.h @@ -40,7 +40,7 @@ namespace Harp { Ref(name, rel), addr(addr) { } virtual void bind(Addr addr, Addr base = 0) { std::cout << "Attempted to bind a SimpleRef.\n"; - exit(1); + std::abort(); } virtual Addr getAddr() const { return this->addr; } Byte *getAddrPtr() { return (Byte*)&addr; } @@ -86,7 +86,7 @@ namespace Harp { // std::cout << "Attempt to bind a " << bits << "-bit " // << (relative?"":"non-") << "relative symbol to an address" // " it cannot reach.\n"; -// exit(1); +// std::abort(); // } // virtual Addr getAddr() const { diff --git a/emulator/instruction.cpp b/emulator/instruction.cpp index e3e0882d..f77c584f 100644 --- a/emulator/instruction.cpp +++ b/emulator/instruction.cpp @@ -284,7 +284,7 @@ void Instruction::executeOn(Warp &c) { break; default: cout << "unsupported MUL/DIV instr\n"; - exit(1); + std::abort(); } } else @@ -351,7 +351,7 @@ void Instruction::executeOn(Warp &c) { break; default: cout << "ERROR: UNSUPPORTED R INST\n"; - exit(1); + std::abort(); } } break; @@ -388,7 +388,7 @@ void Instruction::executeOn(Warp &c) { break; default: cout << "ERROR: UNSUPPORTED L INST\n"; - exit(1); + std::abort(); c.memAccesses.push_back(Warp::MemAccess(false, memAddr)); } break; @@ -475,7 +475,7 @@ void Instruction::executeOn(Warp &c) { break; default: cout << "ERROR: UNSUPPORTED L INST\n"; - exit(1); + std::abort(); } break; case S_INST: @@ -507,7 +507,7 @@ void Instruction::executeOn(Warp &c) { break; default: cout << "ERROR: UNSUPPORTED S INST\n"; - exit(1); + std::abort(); } c.memAccesses.push_back(Warp::MemAccess(true, memAddr)); #ifdef EMU_INSTRUMENTATION @@ -855,7 +855,7 @@ void Instruction::executeOn(Warp &c) { default: cout << "pc: " << hex << (c.pc) << "\n"; cout << "aERROR: Unsupported instruction: " << *this << "\n" << flush; - exit(1); + std::abort(); } } diff --git a/emulator/mem.cpp b/emulator/mem.cpp index 35a7e4f5..ca6937d3 100644 --- a/emulator/mem.cpp +++ b/emulator/mem.cpp @@ -25,7 +25,7 @@ RamMemDevice::RamMemDevice(const char *filename, Size wordSize) : if (!input) { cout << "Error reading file \"" << filename << "\" into RamMemDevice.\n"; - exit(1); + std::abort(); } do { contents.push_back(input.get()); } while (input); @@ -38,7 +38,7 @@ RamMemDevice::RamMemDevice(Size size, Size wordSize) : void RomMemDevice::write(Addr, Word) { cout << "Attempt to write to ROM.\n"; - exit(1); + std::abort(); } Word RamMemDevice::read(Addr addr) { @@ -215,7 +215,7 @@ Word DiskControllerMemDevice::read(Addr a) { case 5: return status; default: cout << "Attempt to read invalid disk controller register.\n"; - exit(1); + std::abort(); } } diff --git a/emulator/qsim-harp.cpp b/emulator/qsim-harp.cpp index d25ad9ec..61714b6f 100644 --- a/emulator/qsim-harp.cpp +++ b/emulator/qsim-harp.cpp @@ -20,7 +20,7 @@ Harp::OSDomain::OSDomain(ArchDef &archref, string imgFile) : { if (osDomain != NULL) { cout << "Error: OSDomain is a singleton."; - exit(1); + std::abort(); } osDomain = this; diff --git a/simX/Makefile b/simX/Makefile index fb563f13..68fe7414 100644 --- a/simX/Makefile +++ b/simX/Makefile @@ -1,7 +1,9 @@ ################################################################################ # HARPtools by Chad D. Kersey, Summer 2011 # ################################################################################ -CXXFLAGS ?= -std=c++11 -fPIC -O3 -g # -g -DUSE_DEBUG=3 -DPRINT_ACTIVE_THREADS + +CXXFLAGS ?= -std=c++11 -fPIC -O3 -Wall -Wextra -pedantic -g -DUSE_DEBUG=3 -DPRINT_ACTIVE_THREADS +# CXXFLAGS ?= -std=c++11 -fPIC -O0 -g -Wall -Wextra -pedantic # -g -DUSE_DEBUG=3 -DPRINT_ACTIVE_THREADS LIB_OBJS=simX.cpp args.cpp mem.cpp core.cpp instruction.cpp enc.cpp util.cpp @@ -10,7 +12,9 @@ INCLUDE=-I. -I../rtl/shared_memory -I../rtl/cache -I../rtl/interfaces -Isimulate FILE=cache_simX.v COMP=--compiler gcc LIB= -CF=-CFLAGS '-std=c++11 -fPIC -O3' + +CF=-CFLAGS '-std=c++11 -fPIC -O3 -Wall -Wextra -pedantic' +#CF=-CFLAGS '-std=c++11 -fPIC -O0 -g -Wall -Wextra -pedantic' LIGHTW=-Wno-UNOPTFLAT -Wno-WIDTH DEB=--trace -DVL_DEBUG=1 diff --git a/simX/core.cpp b/simX/core.cpp index f267cbe7..7ba684a4 100644 --- a/simX/core.cpp +++ b/simX/core.cpp @@ -111,6 +111,14 @@ Core::Core(const ArchDef &a, Decoder &d, MemoryUnit &mem, Word id): release_warp = false; foundSchedule = true; schedule_w = 0; + + memset(&inst_in_fetch, 0, sizeof(inst_in_fetch)); + memset(&inst_in_decode, 0, sizeof(inst_in_decode)); + memset(&inst_in_scheduler, 0, sizeof(inst_in_scheduler)); + memset(&inst_in_exe, 0, sizeof(inst_in_exe)); + memset(&inst_in_lsu, 0, sizeof(inst_in_lsu)); + memset(&inst_in_wb, 0, sizeof(inst_in_wb)); + INIT_TRACE(inst_in_fetch); INIT_TRACE(inst_in_decode); INIT_TRACE(inst_in_scheduler); @@ -158,6 +166,7 @@ Core::Core(const ArchDef &a, Decoder &d, MemoryUnit &mem, Word id): bool Core::interrupt(Word r0) { w[0].interrupt(r0); + return false; } void Core::step() @@ -214,8 +223,8 @@ void Core::getCacheDelays(trace_inst_t * trace_inst) if (trace_inst->valid_inst) { - bool in_dcache_in_valid[a.getNThds()]; - unsigned in_dcache_in_address[a.getNThds()]; + std::vector in_dcache_in_valid(a.getNThds()); + std::vector in_dcache_in_address(a.getNThds()); unsigned in_dcache_mem_read; unsigned in_dcache_mem_write; @@ -709,10 +718,26 @@ void Core::printStats() const { } Warp::Warp(Core *c, Word id) : - core(c), pc(0x80000000), interruptEnable(true), - supervisorMode(true), activeThreads(0), reg(0), pred(0), - shadowReg(core->a.getNRegs()), shadowPReg(core->a.getNPRegs()), id(id), - spawned(false), steps(0), insts(0), loads(0), stores(0), VLEN(1024) + core(c), + pc(0x80000000), + shadowPc(0), + id(id), + activeThreads(0), + shadowActiveThreads(0), + reg(0), + pred(0), + shadowReg(core->a.getNRegs()), + shadowPReg(core->a.getNPRegs()), + VLEN(1024), + interruptEnable(true), + shadowInterruptEnable(false), + supervisorMode(true), + shadowSupervisorMode(false), + spawned(false), + steps(0), + insts(0), + loads(0), + stores(0) { D(3, "Creating a new thread with PC: " << hex << this->pc << '\n'); /* Build the register file. */ diff --git a/simX/enc.cpp b/simX/enc.cpp index 074f391e..6a7d81a2 100644 --- a/simX/enc.cpp +++ b/simX/enc.cpp @@ -22,14 +22,12 @@ using namespace Harp; // wordSize = ad.getWordSize(); // } -static void decodeError(string msg) { +/*static void decodeError(string msg) { cout << "Instruction decoder error: " << msg << '\n'; - exit(1); -} + std::abort(); +}*/ - - -static unsigned ceilLog2(RegNum x) { +/*static unsigned ceilLog2(RegNum x) { unsigned z = 0; bool nonZeroInnerValues(false); @@ -44,8 +42,7 @@ static unsigned ceilLog2(RegNum x) { if (nonZeroInnerValues) z++; return z; -} - +}*/ WordDecoder::WordDecoder(const ArchDef &arch) { @@ -236,7 +233,7 @@ Instruction *WordDecoder::decode(const std::vector &v, Size &idx, trace_in case InstType::V_TYPE: D(3, "Entered here: instr type = vector" << op); - switch(op) { + switch (op) { case Opcode::VSET_ARITH: //TODO: arithmetic ops inst.setDestReg((code>>shift_rd) & reg_mask); inst.setSrcReg((code>>shift_rs1) & reg_mask); @@ -308,11 +305,14 @@ Instruction *WordDecoder::decode(const std::vector &v, Size &idx, trace_in //trace_inst->vd = ((code>>shift_rd) & reg_mask); trace_inst->vs1 = ((code>>shift_rd) & reg_mask); //vs3 break; + default: + cout << "Inavlid opcode.\n"; + std::abort(); } break; - default: + default: cout << "Unrecognized argument class in word decoder.\n"; - exit(1); + std::abort(); } if (haveRefs && usedImm && refMap.find(idx-n/8) != refMap.end()) { diff --git a/simX/include/archdef.h b/simX/include/archdef.h index 4a071c0d..fa284aad 100644 --- a/simX/include/archdef.h +++ b/simX/include/archdef.h @@ -111,6 +111,6 @@ namespace Harp { RegNum nRegs, nPRegs; char encChar; }; -}; +} #endif diff --git a/simX/include/args.h b/simX/include/args.h index 77ef2c90..ec8d6880 100644 --- a/simX/include/args.h +++ b/simX/include/args.h @@ -56,6 +56,6 @@ namespace HarpTools { bool &x; }; -}; +} #endif diff --git a/simX/include/asm-tokens.h b/simX/include/asm-tokens.h index f28a598b..792c2f92 100644 --- a/simX/include/asm-tokens.h +++ b/simX/include/asm-tokens.h @@ -11,6 +11,6 @@ namespace HarpTools { ASM_T_PREG, ASM_T_REG, ASM_T_REG_RA, ASM_T_REG_SP, ASM_T_REG_FP, ASM_T_LIT, ASM_T_SYM, ASM_T_PEXP }; -}; +} #endif diff --git a/simX/include/core.h b/simX/include/core.h index b4cfd112..77e4bf41 100644 --- a/simX/include/core.h +++ b/simX/include/core.h @@ -35,9 +35,9 @@ namespace Harp { template class Reg { public: - Reg(): cpuId(0), regNum(0), val(0) {} - Reg(Word c, Word n): cpuId(c), regNum(n), val(0) {} - Reg(Word c, Word n, T v): cpuId(c), regNum(n), val(v) {} + Reg(): val(0), cpuId(0), regNum(0) {} + Reg(Word c, Word n): val(0), cpuId(c), regNum(n) {} + Reg(Word c, Word n, T v): val(v), cpuId(c), regNum(n) {} Reg &operator=(T r) { if (regNum) {val = r; doWrite();} return *this; } @@ -83,10 +83,10 @@ namespace Harp { DomStackEntry(const std::vector &tmask): tmask(tmask), fallThrough(true), uni(false) {} - bool fallThrough; - bool uni; - std::vector tmask; + std::vector tmask; Word pc; + bool fallThrough; + bool uni; }; struct vtype @@ -193,13 +193,14 @@ namespace Harp { std::vector>> vreg; // 32 vector registers - bool interruptEnable, shadowInterruptEnable, supervisorMode, - shadowSupervisorMode, spawned; + bool interruptEnable, shadowInterruptEnable; + bool supervisorMode, shadowSupervisorMode; + bool spawned; unsigned long steps, insts, loads, stores; friend class Instruction; }; -}; +} #endif diff --git a/simX/include/enc.h b/simX/include/enc.h index 0c8dc08e..37b054ee 100644 --- a/simX/include/enc.h +++ b/simX/include/enc.h @@ -50,7 +50,10 @@ namespace Harp { public: WordDecoder(const ArchDef &); virtual Instruction *decode(const std::vector &v, Size &n, trace_inst_t * trace_inst); - virtual Instruction *decode(const std::vector &v, Size &n) {printf("Not implemented\n");} + virtual Instruction *decode(const std::vector &v, Size &n) { + printf("Not implemented\n"); + return nullptr; + } private: Size n, o, r, p, i1, i2, i3; @@ -72,6 +75,6 @@ namespace Harp { }; -}; +} #endif diff --git a/simX/include/harpfloat.h b/simX/include/harpfloat.h index f2941c79..c8cdbcfc 100644 --- a/simX/include/harpfloat.h +++ b/simX/include/harpfloat.h @@ -64,7 +64,7 @@ namespace Harp { DEBUGMSG("Set to " << d); } - Float(double d, Size n): sz(n), d(d) { DEBUGMSG("Float(double, size)"); } + Float(double d, Size n): d(d), sz(n) { DEBUGMSG("Float(double, size)"); } operator Word_u() { DEBUGMSG("Float -> Word_u: " << d); @@ -120,4 +120,4 @@ namespace Harp { double d; Size sz; }; -}; +} diff --git a/simX/include/help.h b/simX/include/help.h index 9c495bbb..802bf501 100644 --- a/simX/include/help.h +++ b/simX/include/help.h @@ -32,6 +32,6 @@ namespace HarpTools { *disasmHelp = "HARP Disassembler command line arguments:\n" " -a, --arch Architecture string.\n" " -o, --output Output filename.\n"; - }; -}; + } +} #endif diff --git a/simX/include/instruction.h b/simX/include/instruction.h index e227cfd3..4df21236 100644 --- a/simX/include/instruction.h +++ b/simX/include/instruction.h @@ -164,7 +164,7 @@ namespace Harp { }; -}; +} #endif diff --git a/simX/include/mem.h b/simX/include/mem.h index 2b4b38d0..f0f340e7 100644 --- a/simX/include/mem.h +++ b/simX/include/mem.h @@ -99,9 +99,10 @@ namespace Harp { Byte *file; Size blocks; }; - std::vector disks; + + Size wordSize, blockSize; Core &core; - Size wordSize, blockSize;; + std::vector disks; }; class MemoryUnit { @@ -136,7 +137,7 @@ namespace Harp { private: class ADecoder { public: - ADecoder() : zeroChild(NULL), oneChild(NULL), range(0) {} + ADecoder() : zeroChild(NULL), oneChild(NULL), range(0), md(nullptr) {} ADecoder(MemDevice &md, Size range) : zeroChild(NULL), oneChild(NULL), range(range), md(&md) {} Byte *getPtr(Addr a, Size sz, Size wordSize); @@ -145,24 +146,24 @@ namespace Harp { void map(Addr a, MemDevice &md, Size range, Size bit); private: MemDevice &doLookup(Addr a, Size &bit); - ADecoder *zeroChild, *oneChild; - MemDevice *md; + ADecoder *zeroChild, *oneChild; Size range; + MemDevice *md; }; - ADecoder ad; - struct TLBEntry { TLBEntry() {} TLBEntry(Word pfn, Word flags): pfn(pfn), flags(flags) {} - Word flags; Word pfn; + Word flags; }; - std::map tlb; - TLBEntry tlbLookup(Addr vAddr, Word flagMask); - Size pageSize, addrBytes; + + ADecoder ad; + + std::map tlb; + TLBEntry tlbLookup(Addr vAddr, Word flagMask); bool disableVm; }; @@ -402,7 +403,7 @@ namespace Harp { char* content = new char[size]; int x = fread(content, 1, size, fp); - if (!x) { std::cout << "COULD NOT READ FILE\n"; exit(1);} + if (!x) { std::cout << "COULD NOT READ FILE\n"; std::abort();} int offset = 0; char* line = content; @@ -455,7 +456,7 @@ namespace Harp { -}; +} #endif diff --git a/simX/include/obj.h b/simX/include/obj.h index d0ee4357..c64607bb 100644 --- a/simX/include/obj.h +++ b/simX/include/obj.h @@ -40,7 +40,7 @@ namespace Harp { Ref(name, rel), addr(addr) { } virtual void bind(Addr addr, Addr base = 0) { std::cout << "Attempted to bind a SimpleRef.\n"; - exit(1); + std::abort(); } virtual Addr getAddr() const { return this->addr; } Byte *getAddrPtr() { return (Byte*)&addr; } @@ -86,7 +86,7 @@ namespace Harp { // std::cout << "Attempt to bind a " << bits << "-bit " // << (relative?"":"non-") << "relative symbol to an address" // " it cannot reach.\n"; -// exit(1); +// std::abort(); // } // virtual Addr getAddr() const { @@ -205,6 +205,6 @@ namespace Harp { // private: // const ArchDef &arch; // }; -}; +} #endif diff --git a/simX/include/types.h b/simX/include/types.h index 1c5c86d9..43598a7d 100644 --- a/simX/include/types.h +++ b/simX/include/types.h @@ -20,6 +20,6 @@ namespace Harp { enum MemFlags {RD_USR = 1, WR_USR = 2, EX_USR = 4, RD_SUP = 8, WR_SUP = 16, EX_SUP = 32}; -}; +} #endif diff --git a/simX/include/util.h b/simX/include/util.h index 006612e3..a7935ca7 100644 --- a/simX/include/util.h +++ b/simX/include/util.h @@ -19,6 +19,6 @@ namespace Harp { Word_u readWord(const std::vector &b, Size &n, Size wordSize); void writeByte(std::vector &p, Size &n, Byte b); void writeWord(std::vector &p, Size &n, Size wordSize, Word w); -}; +} #endif diff --git a/simX/instruction.cpp b/simX/instruction.cpp index c7f45eb6..60d23682 100644 --- a/simX/instruction.cpp +++ b/simX/instruction.cpp @@ -264,16 +264,16 @@ void trap_to_simulator(Warp & c) fstat(file, &st); fprintf(stderr, "------------------------\n"); - fprintf(stderr, "Size of struct: %x\n", sizeof(struct stat)); + fprintf(stderr, "Size of struct: %ld\n", sizeof(struct stat)); fprintf(stderr, "st_mode: %x\n", st.st_mode); - fprintf(stderr, "st_dev: %x\n", st.st_dev); - fprintf(stderr, "st_ino: %x\n", st.st_ino); + fprintf(stderr, "st_dev: %ld\n", st.st_dev); + fprintf(stderr, "st_ino: %ld\n", st.st_ino); fprintf(stderr, "st_uid: %x\n", st.st_uid); fprintf(stderr, "st_gid: %x\n", st.st_gid); - fprintf(stderr, "st_rdev: %x\n", st.st_rdev); - fprintf(stderr, "st_size: %x\n", st.st_size); - fprintf(stderr, "st_blksize: %x\n", st.st_blksize); - fprintf(stderr, "st_blocks: %x\n", st.st_blocks); + fprintf(stderr, "st_rdev: %ld\n", st.st_rdev); + fprintf(stderr, "st_size: %ld\n", st.st_size); + fprintf(stderr, "st_blksize: %ld\n", st.st_blksize); + fprintf(stderr, "st_blocks: %ld\n", st.st_blocks); fprintf(stderr, "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); upload(&write_buffer, (char *) &st.st_mode , sizeof(st.st_mode), c); @@ -517,7 +517,7 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) { break; default: cout << "unsupported MUL/DIV instr\n"; - exit(1); + std::abort(); } } else @@ -584,7 +584,7 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) { break; default: cout << "ERROR: UNSUPPORTED R INST\n"; - exit(1); + std::abort(); } } break; @@ -622,7 +622,7 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) { break; default: cout << "ERROR: UNSUPPORTED L INST\n"; - exit(1); + std::abort(); c.memAccesses.push_back(Warp::MemAccess(false, memAddr)); } break; @@ -709,7 +709,7 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) { break; default: cout << "ERROR: UNSUPPORTED L INST\n"; - exit(1); + std::abort(); } break; case S_INST: @@ -743,7 +743,7 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) { break; default: cout << "ERROR: UNSUPPORTED S INST\n"; - exit(1); + std::abort(); } c.memAccesses.push_back(Warp::MemAccess(true, memAddr)); #ifdef EMU_INSTRUMENTATION @@ -2397,7 +2397,7 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) { break; default: cout << "ERROR: UNSUPPORTED S INST\n" << flush; - exit(1); + std::abort(); } // cout << "Loop finished" << endl; // c.memAccesses.push_back(Warp::MemAccess(true, memAddr)); @@ -2408,7 +2408,7 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) { default: D(3, "pc: " << hex << (c.pc-4)); D(3, "aERROR: Unsupported instruction: " << *this); - exit(1); + std::abort(); } // break; diff --git a/simX/mem.cpp b/simX/mem.cpp index e7d3bb24..b39a0ee4 100644 --- a/simX/mem.cpp +++ b/simX/mem.cpp @@ -25,7 +25,7 @@ RamMemDevice::RamMemDevice(const char *filename, Size wordSize) : if (!input) { cout << "Error reading file \"" << filename << "\" into RamMemDevice.\n"; - exit(1); + std::abort(); } do { contents.push_back(input.get()); } while (input); @@ -34,11 +34,11 @@ RamMemDevice::RamMemDevice(const char *filename, Size wordSize) : } RamMemDevice::RamMemDevice(Size size, Size wordSize) : - contents(size), wordSize(wordSize) {} + wordSize(wordSize), contents(size) {} void RomMemDevice::write(Addr, Word) { cout << "Attempt to write to ROM.\n"; - exit(1); + std::abort(); } Word RamMemDevice::read(Addr addr) { @@ -216,6 +216,7 @@ void *Harp::consoleInputThread(void* arg_vp) { // } // cout << "Console input ended. Exiting.\n"; // exit(4); + return nullptr; } // ConsoleMemDevice::ConsoleMemDevice(Size wS, std::ostream &o, Core &core, @@ -246,7 +247,7 @@ Word DiskControllerMemDevice::read(Addr a) { case 5: return status; default: cout << "Attempt to read invalid disk controller register.\n"; - exit(1); + std::abort(); } } diff --git a/simX/simX.cpp b/simX/simX.cpp index a2fe330f..7691e728 100644 --- a/simX/simX.cpp +++ b/simX/simX.cpp @@ -144,14 +144,22 @@ int main(int argc, char** argv) { try { switch (findMode(argc - 1, argv + 1)) { - case HARPTOOL_MODE_ASM: cout << "ASM not supported\n"; - case HARPTOOL_MODE_DISASM: cout << "DISASM not supported\n"; - case HARPTOOL_MODE_EMU: return emu_main (argc - 2, argv + 2); - case HARPTOOL_MODE_LD: cout << "LD not supported\n"; - case HARPTOOL_MODE_HELP: - default: - cout << "Usage:\n" << Help::mainHelp; - return 0; + case HARPTOOL_MODE_ASM: + cout << "ASM not supported\n"; + return -1; + case HARPTOOL_MODE_DISASM: + cout << "DISASM not supported\n"; + return -1; + case HARPTOOL_MODE_EMU: + return emu_main(argc - 2, argv + 2); + case HARPTOOL_MODE_LD: + cout << "LD not supported\n"; + return -1; + case HARPTOOL_MODE_HELP: + [[fallthrough]] + default: + cout << "Usage:\n" << Help::mainHelp; + return 0; } } catch (BadArg ba) { cout << "Unrecognized argument \"" << ba.arg << "\".\n"; diff --git a/simX/util.cpp b/simX/util.cpp index 09b2ec0c..a1d6ebe6 100644 --- a/simX/util.cpp +++ b/simX/util.cpp @@ -13,7 +13,7 @@ using namespace std; // Make it easy for autotools-based build systems to detect this library. extern "C" { int harplib_present = 1; -}; +} void Harp::wordToBytes(Byte *b, Word_u w, Size wordSize) { while (wordSize--) {