mame: work around long double on powerpc64

On powerpc64 the long double type is special in that it does not permit
a constexpr return type for a function where a long double constant and
a double constant are multiplied. Yet this is what the MAME _MHz_XTAL and
_GHz_XTAL constexpr suffixes on numbers expect from the multiplication
of a long double value with 1e6 or 1e9 respectively.

To make the code compile, knowing it will produce differing results for
e.g. 6'144'000_Hz_XTAL and 6.144_MHz_XTAL, cast the long double constant
down to double before multiplying by 1e6 or 1e9.

Do this iff the preprocessor macro _GLIBCXX_LONG_DOUBLE_COMPAT is defined.
This commit is contained in:
Jürgen Buchmüller 2020-12-31 14:11:49 +01:00
parent 3cd0d74422
commit 8d95441bcf

View file

@ -0,0 +1,16 @@
--- src/emu/xtal.h 2020-12-30 16:46:10.000000000 +0100
+++ src/emu/xtal.h 2020-12-31 13:41:51.679447004 +0100
@@ -81,8 +81,13 @@
constexpr XTAL operator *(double mult, const XTAL &xtal) { return XTAL(xtal.base(), mult * xtal.dvalue()); }
constexpr XTAL operator ""_Hz_XTAL(long double clock) { return XTAL(double(clock)); }
+#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
+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); }
+#else
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
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); }