Add libbutl lz4 patch

libbutl bundles lz4[1] and builds it as an amalgamated translation unit in
lz4.cxx, but there is a conflicting typdef unalign in lz4.c and xxhash.c. This
patch [2] renames the lz4.c typedef to not conflict with that defined in
xxhash.c. See also the upstream issue [3].

 * build2.spec: add libbutl lz4 patch to Patches and apply during %setup
 * libbutl-lz4-typdef-unalign.patch: add libbutl lz4 patch

[1] https://github.com/lz4/lz4
[2] https://git.build2.org/cgit/libbutl/commit/?id=23c07078a9f2790b96a6ee6a6183911aaec71533
[3] https://github.com/lz4/lz4/issues/1053
This commit is contained in:
Matthew Krupcale 2022-01-27 20:49:36 -05:00
parent d48191929d
commit 4cc4bb9c97
2 changed files with 42 additions and 0 deletions

View File

@ -34,6 +34,8 @@ Patch0000: libbuild2-config.install.scope-no-update-for-install.patch
Patch0100: build2-disable-test-cc-modules-ppc64le.patch
# Upstream https://git.build2.org/cgit/libbutl/commit/?id=c6ea3d784ee920f51de3088437b471c8dd6d70e2
Patch1000: libbutl-openssl-info-overloads.patch
# Upstream https://git.build2.org/cgit/libbutl/commit/?id=23c07078a9f2790b96a6ee6a6183911aaec71533
Patch1001: libbutl-lz4-typdef-unalign.patch
# Upstream https://git.build2.org/cgit/bpkg/commit/?id=073f4ed111b0b10dcbd81fc112f9d66e41f40fac
Patch3000: bpkg-openssl-3-pkeyutl.patch
@ -274,6 +276,7 @@ pushd %{name}-%{version}
popd
pushd libbutl-%{version}
%patch -p 1 -P 1000
%patch -p 1 -P 1001
popd
pushd bpkg-%{version}
%patch -p 1 -P 3000

View File

@ -0,0 +1,39 @@
From 23c07078a9f2790b96a6ee6a6183911aaec71533 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov <boris@codesynthesis.com>
Date: Tue, 25 Jan 2022 15:24:25 +0200
Subject: Rename unalign to LZ4_unalign in lz4.c not to clash with unalign in
xxhash.c
Upstream issue 1053.
---
libbutl/lz4.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libbutl/lz4.c b/libbutl/lz4.c
index eac0541..3f0e430 100644
--- a/libbutl/lz4.c
+++ b/libbutl/lz4.c
@@ -343,14 +343,14 @@ static void LZ4_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
/* currently only defined for gcc and icc */
-typedef union { U16 u16; U32 u32; reg_t uArch; } __attribute__((packed)) unalign;
+typedef union { U16 u16; U32 u32; reg_t uArch; } __attribute__((packed)) LZ4_unalign;
-static U16 LZ4_read16(const void* ptr) { return ((const unalign*)ptr)->u16; }
-static U32 LZ4_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
-static reg_t LZ4_read_ARCH(const void* ptr) { return ((const unalign*)ptr)->uArch; }
+static U16 LZ4_read16(const void* ptr) { return ((const LZ4_unalign*)ptr)->u16; }
+static U32 LZ4_read32(const void* ptr) { return ((const LZ4_unalign*)ptr)->u32; }
+static reg_t LZ4_read_ARCH(const void* ptr) { return ((const LZ4_unalign*)ptr)->uArch; }
-static void LZ4_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
-static void LZ4_write32(void* memPtr, U32 value) { ((unalign*)memPtr)->u32 = value; }
+static void LZ4_write16(void* memPtr, U16 value) { ((LZ4_unalign*)memPtr)->u16 = value; }
+static void LZ4_write32(void* memPtr, U32 value) { ((LZ4_unalign*)memPtr)->u32 = value; }
#else /* safe and portable access using memcpy() */
--
cgit v1.1