Skip site navigation (1)Skip section navigation (2)



index | | raw e-mail

diff --git a/contrib/libcbor/.circleci/config.yml b/contrib/libcbor/.circleci/config.yml
index 4391ad8d1e9c..ea030d6b7b8e 100644
--- a/contrib/libcbor/.circleci/config.yml
+++ b/contrib/libcbor/.circleci/config.yml
@@ -3,30 +3,50 @@ version: 2.1
 commands:
   linux-setup:
     steps:
-    - run: sudo apt-get update
-    # NEEDRESTART_MODE prevents automatic restarts which seem to hang.
-    - run: sudo NEEDRESTART_MODE=l apt-get install -y cmake ${TOOLCHAIN_PACKAGES}
-    - run: sudo NEEDRESTART_MODE=l apt-get install -y libcmocka-dev libcjson-dev
+      - run: sudo apt-get update
+      # NEEDRESTART_MODE prevents automatic restarts which seem to hang.
+      - run: sudo NEEDRESTART_MODE=l  apt-get install -y cmake ${TOOLCHAIN_PACKAGES}
+      - run: sudo NEEDRESTART_MODE=l apt-get install -y libcmocka-dev libcjson-dev
+  build-with-cmocka-from-source:
+    # For whatever reason, cmocka find stopped working on dockercross at some point.
+    steps:
+      - run: git clone https://git.cryptomilk.org/projects/cmocka.git ~/cmocka
+      - run: >
+          cd $(mktemp -d /tmp/build.XXXX) &&
+          cmake ~/cmocka &&
+          make &&
+          sudo make install
+      - run: >
+          cmake -DWITH_TESTS=ON \
+            -DWITH_EXAMPLES=ON \
+            -DCMAKE_BUILD_TYPE=Debug \
+            -DSANITIZE=OFF \
+            -DCOVERAGE="${CMAKE_COVERAGE:='OFF'}" \
+            -DCMOCKA_INCLUDE_DIR=/usr/local/include \
+            -DCMOCKA_LIBRARIES=/usr/local/lib/libcmocka.so
+      - run: make -j 16 VERBOSE=1
   build:
     steps:
-    - run: >
-        cmake -DWITH_TESTS=ON \
-          -DWITH_EXAMPLES=ON \
-          -DCMAKE_BUILD_TYPE=Debug \
-          -DSANITIZE=OFF \
-          -DCOVERAGE="${CMAKE_COVERAGE:='OFF'}" \
-          .
-    - run: make -j 16 VERBOSE=1
+      - run: >
+          cmake -DWITH_TESTS=ON \
+            -DWITH_EXAMPLES=ON \
+            -DCMAKE_BUILD_TYPE=Debug \
+            -DSANITIZE=OFF \
+            -DCOVERAGE="${CMAKE_COVERAGE:='OFF'}" \
+            .
+      - run: make -j 16 VERBOSE=1
   build-release:
     steps:
-    - run: >
-        cmake -DWITH_TESTS=ON \
-          -DCMAKE_BUILD_TYPE=Release \
-          .
-    - run: make -j 16 VERBOSE=1
+      - run: >
+          cmake -DWITH_TESTS=ON \
+            -DCMAKE_BUILD_TYPE=Release \
+            .
+      - run: make -j 16 VERBOSE=1
   test:
     steps:
-    - run: ctest -VV
+      - run: ctest -VV --output-junit ctest_out.xml
+      - store_test_results:
+          path: ctest_out.xml
 
 orbs:
   codecov: codecov/codecov@3.2.2
@@ -34,7 +54,7 @@ orbs:
 jobs:
   static-test:
     machine: &default-machine
-      image: ubuntu-2204:2023.07.2
+      image: ubuntu-2204:current
     environment:
       TOOLCHAIN_PACKAGES: g++
     steps:
@@ -159,7 +179,7 @@ jobs:
 
   build-bazel:
     machine:
-      image: ubuntu-2204:2023.07.2
+      <<: *default-machine
     environment:
       TOOLCHAIN_PACKAGES: g++
     steps:
@@ -178,7 +198,7 @@ jobs:
 
   build-and-test-osx:
     macos:
-      xcode: 12.5.1
+      xcode: 16.0.0
     steps:
       - checkout
       - run: bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@@ -203,7 +223,33 @@ jobs:
       - run: /c/Program\ Files/Cmake/bin/cmake --build libcbor_build
       - run: >
           export PATH="$(pwd)/cmocka_build/src/Debug/:$PATH" &&
-          /c/Program\ Files/Cmake/bin/ctest.exe --test-dir libcbor_build --output-on-failure
+          /c/Program\ Files/Cmake/bin/ctest.exe --test-dir libcbor_build -C Debug --output-on-failure
+
+  build-and-test-mips: &dockcross-job
+    docker:
+      - image: dockcross/linux-mips-lts
+    steps: 
+      - checkout
+      - attach_workspace:
+          at: /home/circleci/project
+      - build-with-cmocka-from-source
+      - test
+
+  build-and-test-mipsel:
+    <<: *dockcross-job
+    docker:
+      - image: dockcross/linux-mipsel-lts
+
+
+  build-and-test-riscv64: &dockcross-job
+    docker:
+      - image: dockcross/linux-riscv64
+    steps: 
+      - checkout
+      - attach_workspace:
+          at: /home/circleci/project
+      - build-with-cmocka-from-source
+      - test
 
 workflows:
   build-and-test:
