From 17e5f1ea4a2e1c5664f96480ca46348d008e8711 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Fri, 10 May 2024 00:01:14 +0100 Subject: gentoo auto-resync : 10:05:2024 - 00:01:13 --- dev-util/rgbds/Manifest | 4 +- .../rgbds/files/rgbds-0.7.0-fix-nan-tests.patch | 147 +++++++++++++++++++++ dev-util/rgbds/rgbds-0.7.0-r1.ebuild | 55 ++++++++ dev-util/rgbds/rgbds-9999.ebuild | 1 + 4 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 dev-util/rgbds/files/rgbds-0.7.0-fix-nan-tests.patch create mode 100644 dev-util/rgbds/rgbds-0.7.0-r1.ebuild (limited to 'dev-util/rgbds') diff --git a/dev-util/rgbds/Manifest b/dev-util/rgbds/Manifest index bd5867cd1dc8..e2430f7e9570 100644 --- a/dev-util/rgbds/Manifest +++ b/dev-util/rgbds/Manifest @@ -1,6 +1,8 @@ +AUX rgbds-0.7.0-fix-nan-tests.patch 5256 BLAKE2B 8a0f21f992ff526fd8abc1f34d80518217255375921ccc69672a57a2bb30681a94a5aa42d9a58c8bfe90eeeeadb3b70bbf97a15277c5e8e8a27be1b57ba34935 SHA512 6ad1db1c35f5952cbffe1e59551f6a58d6cbf0230e6501749cf36ffddb8b112f1abd02990876d116ac393dcad39d3ecdbb239e98b3c6b5357ff4bafac328ef24 DIST rgbds-0.6.1.tar.gz 8041890 BLAKE2B cd5483e6fa5e2ca3bc9a6e3de44fdf7dc92289d558ac72d8922c0cf21b9dc576b878bfd7610cb41f791ad16cc415e446c925ee0dbc77ec4370d6ef4549935681 SHA512 b4a111e3d98a190d3c9b500dc59585fe68a8e6febc79b6716b406b96714e401bac427336388409ae456ee0f1e5a2c285bfe7b4bfa10e0d148ffc161adefe435b DIST rgbds-0.7.0.tar.gz 8053662 BLAKE2B 07f6901eeaade45125acce5c33430bdefc5a4228d2fe952d55ca254c0fc17dc5248262ecc7df5e9dd0a73aab29a39a2b38988a7ae93ad739609397a286e96aa9 SHA512 82d799f9639cb3a4c110f84f5184f46a371e66428e7d3b4f3f0229473d472dea1b381268df92736f2d1d4f5e8e2c83b61888c3ab4055768f9472b834f66f2f68 EBUILD rgbds-0.6.1.ebuild 816 BLAKE2B 7992f7590f30bd809b3b5551b52ce2fe8f28e031d7a931373952717a6c20b8014e2f8a2d3b66ae9aa8e87e1ba5bb84c85063cf1ab7e4be569a395f72b88b71db SHA512 f7305129d91c25e6fc1d704e2a1bd147201a711225817293007f238943ef30eb4e033a5d4f41a962360b3b190ae11183d944fe49009226cfd747cf3f593439f2 +EBUILD rgbds-0.7.0-r1.ebuild 1085 BLAKE2B 6df90750b7deb7e97466479365fc9262e5bcad793fc685e2185c4be8355e76aed64ec4ed73c0d8b5ca8e01b54a3a5d8693d8ec21188434d7351ef33cc655f796 SHA512 650b4d190b14a9f9a68de6d19828a89b2d5ba21a287c09f6b95c878ff4f4c3f0053a325e78b0adf54d7b4b200e34db762133b520a094d9ae5d6ebf57ecc93745 EBUILD rgbds-0.7.0.ebuild 966 BLAKE2B ab4ce0569be9f791bfe882a45df513040009f288f06d1e7836f37de2036dabc479b6089ecf29cffe9841c942de4fd1e97718984f79aa5a15821484b6e6af872c SHA512 1de7867d3a995ec2ce9b014efcfe32590b1d1f23fa7d3c48d9ac2932bdf5f25dcfd8568639ae6ed52ff113ef2c74ab86518269d697170177cfd6a6e4339f8328 -EBUILD rgbds-9999.ebuild 965 BLAKE2B 2d7a09fbc6b74045afb0d6b28bfbe97cdbeac75e7bb7ef40b3eb6db5749df6eac1f0b7fb069057529a9346b89e243afab66ce58c79a9ea3f3f4ad3c0b7aefc05 SHA512 accf0283238ec15cc9770e8d1ed4c805fe50d1516a9165fd643a0027b23d8a66ec871b5078bc89f42dc41df0ea22595c0921f534028bc7b4eeedf6fe3dee1dd0 +EBUILD rgbds-9999.ebuild 997 BLAKE2B a00f08315ce37800a64e64ceb1fca7cdb00a10ad2f3799a577db5122940f598824df666836112bf6b11559b0129ad9494b901a12afc51494f6e849f270908d62 SHA512 eca845312232f4c3aafbefb161a30ae4b566ff0b91b6d577063777484ec73ebd9ad4d48c1fc880c4979228c4e63de50e8b46d147adef61df716b4215e3b3ab0f MISC metadata.xml 682 BLAKE2B cf9153f0ca5faaefa518fd7300d4107d3eb4770f8471ccbaf90bfb8ca6397c3387b970b4ed97a8c5ea78695f168be3265d6e3bf84fa67dcef4ba214cd7f7bd3e SHA512 b4810cc1b6c4b9b557a11e0b172520bf0d74fd2874c6557726e51a85e946ec9e60ba4952e2746f19de25f98b97918aab1fef7c7278956ab0d0f2f551d709e20f diff --git a/dev-util/rgbds/files/rgbds-0.7.0-fix-nan-tests.patch b/dev-util/rgbds/files/rgbds-0.7.0-fix-nan-tests.patch new file mode 100644 index 000000000000..9cee354a810e --- /dev/null +++ b/dev-util/rgbds/files/rgbds-0.7.0-fix-nan-tests.patch @@ -0,0 +1,147 @@ +https://bugs.gentoo.org/928268 +https://github.com/gbdev/rgbds/issues/1387 +https://github.com/gbdev/rgbds/pull/1388 +https://github.com/gbdev/rgbds/commit/9ab3446d1a3d84d6b34062b8287be9169fbe663b + +From 1afbaa3cf2b667c33ae02e899ad7a833e3b71292 Mon Sep 17 00:00:00 2001 +From: Sylvie <35663410+Rangi42@users.noreply.github.com> +Date: Sun, 31 Mar 2024 12:53:20 -0400 +Subject: [PATCH] Fix two bugs with RGBASM fixed-point math (#1388) + +- Fixed-point formulas are implemented using IEEE-754 floating-point + internally, which could give infinity or NaN values whose conversion + to fixed-point integer was platform-dependent. +- Formatting fixed-point $8000_0000 (INT32_MIN, -2147483648) was + not putting the negative sign in front. +--- + src/asm/fixpoint.cpp | 10 +++++++++- + src/asm/format.cpp | 22 +++++++++++++--------- + test/asm/format-extremes.asm | 8 ++++++++ + test/asm/format-extremes.out | 4 ++++ + test/asm/math.asm | 8 ++++++-- + 5 files changed, 40 insertions(+), 12 deletions(-) + create mode 100644 test/asm/format-extremes.asm + create mode 100644 test/asm/format-extremes.out + +diff --git a/src/asm/fixpoint.cpp b/src/asm/fixpoint.cpp +index 97a091af..9334bbba 100644 +--- a/src/asm/fixpoint.cpp ++++ b/src/asm/fixpoint.cpp +@@ -15,7 +15,6 @@ + #endif + + #define fix2double(i, q) ((double)((i) / pow(2.0, q))) +-#define double2fix(d, q) ((int32_t)round((d) * pow(2.0, q))) + + // 2*pi radians == 1 turn + #define turn2rad(f) ((f) * (M_PI * 2)) +@@ -33,6 +32,15 @@ double fix_PrecisionFactor(void) + return pow(2.0, fixPrecision); + } + ++static int32_t double2fix(double d, int32_t q) ++{ ++ if (isnan(d)) ++ return 0; ++ if (isinf(d)) ++ return d < 0 ? INT32_MIN : INT32_MAX; ++ return (int32_t)round(d * pow(2.0, q)); ++} ++ + int32_t fix_Sin(int32_t i, int32_t q) + { + return double2fix(sin(turn2rad(fix2double(i, q))), q); +diff --git a/src/asm/format.cpp b/src/asm/format.cpp +index 553e5c77..2b8b8a8a 100644 +--- a/src/asm/format.cpp ++++ b/src/asm/format.cpp +@@ -180,11 +180,10 @@ void fmt_PrintNumber(char *buf, size_t bufLen, struct FormatSpec const *fmt, uin + char sign = fmt->sign; // 0 or ' ' or '+' + + if (fmt->type == 'd' || fmt->type == 'f') { +- int32_t v = value; +- +- if (v < 0 && v != INT32_MIN) { ++ if (int32_t v = value; v < 0) { + sign = '-'; +- value = -v; ++ if (v != INT32_MIN) ++ value = -v; + } + } + +@@ -229,15 +228,20 @@ void fmt_PrintNumber(char *buf, size_t bufLen, struct FormatSpec const *fmt, uin + fracWidth = 255; + } + +- snprintf(valueBuf, sizeof(valueBuf), "%.*f", (int)fracWidth, +- value / fix_PrecisionFactor()); ++ double fval = fabs(value / fix_PrecisionFactor()); ++ snprintf(valueBuf, sizeof(valueBuf), "%.*f", (int)fracWidth, fval); ++ } else if (fmt->type == 'd') { ++ // Decimal numbers may be formatted with a '-' sign by `snprintf`, so `abs` prevents that, ++ // with a special case for `INT32_MIN` since `labs(INT32_MIN)` is UB. The sign will be ++ // printed later from `signChar`. ++ uint32_t uval = value != (uint32_t)INT32_MIN ? labs((int32_t)value) : value; ++ snprintf(valueBuf, sizeof(valueBuf), "%" PRIu32, uval); + } else { +- char const *spec = fmt->type == 'd' ? "%" PRId32 +- : fmt->type == 'u' ? "%" PRIu32 ++ char const *spec = fmt->type == 'u' ? "%" PRIu32 + : fmt->type == 'X' ? "%" PRIX32 + : fmt->type == 'x' ? "%" PRIx32 + : fmt->type == 'o' ? "%" PRIo32 +- : "%" PRId32; ++ : "%" PRIu32; + + snprintf(valueBuf, sizeof(valueBuf), spec, value); + } +diff --git a/test/asm/format-extremes.asm b/test/asm/format-extremes.asm +new file mode 100644 +index 00000000..19ddb677 +--- /dev/null ++++ b/test/asm/format-extremes.asm +@@ -0,0 +1,8 @@ ++MACRO test ++ def v = \1 ++ println "{#09x:v} = {#012o:v} = {#033b:v} = {u:v}U = {+d:v} = {+.16f:v}" ++ENDM ++ test $7fff_ffff ; INT32_MAX ++ test $8000_0000 ; INT32_MIN ++ test $0000_0000 ; UINT32_MIN ++ test $ffff_ffff ; UINT32_MAX +diff --git a/test/asm/format-extremes.out b/test/asm/format-extremes.out +new file mode 100644 +index 00000000..9e19b2f4 +--- /dev/null ++++ b/test/asm/format-extremes.out +@@ -0,0 +1,4 @@ ++$7fffffff = &17777777777 = %01111111111111111111111111111111 = 2147483647U = +2147483647 = +32767.9999847412109375 ++$80000000 = &20000000000 = %10000000000000000000000000000000 = 2147483648U = -2147483648 = -32768.0000000000000000 ++$00000000 = &00000000000 = %00000000000000000000000000000000 = 0U = +0 = +0.0000000000000000 ++$ffffffff = &37777777777 = %11111111111111111111111111111111 = 4294967295U = -1 = -0.0000152587890625 +diff --git a/test/asm/math.asm b/test/asm/math.asm +index b189fca8..9f87a11b 100644 +--- a/test/asm/math.asm ++++ b/test/asm/math.asm +@@ -19,14 +19,18 @@ ENDM + + assert DIV(5.0, 2.0) == 2.5 + assert DIV(-5.0, 2.0) == -2.5 +- assert DIV(-5.0, 0.0) == $8000_0000 ++ assert DIV(5.0, 0.0) == $7fff_ffff ; +inf => INT32_MAX ++ assert DIV(-5.0, 0.0) == $8000_0000 ; -inf => INT32_MIN ++ assert DIV(0.0, 0.0) == $0000_0000 ; nan => 0 + + assert MUL(10.0, 0.5) == 5.0 + assert MUL(10.0, 0.0) == 0.0 + + assert FMOD(5.0, 2.0) == 1.0 + assert FMOD(-5.0, 2.0) == -1.0 +- assert FMOD(-5.0, 0.0) == $8000_0000 ++ assert FMOD(5.0, 0.0) == 0 ; nan ++ assert FMOD(-5.0, 0.0) == 0 ; nan ++ assert FMOD(0.0, 0.0) == 0 ; nan + + assert POW(10.0, 2.0) == 100.0 + assert POW(100.0, 0.5) == 10.0 diff --git a/dev-util/rgbds/rgbds-0.7.0-r1.ebuild b/dev-util/rgbds/rgbds-0.7.0-r1.ebuild new file mode 100644 index 000000000000..052429ca8c57 --- /dev/null +++ b/dev-util/rgbds/rgbds-0.7.0-r1.ebuild @@ -0,0 +1,55 @@ +# Copyright 2022-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit flag-o-matic toolchain-funcs + +DESCRIPTION="Rednex Game Boy Development System" +HOMEPAGE="https://rgbds.gbdev.io/" +if [[ "${PV}" == *9999 ]] ; then + inherit git-r3 + EGIT_REPO_URI="https://github.com/gbdev/${PN}.git" +else + SRC_URI="https://github.com/gbdev/${PN}/archive/v${PV}/${P}.tar.gz" + KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86" +fi + +LICENSE="MIT" +SLOT="0" + +DEPEND="media-libs/libpng" +RDEPEND="${DEPEND}" +BDEPEND=" + sys-devel/bison + virtual/pkgconfig +" + +PATCHES=( + # https://bugs.gentoo.org/928268 + "${FILESDIR}"/${P}-fix-nan-tests.patch +) + +src_compile() { + append-flags -DNDEBUG + + emake Q= \ + CC="$(tc-getCC)" \ + CXX="$(tc-getCXX)" \ + PKG_CONFIG="$(tc-getPKG_CONFIG)" +} + +src_test() { + local dir + for dir in asm link fix gfx; do + pushd "test/${dir}" >/dev/null || die + einfo "Running ${dir} tests." + ./test.sh || die + popd >/dev/null || die + done +} + +src_install() { + emake DESTDIR="${D}" PREFIX="${EPREFIX}"/usr Q= STRIP= install + dodoc README.rst +} diff --git a/dev-util/rgbds/rgbds-9999.ebuild b/dev-util/rgbds/rgbds-9999.ebuild index 0a79e0043a34..7f24c27d44dd 100644 --- a/dev-util/rgbds/rgbds-9999.ebuild +++ b/dev-util/rgbds/rgbds-9999.ebuild @@ -38,6 +38,7 @@ src_test() { local dir for dir in asm link fix gfx; do pushd "test/${dir}" >/dev/null || die + einfo "Running ${dir} tests." ./test.sh || die popd >/dev/null || die done -- cgit v1.2.3