From 8d95441bcf9291ef98cc04dda32cb7caa883703a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Buchm=C3=BCller?= Date: Thu, 31 Dec 2020 14:11:49 +0100 Subject: [PATCH] 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. --- srcpkgs/mame/patches/ppc-long_double.patch | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 srcpkgs/mame/patches/ppc-long_double.patch diff --git a/srcpkgs/mame/patches/ppc-long_double.patch b/srcpkgs/mame/patches/ppc-long_double.patch new file mode 100644 index 00000000000..a01fa1000f2 --- /dev/null +++ b/srcpkgs/mame/patches/ppc-long_double.patch @@ -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); }