@@ -215,6 +261,9 @@ workflows:
       - build-and-test-release-clang
       - build-and-test-arm
       - build-and-test-win
+      - build-and-test-mips
+      - build-and-test-mipsel
+      - build-and-test-riscv64
       - build-bazel
       - llvm-coverage
       # OSX builds are expensive, run only on master
diff --git a/contrib/libcbor/.cirrus.yml b/contrib/libcbor/.cirrus.yml
index 948ae23b4a98..beaea2a0b6ee 100644
--- a/contrib/libcbor/.cirrus.yml
+++ b/contrib/libcbor/.cirrus.yml
@@ -5,7 +5,6 @@ freebsd_task:
     - mkdir build
     - cd build
     - cmake -GNinja -DWITH_TESTS=ON
-      -DCBOR_CUSTOM_ALLOC=ON
       -DCMAKE_BUILD_TYPE=Debug
       -DSANITIZE=OFF
       ..
@@ -15,12 +14,12 @@ freebsd_task:
     - ctest -VV
     matrix:
     # From gcloud compute images list --project freebsd-org-cloud-dev --no-standard-images
-    - name: freebsd-13-2
+    - name: freebsd-13-4
       freebsd_instance:
-        image_family: freebsd-13-2
-    - name: freebsd-14-0
+        image_family: freebsd-13-4
+    - name: freebsd-14-2
       freebsd_instance:
-        image_family: freebsd-14-0
+        image_family: freebsd-14-2
     - name: freebsd-15-0-snap
       freebsd_instance:
         image_family: freebsd-15-0-snap
diff --git a/contrib/libcbor/.clang-format b/contrib/libcbor/.clang-format
index de0dc5e77907..09a8bc907ac8 100644
--- a/contrib/libcbor/.clang-format
+++ b/contrib/libcbor/.clang-format
@@ -52,7 +52,7 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true
 ConstructorInitializerIndentWidth: 4
 ContinuationIndentWidth: 4
 Cpp11BracedListStyle: true
-DerivePointerAlignment: true
+DerivePointerAlignment: false
 DisableFormat:   false
 ExperimentalAutoDetectBinPacking: false
 FixNamespaceComments: true
diff --git a/contrib/libcbor/.github/workflows/fuzz-pr.yml b/contrib/libcbor/.github/workflows/fuzz-pr.yml
index 0e3c4fde4e02..aba933e193f3 100644
--- a/contrib/libcbor/.github/workflows/fuzz-pr.yml
+++ b/contrib/libcbor/.github/workflows/fuzz-pr.yml
@@ -18,7 +18,7 @@ jobs:
         fuzz-seconds: 10
         dry-run: false
     - name: Upload Crash
-      uses: actions/upload-artifact@v1
+      uses: actions/upload-artifact@v4
       if: failure()
       with:
         name: artifacts
diff --git a/contrib/libcbor/.github/workflows/fuzz.yml b/contrib/libcbor/.github/workflows/fuzz.yml
index 8603cc2f338e..8a95cdff76db 100644
--- a/contrib/libcbor/.github/workflows/fuzz.yml
+++ b/contrib/libcbor/.github/workflows/fuzz.yml
@@ -18,7 +18,7 @@ jobs:
         fuzz-seconds: 14400 # 4 hours
         dry-run: false
     - name: Upload Crash
-      uses: actions/upload-artifact@v1
+      uses: actions/upload-artifact@v4
       if: failure()
       with:
         name: artifacts
diff --git a/contrib/libcbor/.gitignore b/contrib/libcbor/.gitignore
index 61f88a874965..cfc2f906bd0a 100644
--- a/contrib/libcbor/.gitignore
+++ b/contrib/libcbor/.gitignore
@@ -1,4 +1,3 @@
-build
 *~
 nbproject
 .idea
@@ -7,10 +6,13 @@ doxygen_docs
 cmake-build-debug
 venv
 **.DS_Store
-.vscode
+.vscode/tmp
+.vscode/c_cpp_properties.json
+doc/build
 # No top-level requirements, see doc/source
 requirements.txt
 examples/bazel/bazel-bazel
 examples/bazel/bazel-bin
 examples/bazel/bazel-out
 examples/bazel/bazel-testlogs
