commit: 0a662a6a35bff692c5b7fbad7cee6a8ea2f8ce09 Author: Petr Vaněk <arkamar <AT> gentoo <DOT> org> AuthorDate: Tue Oct 1 08:44:21 2024 +0000 Commit: Petr Vaněk <arkamar <AT> gentoo <DOT> org> CommitDate: Tue Oct 1 09:34:08 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0a662a6a
games-arcade/jazz2: apply strict aliasing fix Closes: https://bugs.gentoo.org/940326 Signed-off-by: Petr Vaněk <arkamar <AT> gentoo.org> .../jazz2/files/jazz2-2.8.0-strict-aliasing.patch | 33 ++++++++++++++++++++++ .../{jazz2-2.8.0.ebuild => jazz2-2.8.0-r1.ebuild} | 1 + 2 files changed, 34 insertions(+) diff --git a/games-arcade/jazz2/files/jazz2-2.8.0-strict-aliasing.patch b/games-arcade/jazz2/files/jazz2-2.8.0-strict-aliasing.patch new file mode 100644 index 000000000000..1c727478e1d5 --- /dev/null +++ b/games-arcade/jazz2/files/jazz2-2.8.0-strict-aliasing.patch @@ -0,0 +1,33 @@ +From ac7e3bf7237c12ac5a43fef52d42d31779cd62f6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20Van=C4=9Bk?= <arka...@atlas.cz> +Date: Mon, 30 Sep 2024 09:54:56 +0200 +Subject: [PATCH] Use union for int-float type conversion + +Union based type punning seems to be safer for int-float type conversion +as it works around strict aliasing rules, which improves portability. + +PR: https://github.com/deathkiller/jazz2-native/pull/80 + +diff --git a/Sources/nCine/Base/Algorithms.cpp b/Sources/nCine/Base/Algorithms.cpp +index 99fa88bf..e7805fda 100644 +--- a/Sources/nCine/Base/Algorithms.cpp ++++ b/Sources/nCine/Base/Algorithms.cpp +@@ -247,12 +247,16 @@ namespace nCine + + static inline std::uint32_t as_uint32(const float x) + { +- return *(std::uint32_t*)&x; ++ union {float f; uint32_t i;} u; ++ u.f = x; ++ return u.i; + } + + static inline float as_float(const std::uint32_t x) + { +- return *(float*)&x; ++ union {float f; uint32_t i;} u; ++ u.i = x; ++ return u.f; + } + + float halfToFloat(std::uint16_t value) diff --git a/games-arcade/jazz2/jazz2-2.8.0.ebuild b/games-arcade/jazz2/jazz2-2.8.0-r1.ebuild similarity index 96% rename from games-arcade/jazz2/jazz2-2.8.0.ebuild rename to games-arcade/jazz2/jazz2-2.8.0-r1.ebuild index bcc62ab10108..2293ae2aff09 100644 --- a/games-arcade/jazz2/jazz2-2.8.0.ebuild +++ b/games-arcade/jazz2/jazz2-2.8.0-r1.ebuild @@ -34,6 +34,7 @@ RDEPEND="${DEPEND}" PATCHES=( "${FILESDIR}/${P}-about-section.patch" + "${FILESDIR}/${P}-strict-aliasing.patch" #940326 ) src_prepare() {