summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/attotime.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/attotime.h')
-rw-r--r--src/emu/attotime.h48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/emu/attotime.h b/src/emu/attotime.h
index cad95177724..945ed78a87a 100644
--- a/src/emu/attotime.h
+++ b/src/emu/attotime.h
@@ -91,15 +91,15 @@ class attotime
{
public:
// construction/destruction
- constexpr attotime() : m_seconds(0), m_attoseconds(0) { }
+ constexpr attotime() noexcept : m_seconds(0), m_attoseconds(0) { }
/** Constructs with @p secs seconds and @p attos attoseconds. */
- constexpr attotime(seconds_t secs, attoseconds_t attos) : m_seconds(secs), m_attoseconds(attos) { }
+ constexpr attotime(seconds_t secs, attoseconds_t attos) noexcept : m_seconds(secs), m_attoseconds(attos) { }
- constexpr attotime(const attotime& that) : m_seconds(that.m_seconds), m_attoseconds(that.m_attoseconds) { }
+ constexpr attotime(const attotime& that) noexcept : m_seconds(that.m_seconds), m_attoseconds(that.m_attoseconds) { }
// assignment
- attotime& operator=(const attotime& that)
+ attotime &operator=(const attotime& that) noexcept
{
this->m_seconds = that.m_seconds;
this->m_attoseconds = that.m_attoseconds;
@@ -107,23 +107,25 @@ public:
}
// queries
- constexpr bool is_zero() const { return (m_seconds == 0 && m_attoseconds == 0); }
+ constexpr bool is_zero() const noexcept { return (m_seconds == 0 && m_attoseconds == 0); }
/** Test if value is above @ref ATTOTIME_MAX_SECONDS (considered an overflow) */
- constexpr bool is_never() const { return (m_seconds >= ATTOTIME_MAX_SECONDS); }
+ constexpr bool is_never() const noexcept { return (m_seconds >= ATTOTIME_MAX_SECONDS); }
// conversion to other forms
- constexpr double as_double() const { return double(m_seconds) + ATTOSECONDS_TO_DOUBLE(m_attoseconds); }
- constexpr attoseconds_t as_attoseconds() const;
+ constexpr double as_double() const noexcept { return double(m_seconds) + ATTOSECONDS_TO_DOUBLE(m_attoseconds); }
+ constexpr attoseconds_t as_attoseconds() const noexcept;
constexpr double as_hz() const { return m_seconds == 0 ? ATTOSECONDS_TO_HZ(m_attoseconds) : is_never() ? 0.0 : 1.0 / as_double(); }
+ constexpr double as_khz() const { return m_seconds == 0 ? double(ATTOSECONDS_PER_MILLISECOND) / double(m_attoseconds) : is_never() ? 0.0 : 1e-3 / as_double(); }
+ constexpr double as_mhz() const { return m_seconds == 0 ? double(ATTOSECONDS_PER_MICROSECOND) / double(m_attoseconds) : is_never() ? 0.0 : 1e-6 / as_double(); }
u64 as_ticks(u32 frequency) const;
u64 as_ticks(const XTAL &xtal) const { return as_ticks(xtal.value()); }
/** Convert to string using at @p precision */
const char *as_string(int precision = 9) const;
/** @return the attoseconds portion. */
- constexpr attoseconds_t attoseconds() const { return m_attoseconds; }
+ constexpr attoseconds_t attoseconds() const noexcept { return m_attoseconds; }
/** @return the seconds portion. */
- constexpr seconds_t seconds() const { return m_seconds; }
+ constexpr seconds_t seconds() const noexcept { return m_seconds; }
static attotime from_double(double _time);
static attotime from_ticks(u64 ticks, u32 frequency);
@@ -154,8 +156,8 @@ public:
}
// math
- attotime &operator+=(const attotime &right);
- attotime &operator-=(const attotime &right);
+ attotime &operator+=(const attotime &right) noexcept;
+ attotime &operator-=(const attotime &right) noexcept;
attotime &operator*=(u32 factor);
attotime &operator/=(u32 factor);
@@ -175,7 +177,7 @@ public:
//**************************************************************************
/** handle addition between two attotimes */
-inline attotime operator+(const attotime &left, const attotime &right)
+inline attotime operator+(const attotime &left, const attotime &right) noexcept
{
attotime result;
@@ -200,7 +202,7 @@ inline attotime operator+(const attotime &left, const attotime &right)
return result;
}
-inline attotime &attotime::operator+=(const attotime &right)
+inline attotime &attotime::operator+=(const attotime &right) noexcept
{
// if one of the items is never, return never
if (this->m_seconds >= ATTOTIME_MAX_SECONDS || right.m_seconds >= ATTOTIME_MAX_SECONDS)
@@ -225,7 +227,7 @@ inline attotime &attotime::operator+=(const attotime &right)
/** handle subtraction between two attotimes */
-inline attotime operator-(const attotime &left, const attotime &right)
+inline attotime operator-(const attotime &left, const attotime &right) noexcept
{
attotime result;
@@ -246,7 +248,7 @@ inline attotime operator-(const attotime &left, const attotime &right)
return result;
}
-inline attotime &attotime::operator-=(const attotime &right)
+inline attotime &attotime::operator-=(const attotime &right) noexcept
{
// if time1 is never, return never
if (this->m_seconds >= ATTOTIME_MAX_SECONDS)
@@ -291,39 +293,39 @@ inline attotime operator/(const attotime &left, u32 factor)
/** handle comparisons between attotimes */
-inline constexpr bool operator==(const attotime &left, const attotime &right)
+inline constexpr bool operator==(const attotime &left, const attotime &right) noexcept
{
return (left.m_seconds == right.m_seconds && left.m_attoseconds == right.m_attoseconds);
}
-inline constexpr bool operator!=(const attotime &left, const attotime &right)
+inline constexpr bool operator!=(const attotime &left, const attotime &right) noexcept
{
return (left.m_seconds != right.m_seconds || left.m_attoseconds != right.m_attoseconds);
}
-inline constexpr bool operator<(const attotime &left, const attotime &right)
+inline constexpr bool operator<(const attotime &left, const attotime &right) noexcept
{
return (left.m_seconds < right.m_seconds || (left.m_seconds == right.m_seconds && left.m_attoseconds < right.m_attoseconds));
}
-inline constexpr bool operator<=(const attotime &left, const attotime &right)
+inline constexpr bool operator<=(const attotime &left, const attotime &right) noexcept
{
return (left.m_seconds < right.m_seconds || (left.m_seconds == right.m_seconds && left.m_attoseconds <= right.m_attoseconds));
}
-inline constexpr bool operator>(const attotime &left, const attotime &right)
+inline constexpr bool operator>(const attotime &left, const attotime &right) noexcept
{
return (left.m_seconds > right.m_seconds || (left.m_seconds == right.m_seconds && left.m_attoseconds > right.m_attoseconds));
}
-inline constexpr bool operator>=(const attotime &left, const attotime &right)
+inline constexpr bool operator>=(const attotime &left, const attotime &right) noexcept
{
return (left.m_seconds > right.m_seconds || (left.m_seconds == right.m_seconds && left.m_attoseconds >= right.m_attoseconds));
}
/** Convert to an attoseconds value, clamping to +/- 1 second */
-inline constexpr attoseconds_t attotime::as_attoseconds() const
+inline constexpr attoseconds_t attotime::as_attoseconds() const noexcept
{
return
(m_seconds == 0) ? m_attoseconds : // positive values between 0 and 1 second