commit: a4142c1b32cc2b47230c0fe52a23976adce8dde4 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Sun Jun 30 14:10:57 2024 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Sun Jun 30 14:11:36 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a4142c1b
dev-python/crc32c: Fix signedness issue that broke SPARC Closes: https://bugs.gentoo.org/926961 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> dev-python/crc32c/crc32c-2.4.ebuild | 5 ++++ dev-python/crc32c/files/crc32c-2.4-sparc.patch | 34 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/dev-python/crc32c/crc32c-2.4.ebuild b/dev-python/crc32c/crc32c-2.4.ebuild index 6e0a4600dea6..4c4574350b5f 100644 --- a/dev-python/crc32c/crc32c-2.4.ebuild +++ b/dev-python/crc32c/crc32c-2.4.ebuild @@ -23,6 +23,11 @@ IUSE="cpu_flags_arm_crc32 cpu_flags_x86_sse4_2" distutils_enable_tests pytest +PATCHES=( + # https://github.com/ICRAR/crc32c/pull/44 + "${FILESDIR}/${P}-sparc.patch" +) + python_test() { local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 local -x CRC32C_SW_MODE diff --git a/dev-python/crc32c/files/crc32c-2.4-sparc.patch b/dev-python/crc32c/files/crc32c-2.4-sparc.patch new file mode 100644 index 000000000000..f2e96638d51b --- /dev/null +++ b/dev-python/crc32c/files/crc32c-2.4-sparc.patch @@ -0,0 +1,34 @@ +From 9d94ecbfe2363c7adf49bddbf31871764faf4f41 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]> +Date: Sun, 30 Jun 2024 16:00:34 +0200 +Subject: [PATCH] Fix char signedness issue in _crc32c_sw_slicing_by_8() + +Fix `_crc32c_sw_slicing_by_8()` to use `unsigned char` for `p_buf`, +to fix incorrect results on platforms with signed `char` such as SPARC. +The code has been casting `unsigned char *` to `char *` for no apparent +reason, and this broke the bitshifts in the big endian blocks. + +Particularly, + + crc ^= *(p_buf++) << 16 + +would be XOR-ed against `0xffee0000` rather than `0x00ee0000`. + +Fixes #43 +--- + crc32c_sw.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/crc32c_sw.c b/crc32c_sw.c +index 8382749..67409c9 100644 +--- a/crc32c_sw.c ++++ b/crc32c_sw.c +@@ -490,7 +490,7 @@ const uint32_t crc_tableil8_o88[256] = + + uint32_t _crc32c_sw_slicing_by_8(uint32_t crc, unsigned const char* data, unsigned long length) + { +- const char* p_buf = (const char*) data; ++ unsigned const char* p_buf = data; + size_t initial_bytes = (sizeof(uint32_t) - (intptr_t)p_buf) & (sizeof(uint32_t) - 1); + size_t li; + size_t running_length;
