assert aborts on failure - abort is not an exception. conditional noexcept is an antipattern, get rid of it. (nw)

This commit is contained in:
Vas Crabb 2019-11-10 13:40:53 +11:00
parent f60ed79ed6
commit 199598977e
6 changed files with 19 additions and 27 deletions

View File

@ -92,7 +92,7 @@ device_execute_interface::~device_execute_interface()
// run before we run again // 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 // ignore if not the executing device
if (!executing()) if (!executing())
@ -207,7 +207,7 @@ void device_execute_interface::trigger(int trigid)
// for a device // 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 we're active, add in the time from the current slice
if (executing()) if (executing())
@ -225,7 +225,7 @@ attotime device_execute_interface::local_time() const noexcept(MAME_NDEBUG)
// cycles executed on this device // 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()) if (executing())
{ {

View File

@ -152,12 +152,12 @@ public:
} }
// execution management // execution management
device_scheduler &scheduler() const noexcept(MAME_NDEBUG) { assert(m_scheduler != nullptr); return *m_scheduler; } device_scheduler &scheduler() const noexcept { assert(m_scheduler != nullptr); return *m_scheduler; }
bool executing() const noexcept(MAME_NDEBUG) { return scheduler().currently_executing() == this; } bool executing() const noexcept { return scheduler().currently_executing() == this; }
s32 cycles_remaining() const noexcept(MAME_NDEBUG) { return executing() ? *m_icountptr : 0; } // cycles remaining in this timeslice s32 cycles_remaining() const noexcept { 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 eat_cycles(int cycles) noexcept { 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 adjust_icount(int delta) noexcept { if (executing()) *m_icountptr += delta; }
void abort_timeslice() noexcept(MAME_NDEBUG); void abort_timeslice() noexcept;
// input and interrupt management // input and interrupt management
void set_input_line(int linenum, int state) { m_input[linenum].set_state_synced(state); } 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); } void signal_interrupt_trigger() { trigger(m_inttrigger); }
// time and cycle accounting // time and cycle accounting
attotime local_time() const noexcept(MAME_NDEBUG); attotime local_time() const noexcept;
u64 total_cycles() const noexcept(MAME_NDEBUG); u64 total_cycles() const noexcept;
// required operation overrides // required operation overrides
void run() { execute_run(); } void run() { execute_run(); }

View File

@ -237,14 +237,6 @@ template <typename T> constexpr auto DEGREE_TO_RADIAN(T const &x) { return (M_PI
#define ENDIAN_VALUE_NE_NNE(endian,neval,nneval) (((endian) == ENDIANNESS_NATIVE) ? (neval) : (nneval)) #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 // EXCEPTION CLASSES
//************************************************************************** //**************************************************************************

View File

@ -206,7 +206,7 @@ public:
// additional helpers // additional helpers
emu_options &options() const { return m_config.options(); } 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 scheduled_event_pending() const { return m_exit_pending || m_hard_reset_pending; }
bool allow_logging() const { return !m_logerror_list.empty(); } bool allow_logging() const { return !m_logerror_list.empty(); }

View File

@ -209,7 +209,7 @@ void emu_timer::adjust(attotime start_delay, s32 param, const attotime &period)
// timer was started // timer was started
//------------------------------------------------- //-------------------------------------------------
attotime emu_timer::elapsed() const noexcept(MAME_NDEBUG) attotime emu_timer::elapsed() const noexcept
{ {
return machine().time() - m_start; return machine().time() - m_start;
} }
@ -220,7 +220,7 @@ attotime emu_timer::elapsed() const noexcept(MAME_NDEBUG)
// remaining until the timer expires // remaining until the timer expires
//------------------------------------------------- //-------------------------------------------------
attotime emu_timer::remaining() const noexcept(MAME_NDEBUG) attotime emu_timer::remaining() const noexcept
{ {
attotime curtime = machine().time(); attotime curtime = machine().time();
if (curtime >= m_expire) if (curtime >= m_expire)
@ -356,7 +356,7 @@ device_scheduler::~device_scheduler()
// time - return the current time // 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 we're currently in a callback, use the timer's expiration time as a base
if (m_callback_timer != nullptr) if (m_callback_timer != nullptr)

View File

@ -64,7 +64,7 @@ class emu_timer
public: public:
// getters // getters
emu_timer *next() const { return m_next; } 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; } bool enabled() const { return m_enabled; }
int param() const { return m_param; } int param() const { return m_param; }
void *ptr() const { return m_ptr; } void *ptr() const { return m_ptr; }
@ -79,8 +79,8 @@ public:
void adjust(attotime start_delay, s32 param = 0, const attotime &periodicity = attotime::never); void adjust(attotime start_delay, s32 param = 0, const attotime &periodicity = attotime::never);
// timing queries // timing queries
attotime elapsed() const noexcept(MAME_NDEBUG); attotime elapsed() const noexcept;
attotime remaining() const noexcept(MAME_NDEBUG); attotime remaining() const noexcept;
attotime start() const { return m_start; } attotime start() const { return m_start; }
attotime expire() const { return m_expire; } attotime expire() const { return m_expire; }
attotime period() const { return m_period; } attotime period() const { return m_period; }
@ -122,7 +122,7 @@ public:
// getters // getters
running_machine &machine() const noexcept { return m_machine; } 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; } emu_timer *first_timer() const { return m_timer_list; }
device_execute_interface *currently_executing() const noexcept { return m_executing_device; } device_execute_interface *currently_executing() const noexcept { return m_executing_device; }
bool can_save() const; bool can_save() const;