Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package nanomsg for openSUSE:Factory checked in at 2024-02-05 22:01:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/nanomsg (Old) and /work/SRC/openSUSE:Factory/.nanomsg.new.1815 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "nanomsg" Mon Feb 5 22:01:34 2024 rev:8 rq:1144127 version:1.2.1 Changes: -------- --- /work/SRC/openSUSE:Factory/nanomsg/nanomsg.changes 2022-12-06 14:23:27.957673152 +0100 +++ /work/SRC/openSUSE:Factory/.nanomsg.new.1815/nanomsg.changes 2024-02-05 22:01:45.968240329 +0100 @@ -1,0 +2,6 @@ +Sun Feb 4 17:03:18 UTC 2024 - Andreas Stieger <[email protected]> + +- update to 1.2.1: + * Fix SIGBUS on some platforms due to misaligned access + +------------------------------------------------------------------- Old: ---- nanomsg-1.2.tar.gz New: ---- nanomsg-1.2.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ nanomsg.spec ++++++ --- /var/tmp/diff_new_pack.3AKdkv/_old 2024-02-05 22:01:46.576262325 +0100 +++ /var/tmp/diff_new_pack.3AKdkv/_new 2024-02-05 22:01:46.576262325 +0100 @@ -2,6 +2,7 @@ # spec file for package nanomsg # # Copyright (c) 2022 SUSE LLC +# Copyright (c) 2024 Andreas Stieger <[email protected]> # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +19,7 @@ %define sover 6 Name: nanomsg -Version: 1.2 +Version: 1.2.1 Release: 0 Summary: Socket library providing several common communication patterns License: MIT @@ -51,18 +52,19 @@ Development and header files for nanomsg. %prep -%setup -q -%patch0 -p1 +%autosetup -p1 %build %cmake -make %{?_smp_mflags} +%make_build %install %cmake_install -%post -n libnanomsg%{sover} -p /sbin/ldconfig -%postun -n libnanomsg%{sover} -p /sbin/ldconfig +%check +%ctest + +%ldconfig_scriptlets -n libnanomsg%{sover} %files -n libnanomsg%{sover} %license COPYING @@ -70,11 +72,10 @@ %{_libdir}/libnanomsg.so.* %files devel +%license COPYING %{_includedir}/nanomsg %{_libdir}/libnanomsg.so %{_bindir}/nanocat %{_libdir}/pkgconfig/nanomsg.pc -%dir %{_libdir}/cmake/nanomsg-1.1.5 -%{_libdir}/cmake/nanomsg-1.1.5/nanomsg-config*.cmake -%{_libdir}/cmake/nanomsg-1.1.5/nanomsg-target*.cmake +%{_libdir}/cmake/nanomsg-* ++++++ nanomsg-1.2.tar.gz -> nanomsg-1.2.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/.circleci/build-and-test.sh new/nanomsg-1.2.1/.circleci/build-and-test.sh --- old/nanomsg-1.2/.circleci/build-and-test.sh 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/.circleci/build-and-test.sh 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ -#!/bin/bash - -# -# common build & test steps for CircleCI jobs -# - -uname -a -cmake --version -ninja --version - -mkdir build -cd build -cmake -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Debug} -DNN_ENABLE_COVERAGE=${COVERAGE:-OFF} .. -ninja -env CTEST_OUTPUT_ON_FAILURE=1 ninja test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/.circleci/codecov.sh new/nanomsg-1.2.1/.circleci/codecov.sh --- old/nanomsg-1.2/.circleci/codecov.sh 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/.circleci/codecov.sh 1970-01-01 01:00:00.000000000 +0100 @@ -1,20 +0,0 @@ -#!/bin/bash - -# Copyright 2018 Garrett D'Amore <[email protected]> -# Copyright 2018 Capitar IT Group BV <[email protected]> -# -# This software is supplied under the terms of the MIT License, a -# copy of which should be located in the distribution where this -# file was obtained (LICENSE.txt). A copy of the license may also be -# found online at https://opensource.org/licenses/MIT. - -if [ "${COVERAGE}" != ON ] -then - echo "Code coverage not enabled." - exit 0 -fi - -GCOV=${GCOV:-gcov} - -bash <(curl -s https://codecov.io/bash) -x ${GCOV} || echo "Codecov did not collect coverage" -echo 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/.circleci/config.yml new/nanomsg-1.2.1/.circleci/config.yml --- old/nanomsg-1.2/.circleci/config.yml 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/.circleci/config.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,84 +0,0 @@ -# -# CircleCI 2.0 configuration. This was borrowed from NNG, but is adjusted -# for libnanomsg. (We don't need mbedTLS or use clang-format, for example.) -# -version: 2.0 -jobs: - "clang6 - build, test": - docker: - - image: ubuntu:16.04 - environment: - CC: clang-6.0 - CXX: clang++-6.0 - CTEST_OUTPUT_ON_FAILURE: 1 - steps: - - checkout - - run: apt-get update -qq - - run: apt-get install -y software-properties-common - - run: apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main" - - run: apt-get update -qq - - run: > - apt-get install -y --allow-unauthenticated - build-essential - asciidoctor - cmake - ninja-build - clang-6.0 - - run: ./.circleci/build-and-test.sh - - "gcc8 - build, test": - docker: - - image: ubuntu:16.04 - environment: - CC: gcc-8 - CXX: g++-8 - GCOV: gcov-8 - CTEST_OUTPUT_ON_FAILURE: 1 - steps: - - checkout - - run: apt-get update -qq - - run: apt-get install -y software-properties-common - - run: add-apt-repository ppa:ubuntu-toolchain-r/test - - run: apt-get update -qq - - run: > - apt-get install -y --allow-unauthenticated - build-essential - asciidoctor - cmake - ninja-build - gcc-8 - g++-8 - - run: ./.circleci/build-and-test.sh - - "gcc - coverage": - docker: - - image: ubuntu:16.04 - environment: - CC: gcc - CXX: g++ - COVERAGE: "ON" - GCOV: gcov - CTEST_OUTPUT_ON_FAILURE: 1 - steps: - - checkout - - run: apt-get update -qq - - run: apt-get install -y software-properties-common - - run: add-apt-repository ppa:ubuntu-toolchain-r/test - - run: apt-get update -qq - - run: > - apt-get install -y --allow-unauthenticated - build-essential - curl - asciidoctor - cmake - ninja-build - - run: ./.circleci/build-and-test.sh - - run: ./.circleci/codecov.sh - -workflows: - version: 2 - build_and_test: - jobs: - - "clang6 - build, test" - - "gcc8 - build, test" - - "gcc - coverage" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/.github/workflows/codeql.yml new/nanomsg-1.2.1/.github/workflows/codeql.yml --- old/nanomsg-1.2/.github/workflows/codeql.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/nanomsg-1.2.1/.github/workflows/codeql.yml 2024-02-03 23:45:24.000000000 +0100 @@ -0,0 +1,41 @@ +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: "41 13 * * 6" + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ cpp ] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{ matrix.language }}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/.version new/nanomsg-1.2.1/.version --- old/nanomsg-1.2/.version 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/.version 2024-02-03 23:45:24.000000000 +0100 @@ -1 +1 @@ -1.1.5 +1.2.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/README.md new/nanomsg-1.2.1/README.md --- old/nanomsg-1.2/README.md 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/README.md 2024-02-03 23:45:24.000000000 +0100 @@ -3,9 +3,9 @@ [](https://github.com/nanomsg/nanomsg/releases/latest) [](https://github.com/nanomsg/nanomsg/blob/master/COPYING) -[](https://github.com/nanomsg/nanomsg/actions/workflows/linux.yml) -[](https://github.com/nanomsg/nanomsg/actions/workflows/windows.yml) -[](https://github.com/nanomsg/nanomsg/actions/workflows/darwin.yml) +[](https://github.com/nanomsg/nanomsg/actions/workflows/linux.yml) +[](https://github.com/nanomsg/nanomsg/actions/workflows/windows.yml) +[](https://github.com/nanomsg/nanomsg/actions/workflows/darwin.yml) [](https://discord.com/channels/639573728212156478/639574516812742686) The nanomsg library is a simple high-performance implementation of several @@ -23,7 +23,7 @@ 1. Windows. * Windows Vista or newer (Windows XP and 2003 are *NOT* supported) * Microsoft Visual Studio 2010 (including C++) or newer, or mingw-w64. - (Specifically mingw and older Microsoft compilers are *NOT supported, + (Specifically mingw and older Microsoft compilers are *NOT* supported, and we do not test mingw-w64 at all, so YMMV.) * CMake 2.8.12 or newer, available in $PATH as `cmake` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/cmake/nanomsg-config.cmake.in new/nanomsg-1.2.1/cmake/nanomsg-config.cmake.in --- old/nanomsg-1.2/cmake/nanomsg-config.cmake.in 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/cmake/nanomsg-config.cmake.in 2024-02-03 23:45:24.000000000 +0100 @@ -24,11 +24,11 @@ ### General variables for project discovery/inspection set_and_check(@PROJECT_NAME@_INSTALL_PREFIX @PACKAGE_CMAKE_INSTALL_PREFIX@) -set_and_check(@PROJECT_NAME@_BINDIR @PACKAGE_CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@) -set_and_check(@PROJECT_NAME@_INCDIR @PACKAGE_CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@) -set_and_check(@PROJECT_NAME@_LIBDIR @PACKAGE_CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@) +set_and_check(@PROJECT_NAME@_BINDIR @CMAKE_INSTALL_FULL_BINDIR@) +set_and_check(@PROJECT_NAME@_INCDIR @CMAKE_INSTALL_FULL_INCLUDEDIR@) +set_and_check(@PROJECT_NAME@_LIBDIR @CMAKE_INSTALL_FULL_LIBDIR@) ### Import targets -include(@PACKAGE_CMAKE_INSTALL_PREFIX@/@PACKAGE_INSTALL_DESTINATION@/@[email protected]) +include(@PACKAGE_INSTALL_FULL_DESTINATION@/@[email protected]) check_required_components(@PROJECT_NAME@) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/doc/nn_freemsg.adoc new/nanomsg-1.2.1/doc/nn_freemsg.adoc --- old/nanomsg-1.2/doc/nn_freemsg.adoc 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/doc/nn_freemsg.adoc 2024-02-03 23:45:24.000000000 +0100 @@ -17,7 +17,7 @@ ----------- Deallocates a message allocated using <<nn_allocmsg#,nn_allocmsg(3)>> function or received via <<nn_recv#,nn_recv(3)>> or <<nn_recvmsg#,nn_recvmsg(3)>> function. -While <<nn_recv#,nn_recv(3)>> and <<nn_recvmsg#,nn_recvmsg(3)>> allow to receive data +While <<nn_recv#,nn_recv(3)>> and <<nn_recvmsg#,nn_recvmsg(3)>> allow one to receive data into arbitrary buffers, using library-allocated buffers can be more efficient for large messages as it allows for using zero-copy techniques. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/doc/nn_inproc.adoc new/nanomsg-1.2.1/doc/nn_inproc.adoc --- old/nanomsg-1.2/doc/nn_inproc.adoc 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/doc/nn_inproc.adoc 2024-02-03 23:45:24.000000000 +0100 @@ -15,7 +15,7 @@ DESCRIPTION ----------- -In-process transport allows to send messages between threads or modules inside a +In-process transport allows one to send messages between threads or modules inside a process. In-process address is an arbitrary case-sensitive string preceded by 'inproc://' protocol specifier. All in-process addresses are visible from any module within the process. They are not visible from outside of the process. @@ -32,7 +32,7 @@ socket option on the receiving end of the connection. NN_SNDBUF socket option is ignored. In addition to the buffer, one message of arbitrary size will fit into the buffer. That way, even messages larger than the buffer can be -transfered via inproc connection. +transferred via inproc connection. EXAMPLE ------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/doc/nn_pair.adoc new/nanomsg-1.2.1/doc/nn_pair.adoc --- old/nanomsg-1.2/doc/nn_pair.adoc 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/doc/nn_pair.adoc 2024-02-03 23:45:24.000000000 +0100 @@ -22,7 +22,7 @@ separate servers. These applications can then communicate via PAIR sockets. The downside of this protocol is that its scaling properties are very limited. -Splitting the application into two pieces allows to scale the two servers. +Splitting the application into two pieces allows one to scale the two servers. To add the third server to the cluster, the application has to be split once more, say by separating HR functionality into hiring module and salary computation module. Whenever possible, try to use one of the more scalable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/doc/nn_pubsub.adoc new/nanomsg-1.2.1/doc/nn_pubsub.adoc --- old/nanomsg-1.2/doc/nn_pubsub.adoc 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/doc/nn_pubsub.adoc 2024-02-03 23:45:24.000000000 +0100 @@ -28,7 +28,7 @@ nn_setsockopt (s, NN_SUB, NN_SUB_SUBSCRIBE, "Hello", 5); ---- -Will match any message with intial 5 bytes being "Hello", for example, +Will match any message with initial 5 bytes being "Hello", for example, message "Hello, World!" will match. Topic with zero length matches any message. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/doc/nn_survey.adoc new/nanomsg-1.2.1/doc/nn_survey.adoc --- old/nanomsg-1.2/doc/nn_survey.adoc 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/doc/nn_survey.adoc 2024-02-03 23:45:24.000000000 +0100 @@ -15,7 +15,7 @@ DESCRIPTION ----------- -Allows to broadcast a survey to multiple locations and gather the responses. +Allows one to broadcast a survey to multiple locations and gather the responses. Socket Types ~~~~~~~~~~~~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/src/CMakeLists.txt new/nanomsg-1.2.1/src/CMakeLists.txt --- old/nanomsg-1.2/src/CMakeLists.txt 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/src/CMakeLists.txt 2024-02-03 23:45:24.000000000 +0100 @@ -384,6 +384,9 @@ set(PACKAGE_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${NN_PACKAGE_VERSION} ) +set(PACKAGE_INSTALL_FULL_DESTINATION + ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${PROJECT_NAME}-${NN_PACKAGE_VERSION} +) install(EXPORT ${PROJECT_NAME}-target DESTINATION ${PACKAGE_INSTALL_DESTINATION} ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/src/pkgconfig.in new/nanomsg-1.2.1/src/pkgconfig.in --- old/nanomsg-1.2/src/pkgconfig.in 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/src/pkgconfig.in 2024-02-03 23:45:24.000000000 +0100 @@ -1,7 +1,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -includedir=${prefix}/include -libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ Name: @CMAKE_PROJECT_NAME@ Description: @NN_DESCRIPTION@ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/src/utils/chunkref.c new/nanomsg-1.2.1/src/utils/chunkref.c --- old/nanomsg-1.2/src/utils/chunkref.c 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/src/utils/chunkref.c 2024-02-03 23:45:24.000000000 +0100 @@ -1,5 +1,6 @@ /* Copyright (c) 2013 Martin Sustrik All rights reserved. + Copyright 2024 Staysail Systems, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,132 +26,116 @@ #include <string.h> -/* nn_chunkref should be reinterpreted as this structure in case the first - byte ('tag') is 0xff. */ -struct nn_chunkref_chunk { - uint8_t tag; - void *chunk; -}; - -/* Check whether VSM are small enough for size to fit into the first byte - of the structure. */ -CT_ASSERT (NN_CHUNKREF_MAX < 255); - -/* Check whether nn_chunkref_chunk fits into nn_chunkref. */ -CT_ASSERT (sizeof (struct nn_chunkref) >= sizeof (struct nn_chunkref_chunk)); +#define NN_CHUNKREF_EXT ((size_t)-1) void nn_chunkref_init (struct nn_chunkref *self, size_t size) { int rc; - struct nn_chunkref_chunk *ch; - if (size < NN_CHUNKREF_MAX) { - self->u.ref [0] = (uint8_t) size; + if (size <= NN_CHUNKREF_MAX) { + self->size = size; return; } - ch = (struct nn_chunkref_chunk*) self; - ch->tag = 0xff; - rc = nn_chunk_alloc (size, 0, &ch->chunk); + self->size = NN_CHUNKREF_EXT; + rc = nn_chunk_alloc (size, 0, (void **)&self->u.chunk); errno_assert (rc == 0); } void nn_chunkref_init_chunk (struct nn_chunkref *self, void *chunk) { - struct nn_chunkref_chunk *ch; - - ch = (struct nn_chunkref_chunk*) self; - ch->tag = 0xff; - ch->chunk = chunk; + self->size = NN_CHUNKREF_EXT; + self->u.chunk = chunk; } void nn_chunkref_term (struct nn_chunkref *self) { - struct nn_chunkref_chunk *ch; - - if (self->u.ref [0] == 0xff) { - ch = (struct nn_chunkref_chunk*) self; - nn_chunk_free (ch->chunk); + if (self->size == NN_CHUNKREF_EXT) { + nn_chunk_free (self->u.chunk); } } void *nn_chunkref_getchunk (struct nn_chunkref *self) { int rc; - struct nn_chunkref_chunk *ch; void *chunk; - if (self->u.ref [0] == 0xff) { - ch = (struct nn_chunkref_chunk*) self; - self->u.ref [0] = 0; - return ch->chunk; + if (self->size == NN_CHUNKREF_EXT) { + chunk = self->u.chunk; + self->u.chunk = NULL; + self->size = 0; + return chunk; } - rc = nn_chunk_alloc (self->u.ref [0], 0, &chunk); + nn_assert (self->size <= NN_CHUNKREF_MAX); + rc = nn_chunk_alloc (self->size, 0, &chunk); errno_assert (rc == 0); - memcpy (chunk, &self->u.ref [1], self->u.ref [0]); - self->u.ref [0] = 0; + memcpy (chunk, &self->u.ref, self->size); + self->size = 0; return chunk; } void nn_chunkref_mv (struct nn_chunkref *dst, struct nn_chunkref *src) { - memcpy (dst, src, src->u.ref [0] == 0xff ? - (int)sizeof (struct nn_chunkref_chunk) : src->u.ref [0] + 1); + dst->size = src->size; + if (src->size == NN_CHUNKREF_EXT) { + dst->u.chunk = src->u.chunk; + } else { + nn_assert (src->size <= NN_CHUNKREF_MAX); + memcpy (dst->u.ref, src->u.ref, src->size); + } } void nn_chunkref_cp (struct nn_chunkref *dst, struct nn_chunkref *src) { - struct nn_chunkref_chunk *ch; - - if (src->u.ref [0] == 0xff) { - ch = (struct nn_chunkref_chunk*) src; - nn_chunk_addref (ch->chunk, 1); + dst->size = src->size; + if (src->size == NN_CHUNKREF_EXT) { + nn_chunk_addref(src->u.chunk, 1); + dst->u.chunk = src->u.chunk; + } else { + nn_assert (src->size <= NN_CHUNKREF_MAX); + memcpy (dst->u.ref, src->u.ref, src->size); } - memcpy (dst, src, sizeof (struct nn_chunkref)); } void *nn_chunkref_data (struct nn_chunkref *self) { - return self->u.ref [0] == 0xff ? - ((struct nn_chunkref_chunk*) self)->chunk : - &self->u.ref [1]; + if (self->size > NN_CHUNKREF_MAX) { + return self->u.chunk; + } else { + return self->u.ref; + } } size_t nn_chunkref_size (struct nn_chunkref *self) { - return self->u.ref [0] == 0xff ? - nn_chunk_size (((struct nn_chunkref_chunk*) self)->chunk) : - self->u.ref [0]; + if (self->size > NN_CHUNKREF_MAX) { + return (nn_chunk_size(self->u.chunk)); + } + return self->size; } void nn_chunkref_trim (struct nn_chunkref *self, size_t n) { - struct nn_chunkref_chunk *ch; - - if (self->u.ref [0] == 0xff) { - ch = (struct nn_chunkref_chunk*) self; - ch->chunk = nn_chunk_trim (ch->chunk, n); + if (self->size == NN_CHUNKREF_EXT) { + nn_chunk_trim (self->u.chunk, n); return; } - nn_assert (self->u.ref [0] >= n); - memmove (&self->u.ref [1], &self->u.ref [1 + n], self->u.ref [0] - n); - self->u.ref [0] -= (uint8_t) n; + nn_assert (self->size >= n); + nn_assert (self->size <= NN_CHUNKREF_MAX); + memmove (self->u.ref, self->u.ref + n, self->size - n); + self->size -= n; } void nn_chunkref_bulkcopy_start (struct nn_chunkref *self, uint32_t copies) { - struct nn_chunkref_chunk *ch; - - if (self->u.ref [0] == 0xff) { - ch = (struct nn_chunkref_chunk*) self; - nn_chunk_addref (ch->chunk, copies); + if (self->size == NN_CHUNKREF_EXT) { + nn_chunk_addref (self->u.chunk, copies); } } void nn_chunkref_bulkcopy_cp (struct nn_chunkref *dst, struct nn_chunkref *src) { - memcpy (dst, src, sizeof (struct nn_chunkref)); + *dst = *src; } - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.2/src/utils/chunkref.h new/nanomsg-1.2.1/src/utils/chunkref.h --- old/nanomsg-1.2/src/utils/chunkref.h 2022-04-19 01:29:26.000000000 +0200 +++ new/nanomsg-1.2.1/src/utils/chunkref.h 2024-02-03 23:45:24.000000000 +0100 @@ -37,12 +37,10 @@ we can avoid additional memory allocation per message. */ struct nn_chunkref { + size_t size; /* if <= NN_CHUNKREF_MAX then data is in ref */ union { - uint8_t ref [NN_CHUNKREF_MAX]; - - /* This option is present only to force alignemt of nn_chunkref to - the word boudnary. */ - void *unused; + void *chunk; /* actually an nn_chunk */ + uint8_t ref [NN_CHUNKREF_MAX]; /* inline data for the chunk */ } u; }; @@ -87,4 +85,3 @@ void nn_chunkref_bulkcopy_cp (struct nn_chunkref *dst, struct nn_chunkref *src); #endif -