+**MODULE.bazel.lock
diff --git a/contrib/libcbor/.vscode/settings.json b/contrib/libcbor/.vscode/settings.json
new file mode 100644
index 000000000000..1efd1526d101
--- /dev/null
+++ b/contrib/libcbor/.vscode/settings.json
@@ -0,0 +1,6 @@
+{
+    "C_Cpp.clang_format_style": "file",
+    "editor.formatOnSave": true,
+    "cmake.configureOnOpen": true,
+    "cmake.buildDirectory": "${workspaceFolder}/.vscode/tmp/build_${buildType}",
+}
\ No newline at end of file
diff --git a/contrib/libcbor/BUILD b/contrib/libcbor/BUILD
new file mode 100644
index 000000000000..5035c90f756b
--- /dev/null
+++ b/contrib/libcbor/BUILD
@@ -0,0 +1,58 @@
+genrule(
+    name = "cbor_cmake",
+    srcs = glob(["**"]),
+    outs = [
+        "libcbor.a",
+        "cbor.h",
+        "cbor/arrays.h",
+        "cbor/bytestrings.h",
+        "cbor/callbacks.h",
+        "cbor/cbor_export.h",
+        "cbor/common.h",
+        "cbor/configuration.h",
+        "cbor/data.h",
+        "cbor/encoding.h",
+        "cbor/floats_ctrls.h",
+        "cbor/ints.h",
+        "cbor/maps.h",
+        "cbor/serialization.h",
+        "cbor/streaming.h",
+        "cbor/strings.h",
+        "cbor/tags.h",
+    ],
+    cmd = " && ".join([
+        # Remember where output should go.
+        "INITIAL_WD=`pwd`",
+        "cd `dirname $(location CMakeLists.txt)`",
+        "cmake -DCMAKE_BUILD_TYPE=Release .",
+        "cmake --build .",
+        # Export the .a and .h files for cbor rule, below.
+        "cp -R src/* $$INITIAL_WD/$(RULEDIR)",
+        "cp cbor/configuration.h $$INITIAL_WD/$(RULEDIR)/cbor",
+    ]),
+    visibility = ["//visibility:private"],
+)
+
+cc_import(
+    name = "cbor",
+    hdrs = [
+        "cbor.h",
+        "cbor/arrays.h",
+        "cbor/bytestrings.h",
+        "cbor/callbacks.h",
+        "cbor/cbor_export.h",
+        "cbor/common.h",
+        "cbor/configuration.h",
+        "cbor/data.h",
+        "cbor/encoding.h",
+        "cbor/floats_ctrls.h",
+        "cbor/ints.h",
+        "cbor/maps.h",
+        "cbor/serialization.h",
+        "cbor/streaming.h",
+        "cbor/strings.h",
+        "cbor/tags.h",
+    ],
+    static_library = "libcbor.a",
+    visibility = ["//visibility:public"],
+)
diff --git a/contrib/libcbor/Bazel.md b/contrib/libcbor/Bazel.md
deleted file mode 100644
index 9fa2081f58fc..000000000000
--- a/contrib/libcbor/Bazel.md
+++ /dev/null
@@ -1,100 +0,0 @@
-# Use as a Bazel Dependency
-
-To use libcbor in your
-[Baze](https://bazel.build/)
-project, first add the following section to your project's `WORKSPACE` file.
-Note the location of the `third_party/libcbor.BUILD` file - you may use a
-different location if you wish, but you the file must be make available to
-`WORKSPACE`.
-
-## WORKSPACE
-
-Note, this imports version `0.8.0` - you may need to update the version and
-the sha256 hash.
-
-```python
-# libcbor
-http_archive(
-    name = "libcbor",
-    build_file = "//third_party:libcbor.BUILD",
-    sha256 = "dd04ea1a7df484217058d389e027e7a0143a4f245aa18a9f89a5dd3e1a4fcc9a",
-    strip_prefix = "libcbor-0.8.0",
-    urls = ["https://github.com/PJK/libcbor/archive/refs/tags/v0.8.0.zip"],
-)
-```
-
-## third_party/libcbor.BUILD
-
-Bazel will unzip the libcbor zip file, then copy this file in as `BUILD`.
-Bazel will then use this file to compile libcbor.
-[Cmake](https://cmake.org/)
-is used in two passes: to create the Makefiles, and then to invoke Make to build
-the `libcbor.a` static library. `libcbor.a` and the `.h` files are then made
-available for other packages to use.
-
-```python
-genrule(
-  name = "cbor_cmake",
-  srcs = glob(["**"]),
-  outs = ["libcbor.a", "cbor.h", "cbor/arrays.h", "cbor/bytestrings.h",
-          "cbor/callbacks.h", "cbor/cbor_export.h", "cbor/common.h", "cbor/configuration.h", "cbor/data.h",
-          "cbor/encoding.h", "cbor/floats_ctrls.h", "cbor/ints.h", "cbor/maps.h",
-          "cbor/serialization.h", "cbor/streaming.h", "cbor/strings.h", "cbor/tags.h"],
-  cmd = " && ".join([
-    # Remember where output should go.
-    "INITIAL_WD=`pwd`",
-    # Build libcbor library.
-    "cd `dirname $(location CMakeLists.txt)`",
-    "cmake -DCMAKE_BUILD_TYPE=Release .",
-    "cmake --build .",
-    # Export the .a and .h files for cbor rule, below.
-    "cp src/libcbor.a src/cbor.h $$INITIAL_WD/$(RULEDIR)",
-    "cp src/cbor/*h cbor/configuration.h $$INITIAL_WD/$(RULEDIR)/cbor"]),
-  visibility = ["//visibility:private"],
-)
-
-cc_import(
-  name = "cbor",
-  hdrs = ["cbor.h", "cbor/arrays.h", "cbor/bytestrings.h",
-          "cbor/callbacks.h", "cbor/cbor_export.h", "cbor/common.h", "cbor/configuration.h", "cbor/data.h",
-          "cbor/encoding.h", "cbor/floats_ctrls.h", "cbor/ints.h", "cbor/maps.h",
-          "cbor/serialization.h", "cbor/streaming.h", "cbor/strings.h", "cbor/tags.h"],
-  static_library = "libcbor.a",
-  visibility = ["//visibility:public"],
-)
-```
-
-## third_party/BUILD
-
-The `libcbor.BUILD` file must be make available to the top-level `WORKSPACE`
-file:
-
-```python
-exports_files(["libcbor.BUILD"]))
-```
-
-## Your BUILD File
-
-Add libcbor dependency to your package's `BUILD` file like so:
-
-```python
-cc_library(
-    name = "...",
-    srcs = [ ... ],
-    hdrs = [ ... ],
-    deps = [
-        ...
-        "@libcbor//:cbor",
-    ],
-)
-```
-
-## Your C File
-
-Now you may simply include `cbor.h`:
-
-```c
-#include "cbor.h"
-
-static const uint8_t version = cbor_major_version;
-```
diff --git a/contrib/libcbor/CHANGELOG.md b/contrib/libcbor/CHANGELOG.md
index 3c331f9266ab..7509569b414f 100644
--- a/contrib/libcbor/CHANGELOG.md
+++ b/contrib/libcbor/CHANGELOG.md
@@ -1,40 +1,76 @@
 Template:
+
 - [Fix issue X in feature Y](https://github.com/PJK/libcbor/pull/XXX) (by [YYY](https://github.com/YYY))
 
 Next
 ---------------------
 
+0.13.0 (2025-08-30)
+---------------------
+
+- [Fix `cbor_is_null`, `cbor_is_undef`, `cbor_is_bool` assertion failing on non-ctrl floats in debug mode](https://github.com/PJK/libcbor/issues/352) (bug discovered by <https://github.com/psturm-swift>)
+- [Add an example for handling of CBOR Sequences](https://github.com/PJK/libcbor/pull/358)
+- [Use C23/c2x if available](https://github.com/PJK/libcbor/pull/361)
+  - libcbor remains C99 compatible
+  - When the compiler does not support new standard, C99 will be used, so the change should be backwards compatible
+- [Improved introduction documentation and examples](https://github.com/PJK/libcbor/pull/363)
+- [Add cbor_copy_definite to turn indefinite items into definite equivalents](https://github.com/PJK/libcbor/pull/364/files) (proposed by Jacob Teplitsky)
+- BUILD BREAKING: [Minimum CMake version set to 3.5](https://github.com/PJK/libcbor/pull/355) to [be compatible with CMake 4](https://github.com/eclipse-ecal/ecal/issues/2041) ([suggestion](https://github.com/PJK/libcbor/commit/1183292d4695300785b272532c1e02d68840e4b8#commitcomment-164507943) by <https://github.com/hnyman>)
+  - See <https://repology.org/project/cmake/versions>; for support; the vast majority of users should not be affected.
+
+0.12.0 (2025-03-16)
+---------------------
+
+- BUILD BREAKING: [Respect `INTERPROCEDURAL_OPTIMIZATION` and use the default value](https://github.com/PJK/libcbor/issues/315)
+- BREAKING: Changes to NaN encoding
+  - [Fix NaN encoding on Windows](https://github.com/PJK/libcbor/issues/271)
+  - [Fix NaN encoding on mips/mipsel](https://github.com/PJK/libcbor/issues/329)
+  - [Signaling NaNs will from now on be encoded as canonical quiet NaNs](https://github.com/PJK/libcbor/pull/335). This was already the existing behavior for half-precision floats
+  - Decoding is unchanged
+  - Please note that this is an intermediate state and likely to be revisited (<https://github.com/PJK/libcbor/issues/336>)
+- [Make build compatible with CMake FetchContent](https://github.com/PJK/libcbor/pull/341) (by [Jan200101](https://github.com/Jan200101))
+- [Support Bzlmod for Bazel builds](https://github.com/PJK/libcbor/pull/340)
+  - This should significantly simplify including libcbor as a dependency/module in Bazel projects, see <https://bazel.build/external/migration>;
+- Code quality improvements
+  - [Fix compiler pragmas](https://github.com/PJK/libcbor/pull/347) (by [brooksdavis](https://github.com/brooksdavis))
+  - [Fix code style issues](https://github.com/PJK/libcbor/pull/321)
+- [Fixed bug in cbor2cjson example](https://github.com/PJK/libcbor/pull/338) (by [whitehse](https://github.com/whitehse))
+
 0.11.0 (2024-02-04)
 ---------------------
+
 - [Updated documentation to refer to RFC 8949](https://github.com/PJK/libcbor/issues/269)
 - Improvements to `cbor_describe`
-  - [Bytestring data will now be printed as well](https://github.com/PJK/libcbor/pull/281) by  [akallabeth](https://github.com/akallabeth)
+  - [Bytestring data will now be printed as well](https://github.com/PJK/libcbor/pull/281) by [akallabeth](https://github.com/akallabeth)
   - [Formatting consistency and clarity improvements](https://github.com/PJK/libcbor/pull/285)
 - [Fix `cbor_string_set_handle` not setting the codepoint count](https://github.com/PJK/libcbor/pull/286)
 - BREAKING: [`cbor_load` will no longer fail on input strings that are well-formed but not valid UTF-8](https://github.com/PJK/libcbor/pull/286)
-  - If you were relying on the validation, please check the result using `cbor_string_codepoint_count` instead 
+  - If you were relying on the validation, please check the result using `cbor_string_codepoint_count` instead
 - BREAKING: [All decoders like `cbor_load` and `cbor_stream_decode` will accept all well-formed tag values](https://github.com/PJK/libcbor/pull/308) (bug discovered by [dskern-github](https://github.com/dskern-github))
   - Previously, decoding of certain values would fail with `CBOR_ERR_MALFORMATED` or `CBOR_DECODER_ERROR`
   - This also makes decoding symmetrical with serialization, which already accepts all values
 
 0.10.2 (2023-01-31)
 ---------------------
+
 - [Fixed minor test bug causing failures for x86 Linux](https://github.com/PJK/libcbor/pull/266) (discovered by [trofi](https://github.com/PJK/libcbor/issues/263))
   - Actual libcbor functionality not affected, bug was in the test suite
 - [Made tests platform-independent](https://github.com/PJK/libcbor/pull/272)
 
 0.10.1 (2022-12-30)
 ---------------------
+
 - [Fix a regression in `cbor_serialize_alloc` that caused serialization of zero-length strings and bytestrings or byte/strings with zero-length chunks to fail](https://github.com/PJK/libcbor/pull/260) (discovered by [martelletto](https://github.com/martelletto))
 
 0.10.0 (2022-12-29)
 ---------------------
+
 - Make the buffer_size optional in `cbor_serialize_alloc` [[#205]](https://github.com/PJK/libcbor/pull/205) (by [hughsie](https://github.com/hughsie))
 - BREAKING: Improved half-float encoding for denormalized numbers. [[#208]](https://github.com/PJK/libcbor/pull/208) (by [ranvis](https://github.com/ranvis))
   - Denormalized half-floats will now preserve data in the mantissa
-  - Note: Half-float NaNs still lose data (https://github.com/PJK/libcbor/issues/215)
+  - Note: Half-float NaNs still lose data (<https://github.com/PJK/libcbor/issues/215>)
 - BUILD BREAKING: Minimum CMake version is 3.0 [[#201]](https://github.com/PJK/libcbor/pull/201) (by [thewtex@](https://github.com/thewtex))
-  - See https://repology.org/project/cmake/versions for support; the vast majority of users should not be affected.
+  - See <https://repology.org/project/cmake/versions>; for support; the vast majority of users should not be affected.
 - Fix a potential memory leak when the allocator fails during array or map decoding [[#224]](https://github.com/PJK/libcbor/pull/224) (by [James-ZHANG](https://github.com/James-ZHANG))
 - [Fix a memory leak when the allocator fails when adding chunks to indefinite bytestrings.](https://github.com/PJK/libcbor/pull/242) ([discovered](https://github.com/PJK/libcbor/pull/228) by [James-ZHANG](https://github.com/James-ZHANG))
 - [Fix a memory leak when the allocator fails when adding chunks to indefinite strings](https://github.com/PJK/libcbor/pull/246)
@@ -53,57 +89,62 @@ Next
 
 0.9.0 (2021-11-14)
 ---------------------
+
 - Improved pkg-config paths handling [[#164]](https://github.com/PJK/libcbor/pull/164) (by [jtojnar@](https://github.com/jtojnar))
 - Use explicit math.h linkage [[#170]](https://github.com/PJK/libcbor/pull/170)
 - BREAKING: Fixed handling of items that exceed the host size_t range [[#186]](https://github.com/PJK/libcbor/pull/186hg)  
-    - Callbacks for bytestrings, strings, arrays, and maps use uint64_t instead of size_t to allow handling of large items that exceed size_t even if size_t < uint64_t
-    - cbor_decode explicitly checks size to avoid overflows (previously broken, potentially resulting in erroneous decoding on affected systems)
-    - The change should be a noop for 64b systems 
+  - Callbacks for bytestrings, strings, arrays, and maps use uint64_t instead of size_t to allow handling of large items that exceed size_t even if size_t < uint64_t
+  - cbor_decode explicitly checks size to avoid overflows (previously broken, potentially resulting in erroneous decoding on affected systems)
+  - The change should be a noop for 64b systems
 - Added a [Bazel](https://bazel.build/) build example [[#196]](https://github.com/PJK/libcbor/pull/196) (by [andyjgf@](https://github.com/andyjgf))
 
 0.8.0 (2020-09-20)
 ---------------------
+
 - BUILD BREAKING: Use BUILD_SHARED_LIBS to determine how to build libraries (fixed Windows linkage) [[#148]](https://github.com/PJK/libcbor/pull/148) (by [intelligide@](https://github.com/intelligide))
 - BREAKING: Fix `cbor_tag_item` not increasing the reference count on the tagged item reference it returns [[Fixes #109](https://github.com/PJK/libcbor/issues/109)] (discovered bt [JohnGilmour](https://github.com/JohnGilmour))
   - If you have previously relied on the broken behavior, you can use `cbor_move` to emulate as long as the returned handle is an "rvalue"
 - BREAKING: [`CBOR_DECODER_EBUFFER` removed from `cbor_decoder_status`](https://github.com/PJK/libcbor/pull/156)
-    - `cbor_stream_decode` will set `CBOR_DECODER_NEDATA` instead if the input buffer is empty
+  - `cbor_stream_decode` will set `CBOR_DECODER_NEDATA` instead if the input buffer is empty
 - [Fix `cbor_stream_decode`](https://github.com/PJK/libcbor/pull/156) to set `cbor_decoder_result.required` to the minimum number of input bytes necessary to receive the next callback (as long as at least one byte was passed) (discovered by [woefulwabbit](https://github.com/woefulwabbit))
 - Fixed several minor manpage issues [[#159]](https://github.com/PJK/libcbor/pull/159) (discovered by [kloczek@](https://github.com/kloczek))
 
 0.7.0 (2020-04-25)
 ---------------------
+
 - Fix bad encoding of NaN half-floats [[Fixes #53]](https://github.com/PJK/libcbor/issues/53) (discovered by [BSipos-RKF](https://github.com/BSipos-RKF))
-    - **Warning**: Previous versions encoded NaNs as `0xf9e700` instead of `0xf97e00`; if you rely on the broken behavior, this will be a breaking change
+  - **Warning**: Previous versions encoded NaNs as `0xf9e700` instead of `0xf97e00`; if you rely on the broken behavior, this will be a breaking change
 - Fix potentially bad encoding of negative half-float with exponent < -14 [[Fixes #112]](https://github.com/PJK/libcbor/issues/112) (discovered by [yami36](https://github.com/yami36))
 - BREAKING: Improved bool support [[Fixes #63]](https://github.com/PJK/libcbor/issues/63)
-    - Rename `cbor_ctrl_is_bool` to `cbor_get_bool` and fix the behavior
-    - Add `cbor_set_bool`
+  - Rename `cbor_ctrl_is_bool` to `cbor_get_bool` and fix the behavior
+  - Add `cbor_set_bool`
 - Fix memory_allocation_test breaking the build without CBOR_CUSTOM_ALLOC [[Fixes #128]](https://github.com/PJK/libcbor/issues/128) (by [panlinux](https://github.com/panlinux))
 - [Fix a potential build issue where cJSON includes may be misconfigured](https://github.com/PJK/libcbor/pull/132)
 - Breaking: [Add a limit on the size of the decoding context stack](https://github.com/PJK/libcbor/pull/138) (by [James-ZHANG](https://github.com/James-ZHANG))
-    - If your usecase requires parsing very deeply nested structures, you might need to increase the default 2k limit via `CBOR_MAX_STACK_SIZE` 
+  - If your usecase requires parsing very deeply nested structures, you might need to increase the default 2k limit via `CBOR_MAX_STACK_SIZE`
 - Enable LTO/IPO based on [CheckIPOSupported](https://cmake.org/cmake/help/latest/module/CheckIPOSupported.html#module:CheckIPOSupported) [[#143]](https://github.com/PJK/libcbor/pull/143) (by [xanderlent](https://github.com/xanderlent))
-    - If you rely on LTO being enabled and use CMake version older than 3.9, you will need to re-enable it manually or upgrade your CMake 
+  - If you rely on LTO being enabled and use CMake version older than 3.9, you will need to re-enable it manually or upgrade your CMake
 
 0.6.1 (2020-03-26)
 ---------------------
+
 - [Fix bad shared library version number](https://github.com/PJK/libcbor/pull/131)
-    - **Warning**: Shared library built from the 0.6.0 release is erroneously marked as version "0.6.0", which makes it incompatible with future releases *including the v0.6.X line* even though they may be compatible API/ABI-wise. Refer to the documentation for the new SO versioning scheme.
+  - **Warning**: Shared library built from the 0.6.0 release is erroneously marked as version "0.6.0", which makes it incompatible with future releases *including the v0.6.X line* even though they may be compatible API/ABI-wise. Refer to the documentation for the new SO versioning scheme.
 
 0.6.0 (2020-03-15)
 ---------------------
-- Correctly set .so version [[Fixes #52]](https://github.com/PJK/libcbor/issues/52). 
-    - **Warning**: All previous releases will be identified as 0.0 by the linker.
+
+- Correctly set .so version [[Fixes #52]](https://github.com/PJK/libcbor/issues/52).
+  - **Warning**: All previous releases will be identified as 0.0 by the linker.
 - Fix & prevent heap overflow error in example code [[#74]](https://github.com/PJK/libcbor/pull/74) [[#76]](https://github.com/PJK/libcbor/pull/76) (by @nevun)
 - Correctly set OSX dynamic library version [[Fixes #75]](https://github.com/PJK/libcbor/issues/75)
 - [Fix misplaced 0xFF bytes in maps possibly causing memory corruption](https://github.com/PJK/libcbor/pull/82)
 - BREAKING: Fix handling & cleanup of failed memory allocation in constructor
   and builder helper functions [[Fixes #84]](https://github.com/PJK/libcbor/issues/84)
-  - All cbor_new_* and cbor_build_* functions will now explicitly return NULL when memory allocation fails
+  - All cbor_new_*and cbor_build_* functions will now explicitly return NULL when memory allocation fails
   - It is up to the client to handle such cases
 - Globally enforced code style [[Fixes #83]](https://github.com/PJK/libcbor/issues/83)
-- Fix issue possible memory corruption bug on repeated 
+- Fix issue possible memory corruption bug on repeated
   cbor_(byte)string_add_chunk calls with intermittently failing realloc calls
 - Fix possibly misaligned reads and writes when endian.h is uses or when
   running on a big-endian machine [[Fixes #99](https://github.com/PJK/libcbor/issues/99), [#100](https://github.com/PJK/libcbor/issues/100)]
@@ -112,6 +153,7 @@ Next
 
 0.5.0 (2017-02-06)
 ---------------------
+
 - Remove cmocka from the subtree (always rely on system or user-provided version)
 - Windows CI
 - Only build tests if explicitly enabled (`-DWITH_TESTS=ON`)
@@ -127,6 +169,7 @@ Next
 
 0.4.0 (2015-12-25)
 ---------------------
+
 Breaks build & header compatibility due to:
 
 - Improved build configuration and feature check macros
@@ -137,6 +180,7 @@ Breaks build & header compatibility due to:
 
 0.3.1 (2015-05-21)
 ---------------------
+
 - documentation and comments improvements, mostly for the API reference
 
 0.3.0 (2015-05-21)
@@ -152,6 +196,7 @@ Breaks build & header compatibility due to:
 
 0.2.1 (2015-05-17)
 ---------------------
+
 - C99 support
 
 0.2.0 (2015-05-17)
diff --git a/contrib/libcbor/CMakeLists.txt b/contrib/libcbor/CMakeLists.txt
index 16b9f0875d33..a7e133a3e888 100644
--- a/contrib/libcbor/CMakeLists.txt
+++ b/contrib/libcbor/CMakeLists.txt
@@ -1,16 +1,19 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.5)
 
-project(libcbor)
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/")
+project(libcbor LANGUAGES C CXX)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
+                      "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/")
 include(CTest)
 include(GNUInstallDirs) # Provides CMAKE_INSTALL_ variables
 
-SET(CBOR_VERSION_MAJOR "0")
-SET(CBOR_VERSION_MINOR "11")
-SET(CBOR_VERSION_PATCH "0")
-SET(CBOR_VERSION ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR}.${CBOR_VERSION_PATCH})
+set(CBOR_VERSION_MAJOR "0")
+set(CBOR_VERSION_MINOR "13")
+set(CBOR_VERSION_PATCH "0")
+set(CBOR_VERSION
+    ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR}.${CBOR_VERSION_PATCH})
 
-option(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY "cmake --build --target install does not depend on cmake --build" true)
+option(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY
+       "cmake --build --target install does not depend on cmake --build" true)
 option(BUILD_SHARED_LIBS "Build as a shared library" false)
 
 include(CheckIncludeFiles)
@@ -18,42 +21,51 @@ include(CheckIncludeFiles)
 include(TestBigEndian)
 test_big_endian(BIG_ENDIAN)
 if(BIG_ENDIAN)
-    add_definitions(-DIS_BIG_ENDIAN)
+  add_definitions(-DIS_BIG_ENDIAN)
 endif()
 
 option(CBOR_CUSTOM_ALLOC "Custom, dynamically defined allocator support" OFF)
 if(CBOR_CUSTOM_ALLOC)
-    message(WARNING
-        "CBOR_CUSTOM_ALLOC has been deprecated. Custom allocators are now enabled by default."
-        "The flag is a no-op and will be removed in the next version. "
-        "Please remove CBOR_CUSTOM_ALLOC from your build configuration.")
-endif(CBOR_CUSTOM_ALLOC)
+  message(
+    WARNING
+      "CBOR_CUSTOM_ALLOC has been deprecated. \
+      Custom allocators are now enabled by default. \
+      The flag is a no-op and will be removed in the next version. \
+      Please remove CBOR_CUSTOM_ALLOC from your build configuration.")
+endif()
 
 option(CBOR_PRETTY_PRINTER "Include a pretty-printing routine" ON)
-set(CBOR_BUFFER_GROWTH "2" CACHE STRING "Factor for buffer growth & shrinking")
-set(CBOR_MAX_STACK_SIZE "2048" CACHE STRING "maximum size for decoding context stack")
+set(CBOR_BUFFER_GROWTH
+    "2"
+    CACHE STRING "Factor for buffer growth & shrinking")
+set(CBOR_MAX_STACK_SIZE
+    "2048"
+    CACHE STRING "maximum size for decoding context stack")
 
 option(WITH_TESTS "[TEST] Build unit tests (requires CMocka)" OFF)
 if(WITH_TESTS)
-    add_definitions(-DWITH_TESTS)
-endif(WITH_TESTS)
+  add_definitions(-DWITH_TESTS)
+endif()
 
 option(WITH_EXAMPLES "Build examples" ON)
 
-option(HUGE_FUZZ "[TEST] Fuzz through 8GB of data in the test. Do not use with memory instrumentation!" OFF)
+option(HUGE_FUZZ "[TEST] Fuzz through 8GB of data in the test.\
+       Do not use with memory instrumentation!" OFF)
 if(HUGE_FUZZ)
-    add_definitions(-DHUGE_FUZZ)
-endif(HUGE_FUZZ)
+  add_definitions(-DHUGE_FUZZ)
+endif()
 
-option(SANE_MALLOC "[TEST] Assume that malloc will not allocate multi-GB blocks. Tests only, platform specific" OFF)
+option(SANE_MALLOC
+       "[TEST] Assume that malloc will not allocate multi-GB blocks.\
+       Tests only, platform specific" OFF)
 if(SANE_MALLOC)
-    add_definitions(-DSANE_MALLOC)
-endif(SANE_MALLOC)
+  add_definitions(-DSANE_MALLOC)
+endif()
 
 option(PRINT_FUZZ "[TEST] Print the fuzzer input" OFF)
 if(PRINT_FUZZ)
-    add_definitions(-DPRINT_FUZZ)
-endif(PRINT_FUZZ)
+  add_definitions(-DPRINT_FUZZ)
+endif()
 
 option(SANITIZE "Enable ASan & a few compatible sanitizers in Debug mode" ON)
 
@@ -67,119 +79,218 @@ set(CPACK_PACKAGE_VERSION_PATCH ${CBOR_VERSION_PATCH})
 
 include(CPack)
 
+#
+# Configure compilation flags and language features
+#
+
+include(CheckCSourceCompiles)
+
+check_c_source_compiles("
+  #include <stdio.h>
+  [[nodiscard]] int f(void) { return 42; }
+  int main(void) { return f(); }
+" HAS_NODISCARD_ATTRIBUTE)
+
+if (HAS_NODISCARD_ATTRIBUTE)
+  message(STATUS "[[nodiscard]] is supported.")
+  add_definitions(-D_CBOR_HAS_NODISCARD_ATTRIBUTE)
+  # Assume that if we have [[nodiscard]], we have some C23 support. May fail.
+  if(NOT DEFINED CMAKE_C_STANDARD)
+    message(STATUS "Switching to C23-like mode. To prevent this, pass -DCMAKE_C_STANDARD explicitly.")
+    # On Clang 16, this is resolved to -std=c2x
+    set(CMAKE_C_STANDARD 23 CACHE STRING "C language standard")
+  endif()
+endif()
+
 if(MINGW)
-    # https://github.com/PJK/libcbor/issues/13
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
+  # https://github.com/PJK/libcbor/issues/13
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
 elseif(NOT MSVC)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic")
+  # Default to C99
+  if(NOT DEFINED CMAKE_C_STANDARD)
+    set(CMAKE_C_STANDARD 99 CACHE STRING "C language standard")
+  endif()
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
 endif()
 
+# CMAKE_C_STANDARD set above
+set(CMAKE_C_STANDARD_REQUIRED ON)
+set(CMAKE_C_EXTENSIONS OFF)
+
 if(MSVC)
-    # This just doesn't work right -- https://msdn.microsoft.com/en-us/library/5ft82fed.aspx
-    set(CBOR_RESTRICT_SPECIFIER "")
+  # This just doesn't work right --
+  # https://msdn.microsoft.com/en-us/library/5ft82fed.aspx
+  set(CBOR_RESTRICT_SPECIFIER "")
+  # Safe stdio is only available in C11
+  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+
+  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /sdl")
 else()
-    set(CBOR_RESTRICT_SPECIFIER "restrict")
+  set(CBOR_RESTRICT_SPECIFIER "restrict")
 
-    set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall -g -ggdb -DDEBUG=true")
-    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -Wall -DNDEBUG")
+  set(CMAKE_C_FLAGS_DEBUG
+      "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall -Wextra -g -ggdb -DDEBUG=true")
+  set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -Wall -Wextra -DNDEBUG")
 
-    if(SANITIZE)
-        set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} \
+  if(SANITIZE)
+    set(CMAKE_C_FLAGS_DEBUG
+        "${CMAKE_C_FLAGS_DEBUG} \
             -fsanitize=undefined -fsanitize=address \
             -fsanitize=bounds -fsanitize=alignment")
-    endif()
-endif()
-
-set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-g")
+  endif()
 
+  set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-g")
+endif()
 
 include(CheckTypeSize)
 check_type_size("size_t" SIZEOF_SIZE_T)
 if(SIZEOF_SIZE_T LESS 8)
-    message(WARNING "Your size_t is less than 8 bytes. Decoding of huge items that would exceed the memory address space will always fail. Consider implementing a custom streaming decoder if you need to deal with huge items.")
+  message(
+    WARNING
+      "Your size_t is less than 8 bytes. \
+      Decoding of huge items that would exceed the memory address space \
+      will always fail. Consider implementing a custom streaming \
+      decoder if you need to deal with huge items.")
+else()
+  add_definitions(-DEIGHT_BYTE_SIZE_T)
+endif()
+
+check_c_source_compiles("
+    int main() {
+        __builtin_unreachable();
+        return 0;
+    }
+" HAS_BUILTIN_UNREACHABLE)
+
+if (HAS_BUILTIN_UNREACHABLE)
+  add_definitions(-D_CBOR_HAS_BUILTIN_UNREACHABLE)
+endif()
+
+# CMake >= 3.9.0 enables LTO for GCC and Clang with INTERPROCEDURAL_OPTIMIZATION
+# Policy CMP0069 enables this behavior when we set the minimum CMake version <
+# 3.9.0 Checking for LTO support before setting INTERPROCEDURAL_OPTIMIZATION is
+# mandatory with CMP0069 set to NEW.
+set(LTO_SUPPORTED FALSE)
+if(${CMAKE_VERSION} VERSION_GREATER "3.9.0" OR ${CMAKE_VERSION} VERSION_EQUAL
+                                               "3.9.0")
+  cmake_policy(SET CMP0069 NEW)
+  # Require LTO support to build libcbor with newer CMake versions
+  include(CheckIPOSupported)
+  check_ipo_supported(RESULT LTO_SUPPORTED)
+endif()
+
+if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
+  set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
+endif()
+
+if(LTO_SUPPORTED)
+  message(
+    STATUS
+      "LTO is supported and CMAKE_INTERPROCEDURAL_OPTIMIZATION=${CMAKE_INTERPROCEDURAL_OPTIMIZATION}"
+  )
 else()
-    add_definitions(-DEIGHT_BYTE_SIZE_T)
+  message(STATUS "LTO is not supported")
 endif()
*** 10870 LINES SKIPPED ***


home | help