commit:     32f70be06d68b63c63e6c2bd704bf943a62f25df
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 27 15:47:47 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 27 15:47:47 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=32f70be0

dev-libs/nanomsg: fix chunking

Pull in a patch which upstream have acked on the upstream bug but
not yet merged/put in a release. This fixes criterion's testsuite.

Thanks to matoro and emily.

Closes: https://bugs.gentoo.org/934665
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-libs/nanomsg/files/nanomsg-1.2.1-chunk.patch | 49 ++++++++++++++++++++++++
 dev-libs/nanomsg/nanomsg-1.2.1-r1.ebuild         | 40 +++++++++++++++++++
 2 files changed, 89 insertions(+)

diff --git a/dev-libs/nanomsg/files/nanomsg-1.2.1-chunk.patch 
b/dev-libs/nanomsg/files/nanomsg-1.2.1-chunk.patch
new file mode 100644
index 000000000000..7d6cec725939
--- /dev/null
+++ b/dev-libs/nanomsg/files/nanomsg-1.2.1-chunk.patch
@@ -0,0 +1,49 @@
+https://bugs.gentoo.org/934665
+https://github.com/nanomsg/nanomsg/issues/1111#issuecomment-2113151297
+(acked by upstream at 
https://github.com/nanomsg/nanomsg/issues/1111#issuecomment-2305516234)
+
+--- a/src/utils/chunkref.c
++++ b/src/utils/chunkref.c
+@@ -52,6 +52,7 @@
+ {
+     if (self->size == NN_CHUNKREF_EXT) {
+         nn_chunk_free (self->u.chunk);
++        self->size = 0;
+     }
+ }
+ 
+@@ -80,6 +81,8 @@
+     dst->size = src->size;
+     if (src->size == NN_CHUNKREF_EXT) {
+         dst->u.chunk = src->u.chunk;
++        // self->u.chunk = NULL;
++        // src->size = 0;
+     } else {
+         nn_assert (src->size <= NN_CHUNKREF_MAX);
+         memcpy (dst->u.ref, src->u.ref, src->size);
+@@ -100,7 +103,7 @@
+ 
+ void *nn_chunkref_data (struct nn_chunkref *self)
+ {
+-    if (self->size > NN_CHUNKREF_MAX) {
++    if (self->size == NN_CHUNKREF_EXT) {
+         return self->u.chunk;
+     } else {
+         return self->u.ref;
+@@ -109,7 +112,7 @@
+ 
+ size_t nn_chunkref_size (struct nn_chunkref *self)
+ {
+-    if (self->size > NN_CHUNKREF_MAX) {
++    if (self->size == NN_CHUNKREF_EXT) {
+         return (nn_chunk_size(self->u.chunk));
+     }
+     return self->size;
+@@ -118,7 +121,7 @@
+ void nn_chunkref_trim (struct nn_chunkref *self, size_t n)
+ {
+     if (self->size == NN_CHUNKREF_EXT) {
+-        nn_chunk_trim (self->u.chunk, n);
++        self->u.chunk = nn_chunk_trim(self->u.chunk, n);
+         return;
+     }

diff --git a/dev-libs/nanomsg/nanomsg-1.2.1-r1.ebuild 
b/dev-libs/nanomsg/nanomsg-1.2.1-r1.ebuild
new file mode 100644
index 000000000000..d99d9f30243a
--- /dev/null
+++ b/dev-libs/nanomsg/nanomsg-1.2.1-r1.ebuild
@@ -0,0 +1,40 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit cmake
+
+DESCRIPTION="High-performance messaging interface for distributed applications"
+HOMEPAGE="https://nanomsg.org/";
+SRC_URI="https://github.com/nanomsg/nanomsg/archive/${PV}.tar.gz -> 
${P}.tar.gz"
+
+LICENSE="MIT"
+SLOT="0/6.0.1"
+KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~riscv x86"
+IUSE="doc"
+
+BDEPEND="doc? ( dev-ruby/asciidoctor )"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-1.2.1-chunk.patch
+)
+
+src_prepare() {
+       # Old CPUs like HPPA fails test because of timeout
+       sed -i \
+               -e '/inproc_shutdown/s/10/80/' \
+               -e '/ws_async_shutdown/s/10/80/' \
+               -e '/ipc_shutdown/s/40/80/' CMakeLists.txt || die
+
+       cmake_src_prepare
+}
+
+src_configure() {
+       local mycmakeargs=(
+               -DNN_STATIC_LIB=OFF
+               -DNN_ENABLE_DOC=$(usex doc)
+       )
+
+       cmake_src_configure
+}

Reply via email to