From a9a9c45871801d97da9ac751b394f0f8119bd878 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Fri, 26 Jan 2018 17:43:44 +1100 Subject: [PATCH] less reliant on PCH, more constexpr, allow 16_MHz_XTAL without decimal point (nw) --- src/emu/attotime.h | 16 +++++++++------- src/emu/xtal.h | 12 +++++++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/emu/attotime.h b/src/emu/attotime.h index 2b8f75450f9..414e65d81d2 100644 --- a/src/emu/attotime.h +++ b/src/emu/attotime.h @@ -35,6 +35,9 @@ #pragma once +#include "emucore.h" +#include "xtal.h" + #include #undef min #undef max @@ -48,13 +51,13 @@ typedef s64 attoseconds_t; typedef s32 seconds_t; // core definitions -const attoseconds_t ATTOSECONDS_PER_SECOND_SQRT = 1'000'000'000; -const attoseconds_t ATTOSECONDS_PER_SECOND = ATTOSECONDS_PER_SECOND_SQRT * ATTOSECONDS_PER_SECOND_SQRT; -const attoseconds_t ATTOSECONDS_PER_MILLISECOND = ATTOSECONDS_PER_SECOND / 1'000; -const attoseconds_t ATTOSECONDS_PER_MICROSECOND = ATTOSECONDS_PER_SECOND / 1'000'000; -const attoseconds_t ATTOSECONDS_PER_NANOSECOND = ATTOSECONDS_PER_SECOND / 1'000'000'000; +constexpr attoseconds_t ATTOSECONDS_PER_SECOND_SQRT = 1'000'000'000; +constexpr attoseconds_t ATTOSECONDS_PER_SECOND = ATTOSECONDS_PER_SECOND_SQRT * ATTOSECONDS_PER_SECOND_SQRT; +constexpr attoseconds_t ATTOSECONDS_PER_MILLISECOND = ATTOSECONDS_PER_SECOND / 1'000; +constexpr attoseconds_t ATTOSECONDS_PER_MICROSECOND = ATTOSECONDS_PER_SECOND / 1'000'000; +constexpr attoseconds_t ATTOSECONDS_PER_NANOSECOND = ATTOSECONDS_PER_SECOND / 1'000'000'000; -const seconds_t ATTOTIME_MAX_SECONDS = 1'000'000'000; +constexpr seconds_t ATTOTIME_MAX_SECONDS = 1'000'000'000; @@ -70,7 +73,6 @@ inline constexpr attoseconds_t DOUBLE_TO_ATTOSECONDS(double x) { return attoseco inline constexpr double ATTOSECONDS_TO_HZ(attoseconds_t x) { return double(ATTOSECONDS_PER_SECOND) / double(x); } template inline constexpr attoseconds_t HZ_TO_ATTOSECONDS(T &&x) { return attoseconds_t(ATTOSECONDS_PER_SECOND / x); } inline constexpr attoseconds_t HZ_TO_ATTOSECONDS(const XTAL &x) { return attoseconds_t(ATTOSECONDS_PER_SECOND / x.dvalue()); } -inline constexpr attoseconds_t HZ_TO_ATTOSECONDS(XTAL &&x) { return attoseconds_t(ATTOSECONDS_PER_SECOND / x.dvalue()); } // macros for converting other seconds types to attoseconds template inline constexpr attoseconds_t ATTOSECONDS_IN_SEC(T &&x) { return attoseconds_t(x) * ATTOSECONDS_PER_SECOND; } diff --git a/src/emu/xtal.h b/src/emu/xtal.h index 34f4142b37c..6860d38fae6 100644 --- a/src/emu/xtal.h +++ b/src/emu/xtal.h @@ -36,8 +36,10 @@ Usage: ***************************************************************************/ -#ifndef MAME_EMU_DRIVERS_XTAL_H -#define MAME_EMU_DRIVERS_XTAL_H +#ifndef MAME_EMU_XTAL_H +#define MAME_EMU_XTAL_H + +#include "emucore.h" #pragma once @@ -90,4 +92,8 @@ constexpr XTAL operator ""_Hz_XTAL(long double clock) { return XTAL(double(clock constexpr XTAL operator ""_kHz_XTAL(long double clock) { return XTAL(double(clock * 1e3)); } constexpr XTAL operator ""_MHz_XTAL(long double clock) { return XTAL(double(clock * 1e6)); } -#endif // MAME_EMU_DRIVERS_XTAL_H +constexpr XTAL operator ""_Hz_XTAL(unsigned long long clock) { return XTAL(double(clock)); } +constexpr XTAL operator ""_kHz_XTAL(unsigned long long clock) { return XTAL(double(clock) * 1e3); } +constexpr XTAL operator ""_MHz_XTAL(unsigned long long clock) { return XTAL(double(clock) * 1e6); } + +#endif // MAME_EMU_XTAL_H