From 199598977ec6aa5e897bb37a83de89e08d14eba9 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 10 Nov 2019 13:40:53 +1100 Subject: assert aborts on failure - abort is not an exception. conditional noexcept is an antipattern, get rid of it. (nw) --- src/emu/diexec.cpp | 6 +++--- src/emu/diexec.h | 16 ++++++++-------- src/emu/emucore.h | 8 -------- src/emu/machine.h | 2 +- src/emu/schedule.cpp | 6 +++--- src/emu/schedule.h | 8 ++++---- 6 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/emu/diexec.cpp b/src/emu/diexec.cpp index a3a042b4d32..f04854ee090 100644 --- a/src/emu/diexec.cpp +++ b/src/emu/diexec.cpp @@ -92,7 +92,7 @@ device_execute_interface::~device_execute_interface() // run before we run again //------------------------------------------------- -void device_execute_interface::abort_timeslice() noexcept(MAME_NDEBUG) +void device_execute_interface::abort_timeslice() noexcept { // ignore if not the executing device if (!executing()) @@ -207,7 +207,7 @@ void device_execute_interface::trigger(int trigid) // for a device //------------------------------------------------- -attotime device_execute_interface::local_time() const noexcept(MAME_NDEBUG) +attotime device_execute_interface::local_time() const noexcept { // if we're active, add in the time from the current slice if (executing()) @@ -225,7 +225,7 @@ attotime device_execute_interface::local_time() const noexcept(MAME_NDEBUG) // cycles executed on this device //------------------------------------------------- -u64 device_execute_interface::total_cycles() const noexcept(MAME_NDEBUG) +u64 device_execute_interface::total_cycles() const noexcept { if (executing()) { diff --git a/src/emu/diexec.h b/src/emu/diexec.h index 565d89c6da2..c4a99c63043 100644 --- a/src/emu/diexec.h +++ b/src/emu/diexec.h @@ -152,12 +152,12 @@ public: } // execution management - device_scheduler &scheduler() const noexcept(MAME_NDEBUG) { assert(m_scheduler != nullptr); return *m_scheduler; } - bool executing() const noexcept(MAME_NDEBUG) { return scheduler().currently_executing() == this; } - s32 cycles_remaining() const noexcept(MAME_NDEBUG) { return executing() ? *m_icountptr : 0; } // cycles remaining in this timeslice - void eat_cycles(int cycles) noexcept(MAME_NDEBUG) { if (executing()) *m_icountptr = (cycles > *m_icountptr) ? 0 : (*m_icountptr - cycles); } - void adjust_icount(int delta) noexcept(MAME_NDEBUG) { if (executing()) *m_icountptr += delta; } - void abort_timeslice() noexcept(MAME_NDEBUG); + device_scheduler &scheduler() const noexcept { assert(m_scheduler != nullptr); return *m_scheduler; } + bool executing() const noexcept { return scheduler().currently_executing() == this; } + s32 cycles_remaining() const noexcept { return executing() ? *m_icountptr : 0; } // cycles remaining in this timeslice + void eat_cycles(int cycles) noexcept { if (executing()) *m_icountptr = (cycles > *m_icountptr) ? 0 : (*m_icountptr - cycles); } + void adjust_icount(int delta) noexcept { if (executing()) *m_icountptr += delta; } + void abort_timeslice() noexcept; // input and interrupt management void set_input_line(int linenum, int state) { m_input[linenum].set_state_synced(state); } @@ -183,8 +183,8 @@ public: void signal_interrupt_trigger() { trigger(m_inttrigger); } // time and cycle accounting - attotime local_time() const noexcept(MAME_NDEBUG); - u64 total_cycles() const noexcept(MAME_NDEBUG); + attotime local_time() const noexcept; + u64 total_cycles() const noexcept; // required operation overrides void run() { execute_run(); } diff --git a/src/emu/emucore.h b/src/emu/emucore.h index 530227ad692..ef6713c8d8f 100644 --- a/src/emu/emucore.h +++ b/src/emu/emucore.h @@ -237,14 +237,6 @@ template constexpr auto DEGREE_TO_RADIAN(T const &x) { return (M_PI #define ENDIAN_VALUE_NE_NNE(endian,neval,nneval) (((endian) == ENDIANNESS_NATIVE) ? (neval) : (nneval)) -// useful for declaring functions with asserts as conditionally noexcept -#ifdef NDEBUG -constexpr bool MAME_NDEBUG = true; -#else -constexpr bool MAME_NDEBUG = false; -#endif - - //************************************************************************** // EXCEPTION CLASSES //************************************************************************** diff --git a/src/emu/machine.h b/src/emu/machine.h index a3be1a81f4c..0c14f6acdb6 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -206,7 +206,7 @@ public: // additional helpers emu_options &options() const { return m_config.options(); } - attotime time() const noexcept(MAME_NDEBUG) { return m_scheduler.time(); } + attotime time() const noexcept { return m_scheduler.time(); } bool scheduled_event_pending() const { return m_exit_pending || m_hard_reset_pending; } bool allow_logging() const { return !m_logerror_list.empty(); } diff --git a/src/emu/schedule.cpp b/src/emu/schedule.cpp index c35e41d0457..f548e1a9fbf 100644 --- a/src/emu/schedule.cpp +++ b/src/emu/schedule.cpp @@ -209,7 +209,7 @@ void emu_timer::adjust(attotime start_delay, s32 param, const attotime &period) // timer was started //------------------------------------------------- -attotime emu_timer::elapsed() const noexcept(MAME_NDEBUG) +attotime emu_timer::elapsed() const noexcept { return machine().time() - m_start; } @@ -220,7 +220,7 @@ attotime emu_timer::elapsed() const noexcept(MAME_NDEBUG) // remaining until the timer expires //------------------------------------------------- -attotime emu_timer::remaining() const noexcept(MAME_NDEBUG) +attotime emu_timer::remaining() const noexcept { attotime curtime = machine().time(); if (curtime >= m_expire) @@ -356,7 +356,7 @@ device_scheduler::~device_scheduler() // time - return the current time //------------------------------------------------- -attotime device_scheduler::time() const noexcept(MAME_NDEBUG) +attotime device_scheduler::time() const noexcept { // if we're currently in a callback, use the timer's expiration time as a base if (m_callback_timer != nullptr) diff --git a/src/emu/schedule.h b/src/emu/schedule.h index 951bbb045eb..88edd8914d8 100644 --- a/src/emu/schedule.h +++ b/src/emu/schedule.h @@ -64,7 +64,7 @@ class emu_timer public: // getters emu_timer *next() const { return m_next; } - running_machine &machine() const noexcept(MAME_NDEBUG) { assert(m_machine != nullptr); return *m_machine; } + running_machine &machine() const noexcept { assert(m_machine != nullptr); return *m_machine; } bool enabled() const { return m_enabled; } int param() const { return m_param; } void *ptr() const { return m_ptr; } @@ -79,8 +79,8 @@ public: void adjust(attotime start_delay, s32 param = 0, const attotime &periodicity = attotime::never); // timing queries - attotime elapsed() const noexcept(MAME_NDEBUG); - attotime remaining() const noexcept(MAME_NDEBUG); + attotime elapsed() const noexcept; + attotime remaining() const noexcept; attotime start() const { return m_start; } attotime expire() const { return m_expire; } attotime period() const { return m_period; } @@ -122,7 +122,7 @@ public: // getters running_machine &machine() const noexcept { return m_machine; } - attotime time() const noexcept(MAME_NDEBUG); + attotime time() const noexcept; emu_timer *first_timer() const { return m_timer_list; } device_execute_interface *currently_executing() const noexcept { return m_executing_device; } bool can_save() const; -- cgit v1.2.3