Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-arch/pixz/, app-arch/pixz/files/
Date: Mon, 02 Sep 2019 07:22:31
Message-Id: 1567408855.08b6896e6345db4ceb83e1718123e956522b4c27.mattst88@gentoo
1 commit: 08b6896e6345db4ceb83e1718123e956522b4c27
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Mon Sep 2 07:20:45 2019 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Mon Sep 2 07:20:55 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=08b6896e
7
8 app-arch/pixz: Avoid unaligned accesses
9
10 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
11
12 .../pixz-1.0.6-avoid-unaligned-accesses.patch | 44 ++++++++++++++++++++++
13 .../{pixz-1.0.6.ebuild => pixz-1.0.6-r1.ebuild} | 4 ++
14 2 files changed, 48 insertions(+)
15
16 diff --git a/app-arch/pixz/files/pixz-1.0.6-avoid-unaligned-accesses.patch b/app-arch/pixz/files/pixz-1.0.6-avoid-unaligned-accesses.patch
17 new file mode 100644
18 index 00000000000..24c53c9acc4
19 --- /dev/null
20 +++ b/app-arch/pixz/files/pixz-1.0.6-avoid-unaligned-accesses.patch
21 @@ -0,0 +1,44 @@
22 +https://github.com/vasi/pixz/pull/82
23 +
24 +From 8b9a198d86e435929ed0c2246217d241ed1e707c Mon Sep 17 00:00:00 2001
25 +From: Matt Turner <mattst88@×××××.com>
26 +Date: Sun, 1 Sep 2019 23:58:26 -0700
27 +Subject: [PATCH] Avoid unaligned accesses
28 +
29 +Architectures like SPARC do not allow unaligned accesses. Avoid them by
30 +memcpy()ing the data to an aligned buffer. On x86 systems where
31 +unaligned loads are fast, the memcpy() will be compiled away and the
32 +same code generated as before.
33 +---
34 + src/endian.c | 8 ++++++--
35 + 1 file changed, 6 insertions(+), 2 deletions(-)
36 +
37 +diff --git a/src/endian.c b/src/endian.c
38 +index 51aea58..122c7da 100644
39 +--- a/src/endian.c
40 ++++ b/src/endian.c
41 +@@ -13,6 +13,7 @@ void xle64enc(uint8_t *d, uint64_t n) {
42 + #elif defined(__linux__) || defined(__FreeBSD__)
43 +
44 + #include <stdint.h>
45 ++#include <string.h>
46 + #ifdef __linux__
47 + #include <endian.h>
48 + #include <byteswap.h>
49 +@@ -37,11 +38,14 @@ void xle64enc(uint8_t *d, uint64_t n) {
50 + #endif
51 +
52 + uint64_t xle64dec(const uint8_t *d) {
53 +- return le64toh(*(uint64_t*)d);
54 ++ uint64_t tmp;
55 ++ memcpy(&tmp, d, sizeof(tmp));
56 ++ return le64toh(tmp);
57 + }
58 +
59 + void xle64enc(uint8_t *d, uint64_t n) {
60 +- *(uint64_t*)d = htole64(n);
61 ++ uint64_t tmp = htole64(n);
62 ++ memcpy(d, &tmp, sizeof(tmp));
63 + }
64 +
65 + #else
66
67 diff --git a/app-arch/pixz/pixz-1.0.6.ebuild b/app-arch/pixz/pixz-1.0.6-r1.ebuild
68 similarity index 94%
69 rename from app-arch/pixz/pixz-1.0.6.ebuild
70 rename to app-arch/pixz/pixz-1.0.6-r1.ebuild
71 index f4bb78275ca..7e207659629 100644
72 --- a/app-arch/pixz/pixz-1.0.6.ebuild
73 +++ b/app-arch/pixz/pixz-1.0.6-r1.ebuild
74 @@ -27,6 +27,10 @@ DEPEND="${RDEPEND}
75 static? ( ${LIB_DEPEND} )"
76 [[ ${PV} == "9999" ]] && DEPEND+=" app-text/asciidoc"
77
78 +PATCHES=(
79 + "${FILESDIR}"/${P}-avoid-unaligned-accesses.patch
80 +)
81 +
82 src_prepare() {
83 default
84 [[ ${PV} == "9999" ]] && eautoreconf