From 4616230ac0e1b7d1e3bb43cb30fd0b6a107df58e Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 21 Oct 2021 21:49:18 +0300 Subject: [PATCH] Fix the README and update coverage measurement (#10) * Update README as suggested in https://github.com/pavel-kirienko/o1heap/issues/4\#issuecomment-948071875 * Update CI configuration * Enable sonarcloud on push, too --- .github/workflows/main.yml | 8 +++++--- README.md | 8 +++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e36e9a..10e3707 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,6 @@ jobs: run: make test sonarcloud: - if: endsWith(github.base_ref, 'master') || endsWith(github.ref, 'master') runs-on: ubuntu-latest env: SONAR_SCANNER_VERSION: 4.6.1.2450 @@ -87,14 +86,16 @@ jobs: unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH + # Pass NDEBUG to exclude assert() from coverage; see https://github.com/pavel-kirienko/o1heap/issues/9 - name: Run build-wrapper run: | - cmake tests -DCMAKE_BUILD_TYPE=Debug -DNO_STATIC_ANALYSIS=1 + cmake tests -DCMAKE_BUILD_TYPE=Debug -DNO_STATIC_ANALYSIS=1 -DCMAKE_C_FLAGS='-DNDEBUG=1' build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make all make test gcov --preserve-paths --long-file-names $(find CMakeFiles/test_general_cov.dir -name '*.gcno') gcov --preserve-paths --long-file-names $(find CMakeFiles/test_private_cov.dir -name '*.gcno') + # https://community.sonarsource.com/t/analyzing-a-header-only-c-library/51468 - name: Run sonar-scanner run: > sonar-scanner @@ -105,9 +106,10 @@ jobs: --define sonar.cfamily.gcov.reportsPath="." --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" --define sonar.cfamily.cache.enabled="false" - --define sonar.cfamily.threads=1 + --define sonar.cfamily.threads=2 --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.login=${{ secrets.SONAR_TOKEN }} + $([ -z "$GITHUB_BASE_REF" ] && echo "--define sonar.branch.name=${GITHUB_REF##*/}" || true) style_check: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 6bfb2f4..4841402 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # O(1) heap +[![Main Workflow](https://github.com/pavel-kirienko/o1heap/actions/workflows/main.yml/badge.svg)](https://github.com/pavel-kirienko/o1heap/actions/workflows/main.yml) [![Build Status](https://travis-ci.org/pavel-kirienko/o1heap.svg?branch=master)](https://travis-ci.org/pavel-kirienko/o1heap) -[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=pavel-kirienko_o1heap&metric=coverage)](https://sonarcloud.io/dashboard?id=pavel-kirienko_o1heap) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=pavel-kirienko_o1heap&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=pavel-kirienko_o1heap) O1heap is a highly deterministic constant-complexity memory allocator designed for @@ -159,10 +159,6 @@ No special compiler options are needed to compile the source file (if you find t Dedicate a memory arena for the heap, and pass a pointer to it along with its size to the initialization function `o1heapInit(..)`. -In the case of concurrent environments, also pass pointers to the synchronization locking/unlocking functions --- they will be invoked by the library to facilitate atomic transactions. -Alternatively, some applications (where possible) might benefit from using a separate heap per thread to avoid -the synchronization overhead and reduce contention. Allocate and deallocate memory using `o1heapAllocate(..)` and `o1heapFree(..)`. Their semantics are compatible with `malloc(..)` and `free(..)` plus additional behavioral guarantees @@ -171,6 +167,8 @@ Their semantics are compatible with `malloc(..)` and `free(..)` plus additional If necessary, periodically invoke `o1heapDoInvariantsHold(..)` to ensure that the heap is functioning correctly and its internal data structures are not damaged. +Avoid concurrent access to the heap. Use locking if necessary. + ### Build configuration options The preprocessor options given below can be overridden to fine-tune the implementation.