From 7f9d75b7f3ab7e767eb0b869b48c7ac6bed77725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20S=2E=20Ga=C3=9Fmann?= Date: Sat, 25 Nov 2023 17:36:14 +0100 Subject: [PATCH 1/6] build: Update copier-cpp template to version 0.3.3 --- .clang-format | 84 ++++++++++-------- .copier-answers.yml | 6 +- .devcontainer/Dockerfile | 64 -------------- .devcontainer/devcontainer.json | 4 +- .github/workflows/cpp-ci.yml | 60 ++++++++----- .gitlab-ci.yml | 75 ---------------- CMakeLists.txt | 21 +++-- CMakePresets.json | 82 ++++++++++++++++-- apps/vefs/cli/error.hpp | 4 +- include/vefs/config.hpp | 20 +++++ include/vefs/detail/workaround.hpp | 34 ++++++++ include/vefs/disappointment/errc.hpp | 8 +- sources.cmake | 85 +++++++++++-------- src/vefs/config.test.cpp | 12 +++ src/vefs/detail/workaround.test.cpp | 12 +++ src/vefs/vfilesystem.cpp | 8 +- tools/config.hpp.in | 19 +++++ tools/toolchains/clang-15-x64-linux.cmake | 9 -- tools/toolchains/gcc-12-x64-linux.cmake | 7 -- tools/toolchains/x64-linux-clang-16.cmake | 9 ++ ...-x64-linux.cmake => x64-linux-clang.cmake} | 4 +- tools/toolchains/x64-linux-gcc-12.cmake | 7 ++ .../toolchains/x64-macos-clang-16-brew.cmake | 12 +++ tools/toolchains/x64-macos-gcc-12.cmake | 8 ++ ...lang-15.cmake => x64-linux-clang-16.cmake} | 8 +- tools/triplets/x64-linux-clang.cmake | 8 +- tools/triplets/x64-osx-clang-16-brew.cmake | 11 +++ tools/triplets/x64-osx-gcc-12.cmake | 6 ++ vcpkg-configuration.json | 4 +- 29 files changed, 399 insertions(+), 292 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 .gitlab-ci.yml create mode 100644 include/vefs/config.hpp create mode 100644 include/vefs/detail/workaround.hpp create mode 100644 src/vefs/config.test.cpp create mode 100644 src/vefs/detail/workaround.test.cpp create mode 100644 tools/config.hpp.in delete mode 100644 tools/toolchains/clang-15-x64-linux.cmake delete mode 100644 tools/toolchains/gcc-12-x64-linux.cmake create mode 100644 tools/toolchains/x64-linux-clang-16.cmake rename tools/toolchains/{clang-x64-linux.cmake => x64-linux-clang.cmake} (51%) create mode 100644 tools/toolchains/x64-linux-gcc-12.cmake create mode 100644 tools/toolchains/x64-macos-clang-16-brew.cmake create mode 100644 tools/toolchains/x64-macos-gcc-12.cmake rename tools/triplets/{x64-linux-clang-15.cmake => x64-linux-clang-16.cmake} (57%) create mode 100644 tools/triplets/x64-osx-clang-16-brew.cmake create mode 100644 tools/triplets/x64-osx-gcc-12.cmake diff --git a/.clang-format b/.clang-format index 14e2ddf..d399c84 100644 --- a/.clang-format +++ b/.clang-format @@ -3,7 +3,7 @@ BasedOnStyle: LLVM --- Language: Cpp -BasedOnStyle: LLVM +#BasedOnStyle: LLVM AccessModifierOffset: -4 AlignAfterOpenBracket: Align AlignArrayOfStructures: Right @@ -32,16 +32,18 @@ AlignConsecutiveMacros: AlignCompound: false PadOperators: false AlignEscapedNewlines: Right -AlignOperands: AlignAfterOperator -AlignTrailingComments: true +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 1 AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true -AllowShortEnumsOnASingleLine: true AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: false AllowShortFunctionsOnASingleLine: None -AllowShortLambdasOnASingleLine: Inline AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Inline AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None @@ -53,52 +55,48 @@ AttributeMacros: - DPLX_ATTR_NO_UNIQUE_ADDRESS BinPackArguments: true BinPackParameters: false +BitFieldColonSpacing: Both BraceWrapping: AfterCaseLabel: false - AfterClass: false + AfterClass: true AfterControlStatement: Always - AfterEnum: false - AfterFunction: false - AfterNamespace: false + AfterEnum: true + AfterExternBlock: true + AfterFunction: true + AfterNamespace: true AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true BeforeLambdaBody: false - BeforeWhile: false + BeforeWhile: true IndentBraces: false SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: true +BreakArrays: false BreakBeforeBinaryOperators: All BreakBeforeConceptDeclarations: Always -BreakBeforeBraces: Allman -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeComma +BreakBeforeBraces: Custom +BreakBeforeInlineASMColon: OnlyMultiline BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false +BreakInheritanceList: BeforeComma BreakStringLiterals: true ColumnLimit: 80 CommentPragmas: '^ IWYU pragma:' -QualifierAlignment: Right CompactNamespaces: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 8 Cpp11BracedListStyle: true -DeriveLineEnding: true DerivePointerAlignment: false DisableFormat: false EmptyLineAfterAccessModifier: Never EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: false -PackConstructorInitializers: Never -# deprecated, replaced by PackConstructorInitializers -#ConstructorInitializerAllOnOneLineOrOnePerLine: true -#AllowAllConstructorInitializersOnNextLine: false FixNamespaceComments: true ForEachMacros: - foreach @@ -125,20 +123,29 @@ IncludeCategories: IncludeIsMainRegex: '(\.test|-tests)?$' IncludeIsMainSourceRegex: '' IndentAccessModifiers: false -IndentCaseLabels: false IndentCaseBlocks: false +IndentCaseLabels: false +IndentExternBlock: NoIndent IndentGotoLabels: true IndentPPDirectives: None -IndentExternBlock: NoIndent IndentRequiresClause: true IndentWidth: 4 IndentWrappedFunctionNames: false InsertBraces: true +InsertNewlineAtEOF: true InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 8 + BinaryMinDigits: 9 + Decimal: 3 + DecimalMinDigits: 5 + Hex: 4 + HexMinDigits: 5 JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: true LambdaBodyIndentation: Signature +LineEnding: LF MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 @@ -148,6 +155,7 @@ ObjCBlockIndentWidth: 2 ObjCBreakBeforeNestedBlockParam: true ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true +PackConstructorInitializers: Never PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 @@ -156,22 +164,26 @@ PenaltyBreakOpenParenthesis: 0 PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Right PPIndentWidth: -1 +QualifierAlignment: Right ReferenceAlignment: Pointer ReflowComments: true RemoveBracesLLVM: false +RemoveSemicolon: false # TODO: evaluate RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope SeparateDefinitionBlocks: Leave ShortNamespaceLines: 1 SortIncludes: CaseInsensitive SortJavaStaticImport: Before -SortUsingDeclarations: true +SortUsingDeclarations: LexicographicNumeric SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default SpaceBeforeAssignmentOperators: true SpaceBeforeCaseColon: false SpaceBeforeCpp11BracedList: false @@ -188,8 +200,8 @@ SpaceBeforeParensOptions: # this is ignored due to SpaceBeforeParens != "Custom" AfterRequiresInClause: false AfterRequiresInExpression: false BeforeNonEmptyParentheses: false -SpaceAroundPointerQualifiers: Default SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false SpaceInEmptyBlock: false SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 @@ -202,16 +214,16 @@ SpacesInLineCommentPrefix: Maximum: -1 SpacesInParentheses: false SpacesInSquareBrackets: false -SpaceBeforeSquareBrackets: false -BitFieldColonSpacing: Both Standard: Latest StatementAttributeLikeMacros: StatementMacros: TabWidth: 4 -UseCRLF: false UseTab: Never WhitespaceSensitiveMacros: - - STRINGIZE - - PP_STRINGIZE - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE ... + diff --git a/.copier-answers.yml b/.copier-answers.yml index 09a0e4d..f754e88 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,12 +1,12 @@ # Changes here will be overwritten by Copier -_commit: v0.3.1 +_commit: v0.3.3 _src_path: gh:deeplex/copier-cpp email: henrik.gassmann@adesso.de full_name: Henrik Gaßmann -header_config: false +header_config: true header_only: false namespace: vefs project_name: vefs project_slug: vefs -workaround_header: false +workaround_header: true year: 2017-2023 diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index f299b2b..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,64 +0,0 @@ -FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04 - -USER root -SHELL [ "/bin/bash", "-c" ] - -RUN export DEBIAN_FRONTEND=noninteractive; \ - apt-get -qq update && apt-get -qq install --no-install-recommends \ - bash-completion \ - build-essential \ - clang-15 \ - clang-format-15 \ - clang-tidy-15 \ - curl \ - g++-12 \ - gcc-12 \ - gdb \ - git \ - lldb-15 \ - llvm-15 \ - ninja-build \ - pkg-config \ - python3 \ - python3-pip \ - tar \ - unzip \ - zip \ - zsh \ - && apt-get -qq autoremove \ - && apt-get -qq clean \ - && rm -rf /var/lib/apt/lists/* \ - && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 120 --slave /usr/bin/g++ g++ /usr/bin/g++-12 \ - && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 150 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-15 - -ARG CMAKE_VERSION="3.22.6" -RUN declare -A archs=( ["amd64"]="x86_64" ["arm64"]="aarch64" ); \ - architecture=$(dpkg --print-architecture); \ - echo "Detected arch: $architecture => ${archs[$architecture]}"; \ - [[ "${archs[$architecture]}" != "" ]] \ - && mkdir -p /opt/cmake \ - && CMAKE_BINARY_NAME="cmake-$CMAKE_VERSION-linux-${archs[$architecture]}.sh" \ - && TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX) \ - && pushd "$TMP_DIR" \ - && curl -sSL "https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/$CMAKE_BINARY_NAME" -O \ - && sh "$TMP_DIR/$CMAKE_BINARY_NAME" --prefix=/opt/cmake --skip-license \ - && popd \ - && rm -rf "$TMP_DIR" \ - && ln -s -t /usr/local/bin /opt/cmake/bin/cmake /opt/cmake/bin/ccmake /opt/cmake/bin/ctest /opt/cmake/bin/cpack - -# Setup ENV vars for vcpkg -ENV VCPKG_ROOT=/usr/local/vcpkg \ - VCPKG_NO_CI=1 -RUN mkdir -p "$VCPKG_ROOT" \ - && chown vscode:vscode "$VCPKG_ROOT" \ - && su vscode -c "git clone -c core.eol=lf -c core.autocrlf=false -c fsck.zeroPaddedFilemode=ignore -c fetch.fsck.zeroPaddedFilemode=ignore -c receive.fsck.zeroPaddedFilemode=ignore https://github.com/microsoft/vcpkg $VCPKG_ROOT" \ - && VCPKG_DOWNLOADS="$HOME/.cache/vcpkg/downloads" \ - && sh "$VCPKG_ROOT/bootstrap-vcpkg.sh" \ - && rm -rf "$VCPKG_DOWNLOADS" \ - && ln -s "$VCPKG_ROOT/vcpkg" "/usr/local/bin/vcpkg" \ - && echo 'export VCPKG_DOWNLOADS="$HOME/.cache/vcpkg/downloads"' >> ~vscode/.zshenv \ - && echo 'export VCPKG_DOWNLOADS="$HOME/.cache/vcpkg/downloads"' >> ~vscode/.bash_profile - -USER vscode - -RUN python3 -m pip install --user pipenv diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1b8ff61..943b21f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,9 +2,7 @@ // README at: https://github.com/devcontainers/templates/tree/main/src/cpp { "name": "C++", - "build": { - "dockerfile": "Dockerfile" - }, + "image": "ghcr.io/deeplex/devcontainer-cpp:ubuntu-22.04", "customizations": { "vscode": { "extensions": [ diff --git a/.github/workflows/cpp-ci.yml b/.github/workflows/cpp-ci.yml index d1b44b6..2f6875f 100644 --- a/.github/workflows/cpp-ci.yml +++ b/.github/workflows/cpp-ci.yml @@ -14,16 +14,36 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-22.04, windows-2022] + os: [macos-13, ubuntu-22.04, windows-2022] compiler: [gcc, clang, msvc] exclude: - - os: windows-2022 - compiler: gcc + - os: macos-13 + compiler: msvc - os: ubuntu-22.04 compiler: msvc + - os: windows-2022 + compiler: gcc include: + - os: macos-13 + triplet: x64-macos + - os: macos-13 + compiler: clang + triplet: x64-macos + install: | + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install llvm@16 - os: ubuntu-22.04 triplet: x64-linux + install: | + sudo apt-get -qq update + sudo apt-get -qq install nasm + - os: ubuntu-22.04 + triplet: x64-linux + compiler: clang + install: | + sudo cp tools/llvm-snapshot.gpg.key.asc /etc/apt/trusted.gpg.d/llvm-snapshot.asc + sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" + sudo apt-get -qq update + sudo apt-get -qq -y install clang-16 nasm - os: windows-2022 triplet: x64-windows @@ -38,23 +58,20 @@ jobs: uses: actions/setup-go@v4 with: go-version: '>=1.20.7' - - name: Install nasm (boringSSL build dependency) - if: ${{ startsWith(matrix.os, 'ubuntu-') }} - run: | - sudo apt-get -qq update - sudo apt-get -qq install nasm + + - name: Install required packages / compilers + if: ${{ matrix.install }} + run: ${{ matrix.install }} - uses: lukka/get-cmake@latest with: cmakeVersion: 3.22.6 - name: Initialize vcpkg - uses: lukka/run-vcpkg@v10 + uses: lukka/run-vcpkg@v11 with: vcpkgDirectory: ${{ github.workspace }}/build/vcpkg - vcpkgGitCommitId: f6a5d4e8eb7476b8d7fc12a56dff300c1c986131 - prependedCacheKey: compiler=${{ matrix.compiler }} - #appendedCacheKey: r00 + vcpkgGitCommitId: a42af01b72c28a8e1d7b48107b33e4f286a55ef6 - name: Build ${{ matrix.triplet }}-${{ matrix.compiler }} preset uses: lukka/run-cmake@v10 @@ -90,12 +107,17 @@ jobs: steps: - uses: actions/checkout@v3 - - name: "Install clang-tools-15" + - name: Install go (boringSSL build dependency) + uses: actions/setup-go@v4 + with: + go-version: '>=1.20.7' + + - name: "Install clang-tools-16" run: | sudo cp ${{ github.workspace }}/tools/llvm-snapshot.gpg.key.asc /etc/apt/trusted.gpg.d/llvm-snapshot.asc - sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" + sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" sudo apt-get -qq update - sudo apt-get -qq -y install clang-15 clang-tidy-15 clang-format-15 + sudo apt-get -qq -y install clang-16 clang-tidy-16 clang-format-16 nasm - name: Install go (boringSSL build dependency) uses: actions/setup-go@v4 @@ -111,12 +133,10 @@ jobs: cmakeVersion: 3.22.6 - name: Initialize vcpkg - uses: lukka/run-vcpkg@v10 + uses: lukka/run-vcpkg@v11 with: vcpkgDirectory: ${{ github.workspace }}/../vcpkg - vcpkgGitCommitId: f6a5d4e8eb7476b8d7fc12a56dff300c1c986131 - prependedCacheKey: compiler=clang-15 - #appendedCacheKey: r00 + vcpkgGitCommitId: a42af01b72c28a8e1d7b48107b33e4f286a55ef6 - name: Configure x64-linux-clang preset uses: lukka/run-cmake@v10 @@ -129,7 +149,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: 15.0.7 + version: 16.0.6 style: file # use .clang-format settings tidy-checks: '' # use .clang-tidy settings extensions: cpp,hpp diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index d3fbe62..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,75 +0,0 @@ -include: - - project: '${MDC_CI_JOB_TEMPLATES_PREFIX}templates/ci-job-templates' - ref: master - file: 'global-vars.yml' - -variables: - VCPKG_DEFAULT_BINARY_CACHE: C:\cache\vcpkg\archives - VCPKG_DOWNLOADS: C:\cache\vcpkg\downloads - -image: ${DOCKER_REGISTRY_INTERN}/de.mdk.bs/ci-win-native:latest -stages: -- build -- test -- upload - -workflow: - rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH !~ /^wip/' - - -######################################################################## -# test template -.test: &test - stage: test - tags: - - windows-docker - - -######################################################################## -# build jobs -build: - stage: build - tags: - - windows-docker - before_script: - - '& "$env:VS_BUILD_TOOLS_ROOT\Common7\Tools\Launch-VsDevShell.ps1" -VsInstallationPath "$env:VS_BUILD_TOOLS_ROOT" -Arch amd64 -HostArch amd64 *>$null' - - mkdir -Force $env:VCPKG_DEFAULT_BINARY_CACHE,$env:VCPKG_DOWNLOADS *> $null - # fail on warnings if not building CI tags - - $WARNINGS_AS_ERRORS = If ($env:CI_COMMIT_TAG -eq $null) {"ON"} Else {"OFF"} - script: - - cmake --preset "x64-windows-msvc" -DWARNINGS_AS_ERRORS=$WARNINGS_AS_ERRORS - - cmake --build --preset "x64-windows-msvc" --config Debug - - cmake --build --preset "x64-windows-msvc" --config RelWithDebInfo - artifacts: - paths: - - build/x64-windows-msvc/apps/Debug - - build/x64-windows-msvc/apps/RelWithDebInfo - - build/x64-windows-msvc/Debug - - build/x64-windows-msvc/RelWithDebInfo - expire_in: 1 week - expose_as: binaries - -# test jobs -test:debug: - <<: *test - script: - - build\x64-windows-msvc\Debug\vefs-tests - -test:release: - <<: *test - script: - - build\x64-windows-msvc\RelWithDebInfo\vefs-tests - -release:dev_tools: - stage: upload - rules: - - if: '$CI_COMMIT_TAG' - when: on_success - tags: - - windows-docker - script: - - Invoke-WebRequest -Infile "build/x64-windows-msvc/apps/RelWithDebInfo/vefs.exe" -Method PUT -Uri "$env:ARTIFACTORY_URL/$env:ARTIFACTORY_REPO_STAGE_GENERIC/dev-tools/vefs/vefs-cli.exe" -Headers @{'X-JFrog-Art-Api'=$env:ARTIFACTORY_TOKEN} diff --git a/CMakeLists.txt b/CMakeLists.txt index 95ffe53..7bf62d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,13 +49,12 @@ endif() option(BUILD_CLI "Build the CommandLine-Interface" OFF) option(BUILD_TESTING "Build the unit tests" OFF) -option(VEFS_DISABLE_WORKAROUNDS "Disables all code workarounds" OFF) -option(VEFS_FLAG_OUTDATED_WORKAROUNDS "Raises compiler errors for all workarounds which need to be reevaluated" OFF) +option(VEFS_DISABLE_WORKAROUNDS "Disable all workarounds" OFF) +option(VEFS_FLAG_OUTDATED_WORKAROUNDS "Emit compiler errors for workarounds which are active, but haven't been validated for this version" OFF) set(VEFS_LLFIO_TARGET "sl" CACHE STRING "The llfio target to link against, can be 'hl', 'sl' or 'dl'") set_property(CACHE VEFS_LLFIO_TARGET PROPERTY STRINGS "hl;sl;dl") - ######################################################################## # dependencies @@ -169,12 +168,11 @@ target_compile_definitions(vefs VEFS_FLAG_OUTDATED_WORKAROUNDS=$ ) -target_include_directories(vefs - PUBLIC - $ - $ - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/src +target_include_directories(vefs PUBLIC + $ + $ + $ + $ ) if (CMAKE_SYSTEM_NAME STREQUAL "Windows") @@ -244,6 +242,11 @@ install(DIRECTORY include/vefs FILES_MATCHING REGEX ".*\\.h(pp)?" ) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated/src + TYPE INCLUDE + FILES_MATCHING + REGEX ".*\\.h(pp)?" +) install(TARGETS vefs compiler_settings EXPORT vefs-targets) install(EXPORT vefs-targets diff --git a/CMakePresets.json b/CMakePresets.json index 98fdad7..9fa25c3 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -130,8 +130,8 @@ "x64-linux" ], "cacheVariables": { - "VCPKG_TARGET_TRIPLET": "x64-linux-clang", - "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/clang-x64-linux.cmake" + "VCPKG_TARGET_TRIPLET": "x64-linux-clang-16", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-clang-16.cmake" } }, { @@ -140,8 +140,8 @@ "x64-linux-clang" ], "cacheVariables": { - "VCPKG_TARGET_TRIPLET": "x64-linux-clang-15", - "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/clang-15-x64-linux.cmake", + "VCPKG_TARGET_TRIPLET": "x64-linux-clang-16", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-clang-16.cmake", "CMAKE_EXPORT_COMPILE_COMMANDS": true } }, @@ -151,10 +151,41 @@ "x64-linux" ], "cacheVariables": { - "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/gcc-12-x64-linux.cmake", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-gcc-12.cmake", "CMAKE_CXX_FLAGS": "-fconcepts-diagnostics-depth=0 -ftemplate-backtrace-limit=0 -fsanitize=address,leak,undefined -g -fno-omit-frame-pointer", "CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address,leak,undefined" } + }, + { + "name": "x64-macos", + "hidden": true, + "inherits": [ "base" ], + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "x64-osx" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "macOS" + ] + } + } + }, + { + "name": "x64-macos-clang", + "inherits": [ "x64-macos" ], + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "x64-osx-clang-16-brew", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-macos-clang-16-brew.cmake" + } + }, + { + "name": "x64-macos-gcc", + "inherits": [ "x64-macos" ], + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "x64-osx-gcc-12", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-macos-gcc-12.cmake" + } } ], "buildPresets": [ @@ -197,6 +228,26 @@ "name": "x64-linux-gcc-release", "inherits": "x64-linux-gcc", "configuration": "RelWithDebInfo" + }, + { + "name": "x64-macos-clang", + "configurePreset": "x64-macos-clang", + "configuration": "Debug" + }, + { + "name": "x64-macos-clang-release", + "inherits": "x64-macos-clang", + "configuration": "RelWithDebInfo" + }, + { + "name": "x64-macos-gcc", + "configurePreset": "x64-macos-gcc", + "configuration": "Debug" + }, + { + "name": "x64-macos-gcc-release", + "inherits": "x64-macos-gcc", + "configuration": "RelWithDebInfo" } ], "testPresets": [ @@ -248,6 +299,27 @@ "name": "x64-linux-gcc-release", "inherits": "x64-linux-gcc", "configuration": "RelWithDebInfo" + }, + { + "name": "x64-macos-clang", + "configurePreset": "x64-macos-clang", + "configuration": "Debug" + }, + { + "name": "x64-macos-clang-release", + "inherits": "x64-macos-clang", + "configuration": "RelWithDebInfo" + }, + { + "name": "x64-macos-gcc", + "inherits": "sanitizer_env", + "configurePreset": "x64-macos-gcc", + "configuration": "Debug" + }, + { + "name": "x64-macos-gcc-release", + "inherits": "x64-macos-gcc", + "configuration": "RelWithDebInfo" } ] } \ No newline at end of file diff --git a/apps/vefs/cli/error.hpp b/apps/vefs/cli/error.hpp index 7740c53..b41a11c 100644 --- a/apps/vefs/cli/error.hpp +++ b/apps/vefs/cli/error.hpp @@ -53,8 +53,6 @@ class cli_domain_type : public system_error::status_code_domain using base = system_error::status_code_domain; template friend class system_error::status_code; - template - friend class system_error::detail::indirecting_domain; public: static constexpr std::string_view uuid @@ -161,7 +159,7 @@ class cli_domain_type : public system_error::status_code_domain .value(); return system_error::errc::unknown != sysErrc - && map_to_generic(alhs.value()) == sysErrc; + && map_to_generic(alhs.value()) == sysErrc; } return false; } diff --git a/include/vefs/config.hpp b/include/vefs/config.hpp new file mode 100644 index 0000000..2a1443d --- /dev/null +++ b/include/vefs/config.hpp @@ -0,0 +1,20 @@ + +// Copyright 2017-2023 Henrik Gaßmann +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#pragma once + +// the configuration generated by cmake is fully optional +#if __has_include() +#include +#endif + +#if !defined(VEFS_DISABLE_WORKAROUNDS) +#define VEFS_DISABLE_WORKAROUNDS 0 +#endif +#if !defined(VEFS_FLAG_OUTDATED_WORKAROUNDS) +#define VEFS_FLAG_OUTDATED_WORKAROUNDS 0 +#endif diff --git a/include/vefs/detail/workaround.hpp b/include/vefs/detail/workaround.hpp new file mode 100644 index 0000000..b21e09d --- /dev/null +++ b/include/vefs/detail/workaround.hpp @@ -0,0 +1,34 @@ + +// Copyright 2017-2023 Henrik Gaßmann +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#pragma once + +#include +#include + +#include +// NOLINTBEGIN(cppcoreguidelines-macro-usage) + +// these macros are very similar to those in +// but offer library specific configuration knobs + +// guard for bugs which have been resolved with a known (compiler) version +#define VEFS_WORKAROUND(symbol, comp, major, minor, patch) \ + DPLX_XDEF_WORKAROUND(VEFS_DISABLE_WORKAROUNDS, symbol, comp, major, \ + minor, patch) + +// guard for bugs which have _not_ been resolved known (compiler) version +// i.e. we need to periodically test whether they have been resolved +// after which we can move them in the upper category +#define VEFS_WORKAROUND_TESTED_AT(symbol, major, minor, patch) \ + DPLX_XDEF_WORKAROUND_TESTED_AT(VEFS_DISABLE_WORKAROUNDS, \ + VEFS_FLAG_OUTDATED_WORKAROUNDS, \ + symbol, major, minor, patch) + +//////////////////////////////////////////////////////////////////////////////// + +// NOLINTEND(cppcoreguidelines-macro-usage) diff --git a/include/vefs/disappointment/errc.hpp b/include/vefs/disappointment/errc.hpp index 606f062..0b96b06 100644 --- a/include/vefs/disappointment/errc.hpp +++ b/include/vefs/disappointment/errc.hpp @@ -45,8 +45,6 @@ class archive_domain_type : public system_error::status_code_domain using base = system_error::status_code_domain; template friend class system_error::status_code; - template - friend class system_error::detail::indirecting_domain; public: static constexpr std::string_view uuid @@ -85,7 +83,7 @@ class archive_domain_type : public system_error::status_code_domain -> bool override { return static_cast(code).value() - != archive_errc::success; + != archive_errc::success; } constexpr auto map_to_generic(value_type const value) const noexcept @@ -183,7 +181,7 @@ class archive_domain_type : public system_error::status_code_domain if (rhs.domain() == *this) { return alhs.value() - == static_cast(rhs).value(); + == static_cast(rhs).value(); } else if (rhs.domain() == system_error::generic_code_domain) { @@ -192,7 +190,7 @@ class archive_domain_type : public system_error::status_code_domain .value(); return system_error::errc::unknown != sysErrc - && map_to_generic(alhs.value()) == sysErrc; + && map_to_generic(alhs.value()) == sysErrc; } return false; } diff --git a/sources.cmake b/sources.cmake index 30adb63..f4dba22 100644 --- a/sources.cmake +++ b/sources.cmake @@ -8,6 +8,9 @@ dplx_target_sources(vefs # core archive_fwd.hpp llfio.hpp span.hpp + + config.hpp + detail/workaround.hpp PRIVATE # the first added source file determines target language @@ -66,7 +69,7 @@ dplx_target_sources(vefs # cache cache/bloom_filter.hpp cache/spectral_bloom_filter.cpp cache/spectral_bloom_filter.hpp - + cache/cache_mt.cpp cache/cache_mt.hpp cache/cache_page.cpp @@ -210,42 +213,50 @@ dplx_target_sources(vefs # hash hash/spooky_v2.cpp ) +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated/src/vefs/detail") +configure_file(tools/config.hpp.in "${CMAKE_CURRENT_BINARY_DIR}/generated/src/vefs/detail/config.hpp" @ONLY) +target_sources(vefs PUBLIC $) + if (BUILD_TESTING) - target_sources(vefs-tests PRIVATE - tests/vefs-tests.cpp - - tests/test_utils/boost-unit-test.hpp - tests/test_utils/libb2_none_blake2b_crypto_provider.cpp - tests/test_utils/libb2_none_blake2b_crypto_provider.hpp - tests/test_utils/mocks.hpp - tests/test_utils/test-utils.cpp - tests/test_utils/test-utils.hpp - - tests/io_buffer_manager.test.cpp - tests/sector_device-tests.cpp - tests/sector_tree_mt-tests.cpp - tests/sector_tree_seq-tests.cpp - tests/archive-tests.cpp - tests/vfile-tests.cpp - tests/vfilesystem-tests.cpp - tests/span-tests.cpp - tests/crypto_provider-tests.cpp - tests/block_manager-tests.cpp - tests/tree_lut-tests.cpp - tests/tree_walker-tests.cpp - tests/archive_file_id_tests.cpp - tests/archive-integration-tests.cpp - - tests/vefs/hash/hash_algorithm.test.cpp - tests/vefs/hash/spooky_v2.test.cpp - - tests/vefs/cache/bloom_filter.test.cpp - tests/vefs/cache/cache_mt.test.cpp - tests/vefs/cache/cache_page.test.cpp - tests/vefs/cache/eviction_policy.test.cpp - tests/vefs/cache/lru_policy.test.cpp - tests/vefs/cache/slru_policy.test.cpp - tests/vefs/cache/spectral_bloom_filter.test.cpp - tests/vefs/cache/w-tinylfu_policy.test.cpp + dplx_target_sources(vefs-tests PRIVATE + MODE VERBATIM + BASE_DIR ../tests + + PRIVATE + vefs-tests.cpp + + test_utils/boost-unit-test.hpp + test_utils/libb2_none_blake2b_crypto_provider.cpp + test_utils/libb2_none_blake2b_crypto_provider.hpp + test_utils/mocks.hpp + test_utils/test-utils.cpp + test_utils/test-utils.hpp + + io_buffer_manager.test.cpp + sector_device-tests.cpp + sector_tree_mt-tests.cpp + sector_tree_seq-tests.cpp + archive-tests.cpp + vfile-tests.cpp + vfilesystem-tests.cpp + span-tests.cpp + crypto_provider-tests.cpp + block_manager-tests.cpp + tree_lut-tests.cpp + tree_walker-tests.cpp + archive_file_id_tests.cpp + archive-integration-tests.cpp + + vefs/hash/hash_algorithm.test.cpp + vefs/hash/spooky_v2.test.cpp + + vefs/cache/bloom_filter.test.cpp + vefs/cache/cache_mt.test.cpp + vefs/cache/cache_page.test.cpp + vefs/cache/eviction_policy.test.cpp + vefs/cache/lru_policy.test.cpp + vefs/cache/slru_policy.test.cpp + vefs/cache/spectral_bloom_filter.test.cpp + vefs/cache/w-tinylfu_policy.test.cpp ) endif() diff --git a/src/vefs/config.test.cpp b/src/vefs/config.test.cpp new file mode 100644 index 0000000..9eef9da --- /dev/null +++ b/src/vefs/config.test.cpp @@ -0,0 +1,12 @@ + +// Copyright 2017-2023 Henrik Gaßmann +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include "dplx/vefs/config.hpp" + +namespace vefs_tests +{ +} diff --git a/src/vefs/detail/workaround.test.cpp b/src/vefs/detail/workaround.test.cpp new file mode 100644 index 0000000..01f4bc0 --- /dev/null +++ b/src/vefs/detail/workaround.test.cpp @@ -0,0 +1,12 @@ + +// Copyright 2017-2023 Henrik Gaßmann +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include "dplx/vefs/detail/workaround.hpp" + +namespace vefs_tests +{ +} diff --git a/src/vefs/vfilesystem.cpp b/src/vefs/vfilesystem.cpp index 8146138..a15327b 100644 --- a/src/vefs/vfilesystem.cpp +++ b/src/vefs/vfilesystem.cpp @@ -1007,14 +1007,14 @@ auto vfilesystem::commit() -> result syncrx.assume_error() << ed::archive_file{"[archive-index]"}; - std::move(syncrx).assume_error().throw_exception(); + // note that this isn't a child of std::exception + throw std::move(syncrx).assume_error(); } }); } - catch (system_error::status_error> const &exc) + catch (system_error::error const &error) { - return exc.code().clone(); + return error.clone(); } catch (std::bad_alloc const &) { diff --git a/tools/config.hpp.in b/tools/config.hpp.in new file mode 100644 index 0000000..8085ec1 --- /dev/null +++ b/tools/config.hpp.in @@ -0,0 +1,19 @@ + +// Copyright 2017-2023 Henrik Gaßmann +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#pragma once + +// NOLINTBEGIN(modernize-macro-to-enum) +// NOLINTBEGIN(cppcoreguidelines-macro-usage) + +// #cmakedefine01 + +#cmakedefine01 VEFS_DISABLE_WORKAROUNDS +#cmakedefine01 VEFS_FLAG_OUTDATED_WORKAROUNDS + +// NOLINTEND(cppcoreguidelines-macro-usage) +// NOLINTEND(modernize-macro-to-enum) diff --git a/tools/toolchains/clang-15-x64-linux.cmake b/tools/toolchains/clang-15-x64-linux.cmake deleted file mode 100644 index c788743..0000000 --- a/tools/toolchains/clang-15-x64-linux.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(CMAKE_SYSTEM_PROCESSOR AMD64) - -set(CMAKE_C_COMPILER clang-15) -set(CMAKE_CXX_COMPILER clang++-15) - -set(CMAKE_C_STANDARD 17 CACHE STRING "default C standard target") -set(CMAKE_CXX_STANDARD 20 CACHE STRING "default C++ standard target") - -set(CMAKE_CXX_FLAGS_INIT "-fsized-deallocation") diff --git a/tools/toolchains/gcc-12-x64-linux.cmake b/tools/toolchains/gcc-12-x64-linux.cmake deleted file mode 100644 index 59f6e89..0000000 --- a/tools/toolchains/gcc-12-x64-linux.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(CMAKE_SYSTEM_PROCESSOR AMD64) - -set(CMAKE_C_COMPILER "gcc-12" CACHE STRING "C compiler") -set(CMAKE_CXX_COMPILER "g++-12" CACHE STRING "C++ compiler") - -set(CMAKE_C_STANDARD 17 CACHE STRING "default C standard target") -set(CMAKE_CXX_STANDARD 20 CACHE STRING "default C++ standard target") diff --git a/tools/toolchains/x64-linux-clang-16.cmake b/tools/toolchains/x64-linux-clang-16.cmake new file mode 100644 index 0000000..c4733c6 --- /dev/null +++ b/tools/toolchains/x64-linux-clang-16.cmake @@ -0,0 +1,9 @@ +set(CMAKE_SYSTEM_PROCESSOR AMD64) + +set(CMAKE_C_COMPILER clang-16) +set(CMAKE_CXX_COMPILER clang++-16) + +set(CMAKE_C_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) + +set(CMAKE_CXX_FLAGS_INIT "-fsized-deallocation") diff --git a/tools/toolchains/clang-x64-linux.cmake b/tools/toolchains/x64-linux-clang.cmake similarity index 51% rename from tools/toolchains/clang-x64-linux.cmake rename to tools/toolchains/x64-linux-clang.cmake index abdfe79..5220a4f 100644 --- a/tools/toolchains/clang-x64-linux.cmake +++ b/tools/toolchains/x64-linux-clang.cmake @@ -3,7 +3,7 @@ set(CMAKE_SYSTEM_PROCESSOR AMD64) set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) -set(CMAKE_C_STANDARD 17 CACHE STRING "default C standard target") -set(CMAKE_CXX_STANDARD 20 CACHE STRING "default C++ standard target") +set(CMAKE_C_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_FLAGS_INIT "-fsized-deallocation") diff --git a/tools/toolchains/x64-linux-gcc-12.cmake b/tools/toolchains/x64-linux-gcc-12.cmake new file mode 100644 index 0000000..a1790c6 --- /dev/null +++ b/tools/toolchains/x64-linux-gcc-12.cmake @@ -0,0 +1,7 @@ +set(CMAKE_SYSTEM_PROCESSOR AMD64) + +set(CMAKE_C_COMPILER gcc-12) +set(CMAKE_CXX_COMPILER g++-12) + +set(CMAKE_C_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) diff --git a/tools/toolchains/x64-macos-clang-16-brew.cmake b/tools/toolchains/x64-macos-clang-16-brew.cmake new file mode 100644 index 0000000..24c7483 --- /dev/null +++ b/tools/toolchains/x64-macos-clang-16-brew.cmake @@ -0,0 +1,12 @@ +set(CMAKE_SYSTEM_PROCESSOR AMD64) + +execute_process(COMMAND brew --prefix llvm@16 OUTPUT_VARIABLE BREW_LLVM_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(CMAKE_C_COMPILER "${BREW_LLVM_PATH}/bin/clang") +set(CMAKE_CXX_COMPILER "${BREW_LLVM_PATH}/bin/clang++") +set(CMAKE_OSX_SYSROOT /Applications/Xcode_15.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk) + +set(CMAKE_C_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) + +set(CMAKE_CXX_FLAGS_INIT "-fsized-deallocation") diff --git a/tools/toolchains/x64-macos-gcc-12.cmake b/tools/toolchains/x64-macos-gcc-12.cmake new file mode 100644 index 0000000..c1b4122 --- /dev/null +++ b/tools/toolchains/x64-macos-gcc-12.cmake @@ -0,0 +1,8 @@ +set(CMAKE_SYSTEM_PROCESSOR AMD64) + +set(CMAKE_C_COMPILER gcc-12) +set(CMAKE_CXX_COMPILER g++-12) +set(CMAKE_OSX_SYSROOT /Applications/Xcode_15.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk) + +set(CMAKE_C_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) diff --git a/tools/triplets/x64-linux-clang-15.cmake b/tools/triplets/x64-linux-clang-16.cmake similarity index 57% rename from tools/triplets/x64-linux-clang-15.cmake rename to tools/triplets/x64-linux-clang-16.cmake index c177d08..8455330 100644 --- a/tools/triplets/x64-linux-clang-15.cmake +++ b/tools/triplets/x64-linux-clang-16.cmake @@ -3,8 +3,8 @@ set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Linux) -set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/clang-15-x64-linux.cmake") +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/x64-linux-clang-16.cmake") -if (PORT STREQUAL "boringssl") - set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_CXX_STANDARD=17") -endif() +# if (PORT STREQUAL "boringssl") +# set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_CXX_STANDARD=17") +# endif() diff --git a/tools/triplets/x64-linux-clang.cmake b/tools/triplets/x64-linux-clang.cmake index f833319..3c1bd04 100644 --- a/tools/triplets/x64-linux-clang.cmake +++ b/tools/triplets/x64-linux-clang.cmake @@ -3,8 +3,8 @@ set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Linux) -set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/clang-x64-linux.cmake") +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/x64-linux-clang.cmake") -if (PORT STREQUAL "boringssl") - set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_CXX_STANDARD=17") -endif() +# if (PORT STREQUAL "boringssl") +# set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_CXX_STANDARD=17") +# endif() diff --git a/tools/triplets/x64-osx-clang-16-brew.cmake b/tools/triplets/x64-osx-clang-16-brew.cmake new file mode 100644 index 0000000..cbe5d61 --- /dev/null +++ b/tools/triplets/x64-osx-clang-16-brew.cmake @@ -0,0 +1,11 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES x86_64) +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/x64-macos-clang-16-brew.cmake") + +if(PORT STREQUAL "status-code") + set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DBUILD_TESTING=OFF") +endif() diff --git a/tools/triplets/x64-osx-gcc-12.cmake b/tools/triplets/x64-osx-gcc-12.cmake new file mode 100644 index 0000000..53c6db8 --- /dev/null +++ b/tools/triplets/x64-osx-gcc-12.cmake @@ -0,0 +1,6 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/x64-macos-gcc-12.cmake") diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 0e7043e..1a6ec09 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -2,13 +2,13 @@ "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg-configuration.schema.json", "default-registry": { "kind": "builtin", - "baseline": "f6a5d4e8eb7476b8d7fc12a56dff300c1c986131" + "baseline": "a42af01b72c28a8e1d7b48107b33e4f286a55ef6" }, "registries": [ { "kind": "git", "repository": "https://github.com/deeplex/vcpkg-registry", - "baseline": "f7982f12e092037c9ff86c3de381efca14377ddb", + "baseline": "0a1cf2aba847e4074950a3061f5f7251f388e61f", "packages": [ "base64", "concrete", From 8b0563428d9d28bd28bd05355df44b8181418199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20S=2E=20Ga=C3=9Fmann?= Date: Sat, 25 Nov 2023 17:36:43 +0100 Subject: [PATCH 2/6] build: Fix MSVS 2022 vcpkg incompatibility Downgrade boringssl to the last version working with `go` 1.16 due to the fact that MSVS 17.8 doesn't ship a vcpkg version which includes the `go` 1.21. update. And I haven't found a way to override the `VCPKG_ROOT` in Visual Studio. --- vcpkg.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vcpkg.json b/vcpkg.json index 7ed3dd1..b164bcc 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -30,6 +30,13 @@ "outcome", "stduuid" ], + "overrides": [ + { + "name": "boringssl", + "version-date": "2021-06-23", + "port-version": 4 + } + ], "features": { "cli": { "description": "Build the CLI", From 14efe41293a34104982808686f33dbac9ea73c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20S=2E=20Ga=C3=9Fmann?= Date: Sat, 25 Nov 2023 17:40:46 +0100 Subject: [PATCH 3/6] ci: Disable macos builds The library hasn't been fully ported do MacOS therefore it is futile to run CI checks on said platform. --- .github/workflows/cpp-ci.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/cpp-ci.yml b/.github/workflows/cpp-ci.yml index 2f6875f..1bac780 100644 --- a/.github/workflows/cpp-ci.yml +++ b/.github/workflows/cpp-ci.yml @@ -14,23 +14,14 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-13, ubuntu-22.04, windows-2022] + os: [ubuntu-22.04, windows-2022] compiler: [gcc, clang, msvc] exclude: - - os: macos-13 - compiler: msvc - os: ubuntu-22.04 compiler: msvc - os: windows-2022 compiler: gcc include: - - os: macos-13 - triplet: x64-macos - - os: macos-13 - compiler: clang - triplet: x64-macos - install: | - HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install llvm@16 - os: ubuntu-22.04 triplet: x64-linux install: | From ae2a29ddf88f99d75d62fc828837a5a24edc0efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20S=2E=20Ga=C3=9Fmann?= Date: Sat, 25 Nov 2023 19:51:55 +0100 Subject: [PATCH 4/6] fix: Workaround clang <=> gcc incompatibilities - clang poses as gcc, but doesn't grok all warning switches. - Retarget libstdc++ workarounds to libstdc++ defines --- apps/vefs/cli/key-provider/mdc.cpp | 4 ++-- src/vefs/cache/spectral_bloom_filter.hpp | 6 +++--- src/vefs/detail/io_buffer_manager.hpp | 4 ++-- src/vefs/vfilesystem.cpp | 4 ++-- tests/vefs/cache/cache_mt.test.cpp | 25 ++++++++++++++++------- tools/toolchains/x64-linux-clang-16.cmake | 2 +- tools/toolchains/x64-linux-clang.cmake | 2 +- tools/triplets/x64-linux-clang-16.cmake | 6 +++--- tools/triplets/x64-linux-clang.cmake | 6 +++--- 9 files changed, 35 insertions(+), 24 deletions(-) diff --git a/apps/vefs/cli/key-provider/mdc.cpp b/apps/vefs/cli/key-provider/mdc.cpp index e0a702b..87bbafd 100644 --- a/apps/vefs/cli/key-provider/mdc.cpp +++ b/apps/vefs/cli/key-provider/mdc.cpp @@ -19,13 +19,13 @@ #include "vefs/cli/commandlets/base.hpp" #include "vefs/cli/utils.hpp" -#if defined(DPLX_COMP_GNUC_AVAILABLE) +#if defined(DPLX_COMP_GNUC_AVAILABLE) && !defined(DPLX_COMP_GNUC_EMULATED) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Warray-bounds" #pragma GCC diagnostic ignored "-Wstringop-overflow" #endif #include -#if defined(DPLX_COMP_GNUC_AVAILABLE) +#if defined(DPLX_COMP_GNUC_AVAILABLE) && !defined(DPLX_COMP_GNUC_EMULATED) #pragma GCC diagnostic pop #endif diff --git a/src/vefs/cache/spectral_bloom_filter.hpp b/src/vefs/cache/spectral_bloom_filter.hpp index a1ff1cd..2d6c576 100644 --- a/src/vefs/cache/spectral_bloom_filter.hpp +++ b/src/vefs/cache/spectral_bloom_filter.hpp @@ -60,7 +60,7 @@ class spectral_bloom_filter static constexpr unsigned cell_limit = 1U << bits_per_cell; static constexpr unsigned cell_mask = cell_limit - 1U; static constexpr unsigned cell_reset_mask = cell_mask >> 1; -#if defined(BOOST_COMP_GNUC_AVAILABLE) +#if defined(BOOST_COMP_GNUC_AVAILABLE) && !defined(BOOST_COMP_GNUC_EMULATED) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuseless-cast" #endif @@ -68,7 +68,7 @@ class spectral_bloom_filter = static_cast(0x7777'7777'7777'7777U); static constexpr bucket_type bucket_oddity_mask = static_cast(0x1111'1111'1111'1111U); -#if defined(BOOST_COMP_GNUC_AVAILABLE) +#if defined(BOOST_COMP_GNUC_AVAILABLE) && !defined(BOOST_COMP_GNUC_EMULATED) #pragma GCC diagnostic pop #endif @@ -172,7 +172,7 @@ class spectral_bloom_filter { unsigned const incr = values[i] == estimate; mBuckets[bucketIndices[i]] += static_cast(incr) - << cellShifts[i]; + << cellShifts[i]; } return true; } diff --git a/src/vefs/detail/io_buffer_manager.hpp b/src/vefs/detail/io_buffer_manager.hpp index 93bf873..ea43fa8 100644 --- a/src/vefs/detail/io_buffer_manager.hpp +++ b/src/vefs/detail/io_buffer_manager.hpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -30,7 +30,7 @@ class io_buffer_manager { free_buffers_semaphore_type free_buffers; -#if VEFS_WORKAROUND_TESTED_AT(DPLX_COMP_GNUC, 12, 1, 0) +#if VEFS_WORKAROUND_TESTED_AT(BOOST_LIB_STD_GNU, 12, 1, 0) #else constexpr #endif diff --git a/src/vefs/vfilesystem.cpp b/src/vefs/vfilesystem.cpp index a15327b..eedf1e0 100644 --- a/src/vefs/vfilesystem.cpp +++ b/src/vefs/vfilesystem.cpp @@ -118,7 +118,7 @@ class vfilesystem::index_tree_layout int next_block; }; -#if defined(DPLX_COMP_GNUC_AVAILABLE) +#if defined(DPLX_COMP_GNUC_AVAILABLE) && !defined(DPLX_COMP_GNUC_EMULATED) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif @@ -362,7 +362,7 @@ class vfilesystem::index_tree_layout return as_span(mCurrentSector).subspan(alloc_map_size); } }; -#if defined(DPLX_COMP_GNUC_AVAILABLE) +#if defined(DPLX_COMP_GNUC_AVAILABLE) && !defined(DPLX_COMP_GNUC_EMULATED) #pragma GCC diagnostic pop #endif diff --git a/tests/vefs/cache/cache_mt.test.cpp b/tests/vefs/cache/cache_mt.test.cpp index 7f19532..c238288 100644 --- a/tests/vefs/cache/cache_mt.test.cpp +++ b/tests/vefs/cache/cache_mt.test.cpp @@ -1,6 +1,8 @@ #include "vefs/cache/cache_mt.hpp" +#include #include +#include #include "boost-unit-test.hpp" #include "test-utils.hpp" @@ -38,10 +40,10 @@ struct immovable_value_type } friend inline auto operator<<(std::ostream &out, - immovable_value_type const &value) + immovable_value_type const &wrapper) -> std::ostream & { - return out << value.value; + return out << wrapper.value; } }; @@ -107,21 +109,30 @@ static_assert(vefs::detail::cache_traits); template class vefs::detail::cache_mt; template class vefs::detail::cache_handle; +#if VEFS_WORKAROUND_TESTED_AT(BOOST_COMP_CLANG, 16, 0, 6) +#else static_assert(std::regular>); +#endif template class vefs::detail::cache_handle; +#if VEFS_WORKAROUND_TESTED_AT(BOOST_COMP_CLANG, 16, 0, 6) +#else static_assert(std::regular>); +#endif namespace vefs_tests { BOOST_AUTO_TEST_SUITE(cache_ng) +#if VEFS_WORKAROUND_TESTED_AT(BOOST_COMP_CLANG, 16, 0, 6) +#else static_assert(requires(cache_handle t, cache_handle u) { - t == u; - t != u; - u == t; - u != t; - }); + t == u; + t != u; + u == t; + u != t; +}); +#endif BOOST_AUTO_TEST_CASE(default_ctor) { diff --git a/tools/toolchains/x64-linux-clang-16.cmake b/tools/toolchains/x64-linux-clang-16.cmake index c4733c6..59945b8 100644 --- a/tools/toolchains/x64-linux-clang-16.cmake +++ b/tools/toolchains/x64-linux-clang-16.cmake @@ -4,6 +4,6 @@ set(CMAKE_C_COMPILER clang-16) set(CMAKE_CXX_COMPILER clang++-16) set(CMAKE_C_STANDARD 17) -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 20 CACHE STRING "") set(CMAKE_CXX_FLAGS_INIT "-fsized-deallocation") diff --git a/tools/toolchains/x64-linux-clang.cmake b/tools/toolchains/x64-linux-clang.cmake index 5220a4f..c37e9b1 100644 --- a/tools/toolchains/x64-linux-clang.cmake +++ b/tools/toolchains/x64-linux-clang.cmake @@ -4,6 +4,6 @@ set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) set(CMAKE_C_STANDARD 17) -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 20 CACHE STRING "") set(CMAKE_CXX_FLAGS_INIT "-fsized-deallocation") diff --git a/tools/triplets/x64-linux-clang-16.cmake b/tools/triplets/x64-linux-clang-16.cmake index 8455330..58ffeb7 100644 --- a/tools/triplets/x64-linux-clang-16.cmake +++ b/tools/triplets/x64-linux-clang-16.cmake @@ -5,6 +5,6 @@ set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Linux) set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/x64-linux-clang-16.cmake") -# if (PORT STREQUAL "boringssl") -# set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_CXX_STANDARD=17") -# endif() +if (PORT STREQUAL "boringssl") + set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_CXX_STANDARD=17") +endif() diff --git a/tools/triplets/x64-linux-clang.cmake b/tools/triplets/x64-linux-clang.cmake index 3c1bd04..3e09464 100644 --- a/tools/triplets/x64-linux-clang.cmake +++ b/tools/triplets/x64-linux-clang.cmake @@ -5,6 +5,6 @@ set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Linux) set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/x64-linux-clang.cmake") -# if (PORT STREQUAL "boringssl") -# set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_CXX_STANDARD=17") -# endif() +if (PORT STREQUAL "boringssl") + set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_CXX_STANDARD=17") +endif() From f00b51e62fefccd752a2d1ce13e947105ffed370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20S=2E=20Ga=C3=9Fmann?= Date: Sun, 26 Nov 2023 21:30:18 +0000 Subject: [PATCH 5/6] style: Reformat sources with clang-format v16 --- apps/vefs.main.cpp | 6 +- apps/vefs/cli/commandlets/base.hpp | 5 +- .../commandlets/extract_personalization.cpp | 3 +- apps/vefs/cli/commandlets/upsert.cpp | 4 +- include/vefs/detail/workaround.hpp | 14 +- include/vefs/disappointment.hpp | 22 +-- include/vefs/hash/detail/spooky_v2_impl.hpp | 2 +- include/vefs/hash/hash_algorithm.hpp | 10 +- include/vefs/platform/thread_pool.hpp | 7 +- include/vefs/utils/bit.hpp | 4 +- include/vefs/utils/bitset_overlay.hpp | 4 +- include/vefs/utils/enum_bitset.hpp | 2 +- include/vefs/utils/misc.hpp | 17 +- include/vefs/utils/random.hpp | 14 +- src/vefs/archive.cpp | 5 +- src/vefs/cache/cache_mt.hpp | 30 +-- src/vefs/cache/cache_page.hpp | 32 ++-- src/vefs/cache/w-tinylfu_policy.hpp | 12 +- src/vefs/crypto/blake2.hpp | 2 +- src/vefs/crypto/boringssl_aead.hpp | 15 +- src/vefs/crypto/counter.cpp | 6 +- src/vefs/detail/archive_file_id.hpp | 8 +- src/vefs/detail/archive_sector_allocator.cpp | 9 +- src/vefs/detail/block_manager.hpp | 37 ++-- src/vefs/detail/cow_tree_allocator_mt.hpp | 3 +- src/vefs/detail/file_descriptor.cpp | 6 +- src/vefs/detail/file_descriptor.hpp | 4 +- src/vefs/detail/sector_device.cpp | 24 ++- src/vefs/detail/sector_device.hpp | 4 +- src/vefs/detail/sector_tree_mt.hpp | 15 +- src/vefs/detail/tree_lut.hpp | 8 +- src/vefs/detail/tree_walker.hpp | 6 +- src/vefs/platform/platform.cpp | 9 +- src/vefs/platform/sysrandom.cpp | 23 +-- src/vefs/platform/thread_pool.cpp | 35 ++-- src/vefs/vfile.cpp | 13 +- src/vefs/vfilesystem.cpp | 171 ++++++++---------- tests/archive-integration-tests.cpp | 28 +-- tests/io_buffer_manager.test.cpp | 9 +- tests/sector_device-tests.cpp | 35 ++-- tests/sector_tree_mt-tests.cpp | 14 +- tests/sector_tree_seq-tests.cpp | 22 +-- tests/test_utils/test-utils.cpp | 3 +- tests/tree_lut-tests.cpp | 4 +- tests/tree_walker-tests.cpp | 22 +-- tests/vefs/cache/lru_policy.test.cpp | 2 +- tests/vefs/cache/slru_policy.test.cpp | 4 +- tests/vefs/cache/w-tinylfu_policy.test.cpp | 2 +- tests/vefs/hash/hash_algorithm.test.cpp | 2 +- 49 files changed, 351 insertions(+), 387 deletions(-) diff --git a/apps/vefs.main.cpp b/apps/vefs.main.cpp index 2c8fdf7..f31ae6f 100644 --- a/apps/vefs.main.cpp +++ b/apps/vefs.main.cpp @@ -22,7 +22,7 @@ #endif // fmt 9.0.0 -#if FMT_VERSION >= 9'00'00 +#if FMT_VERSION >= 90'000 template <> struct fmt::formatter : fmt::ostream_formatter { @@ -88,7 +88,7 @@ namespace auto win32_utf16_to_utf8(std::wstring_view u16str) noexcept -> std::string { - constexpr unsigned utf8_codepage = 65001U; + constexpr unsigned utf8_codepage = 65'001U; std::string u8str; @@ -137,7 +137,7 @@ auto win32_utf16_to_utf8(std::wstring_view u16str) noexcept -> std::string auto wmain(int argc, wchar_t *argv[]) -> int { auto utf8Args = std::span(argv, static_cast(argc)) - | std::ranges::views::transform(win32_utf16_to_utf8); + | std::ranges::views::transform(win32_utf16_to_utf8); return vefs::cli::main(lyra::args(std::ranges::begin(utf8Args), std::ranges::end(utf8Args))); } diff --git a/apps/vefs/cli/commandlets/base.hpp b/apps/vefs/cli/commandlets/base.hpp index 7048dc9..b560c2a 100644 --- a/apps/vefs/cli/commandlets/base.hpp +++ b/apps/vefs/cli/commandlets/base.hpp @@ -17,7 +17,7 @@ #include "vefs/cli/error.hpp" // fmt 9.0.0 -#if FMT_VERSION >= 9'00'00 +#if FMT_VERSION >= 90'000 template <> struct fmt::formatter : fmt::ostream_formatter { @@ -113,8 +113,7 @@ struct commandlet_base commandlet_base() : cmd(std::string(T::name), - [self = static_cast(this)](lyra::group const &g) - { + [self = static_cast(this)](lyra::group const &g) { if (result rx = self->exec(g); rx.has_failure()) { fmt::print("Command execution failed: {}\n{}\n", diff --git a/apps/vefs/cli/commandlets/extract_personalization.cpp b/apps/vefs/cli/commandlets/extract_personalization.cpp index b4843c4..6dc32f8 100644 --- a/apps/vefs/cli/commandlets/extract_personalization.cpp +++ b/apps/vefs/cli/commandlets/extract_personalization.cpp @@ -27,8 +27,7 @@ auto extract_personalization::exec(lyra::group const &) const -> result VEFS_TRY(auto &&outFile, llfio::file({}, mTargetFile, file_handle::mode::write, file_handle::creation::always_new)); - dplx::scope_guard outFileRemover = [&outFile] - { + dplx::scope_guard outFileRemover = [&outFile] { if (outFile.is_valid()) { (void)outFile.unlink(3s); diff --git a/apps/vefs/cli/commandlets/upsert.cpp b/apps/vefs/cli/commandlets/upsert.cpp index 40325a8..8b39a8c 100644 --- a/apps/vefs/cli/commandlets/upsert.cpp +++ b/apps/vefs/cli/commandlets/upsert.cpp @@ -33,9 +33,9 @@ inline auto transfer_to_vfile(llfio::file_handle &file, readRx.has_error()) { #if defined(BOOST_OS_WINDOWS_AVAILABLE) - constexpr system_error::win32_code error_handle_eof{0x00000026}; + constexpr system_error::win32_code error_handle_eof{0x0000'0026}; constexpr system_error::nt_code status_end_of_file{ - static_cast(0xc0000011U)}; + static_cast(0xc000'0011U)}; if (readRx.assume_error() == error_handle_eof || readRx.assume_error() == status_end_of_file) { diff --git a/include/vefs/detail/workaround.hpp b/include/vefs/detail/workaround.hpp index b21e09d..499ea5a 100644 --- a/include/vefs/detail/workaround.hpp +++ b/include/vefs/detail/workaround.hpp @@ -17,17 +17,17 @@ // but offer library specific configuration knobs // guard for bugs which have been resolved with a known (compiler) version -#define VEFS_WORKAROUND(symbol, comp, major, minor, patch) \ - DPLX_XDEF_WORKAROUND(VEFS_DISABLE_WORKAROUNDS, symbol, comp, major, \ - minor, patch) +#define VEFS_WORKAROUND(symbol, comp, major, minor, patch) \ + DPLX_XDEF_WORKAROUND(VEFS_DISABLE_WORKAROUNDS, symbol, comp, major, minor, \ + patch) // guard for bugs which have _not_ been resolved known (compiler) version // i.e. we need to periodically test whether they have been resolved // after which we can move them in the upper category -#define VEFS_WORKAROUND_TESTED_AT(symbol, major, minor, patch) \ - DPLX_XDEF_WORKAROUND_TESTED_AT(VEFS_DISABLE_WORKAROUNDS, \ - VEFS_FLAG_OUTDATED_WORKAROUNDS, \ - symbol, major, minor, patch) +#define VEFS_WORKAROUND_TESTED_AT(symbol, major, minor, patch) \ + DPLX_XDEF_WORKAROUND_TESTED_AT(VEFS_DISABLE_WORKAROUNDS, \ + VEFS_FLAG_OUTDATED_WORKAROUNDS, symbol, \ + major, minor, patch) //////////////////////////////////////////////////////////////////////////////// diff --git a/include/vefs/disappointment.hpp b/include/vefs/disappointment.hpp index 5c77006..ac6b853 100644 --- a/include/vefs/disappointment.hpp +++ b/include/vefs/disappointment.hpp @@ -111,9 +111,9 @@ using result = oc::basic_result; template requires std::is_enum_v> - && std::derived_from, - detail::error_detail_base> - auto operator<<(T &&c, U &&) noexcept -> std::remove_cvref_t + && std::derived_from, + detail::error_detail_base> +auto operator<<(T &&c, U &&) noexcept -> std::remove_cvref_t { return c; } @@ -191,14 +191,14 @@ auto inject(llfio::byte_io_handle::io_result rx, InjectFn &&injectFn) template concept tryable = requires(T &&t) { - { - oc::try_operation_has_value(t) - } -> std::same_as; - { - oc::try_operation_return_as(static_cast(t)) - } -> std::convertible_to>; - oc::try_operation_extract_value(static_cast(t)); - }; + { + oc::try_operation_has_value(t) + } -> std::same_as; + { + oc::try_operation_return_as(static_cast(t)) + } -> std::convertible_to>; + oc::try_operation_extract_value(static_cast(t)); +}; template using result_value_t diff --git a/include/vefs/hash/detail/spooky_v2_impl.hpp b/include/vefs/hash/detail/spooky_v2_impl.hpp index d9501de..ba46124 100644 --- a/include/vefs/hash/detail/spooky_v2_impl.hpp +++ b/include/vefs/hash/detail/spooky_v2_impl.hpp @@ -422,7 +422,7 @@ class SpookyHash // * is a not-very-regular mix of 1's and 0's // * does not need any other special mathematical properties // - static constexpr uint64_t sc_const = 0xdeadbeefdeadbeefULL; + static constexpr uint64_t sc_const = 0xdead'beef'dead'beefULL; uint64_t m_data[2 * sc_numVars]; // unhashed data, for partial messages uint64_t m_state[sc_numVars]; // internal state of the hash diff --git a/include/vefs/hash/hash_algorithm.hpp b/include/vefs/hash/hash_algorithm.hpp index a5480da..6d31219 100644 --- a/include/vefs/hash/hash_algorithm.hpp +++ b/include/vefs/hash/hash_algorithm.hpp @@ -79,8 +79,8 @@ template inline constexpr bool disable_trivially_hashable = false; template -concept trivially_hashable = std::has_unique_object_representations_v && ! -disable_trivially_hashable; +concept trivially_hashable = std::has_unique_object_representations_v + && !disable_trivially_hashable; inline constexpr struct hash_update_fn { @@ -166,9 +166,9 @@ struct hash_fn } template requires dplx::cncr::nothrow_tag_invocable< - hash_fn, - typename Algorithm::key_type const &, - T const &> + hash_fn, + typename Algorithm::key_type const &, + T const &> [[nodiscard]] constexpr auto operator()(typename Algorithm::key_type const &key, T const &object) const noexcept diff --git a/include/vefs/platform/thread_pool.hpp b/include/vefs/platform/thread_pool.hpp index 2169619..328fcc0 100644 --- a/include/vefs/platform/thread_pool.hpp +++ b/include/vefs/platform/thread_pool.hpp @@ -53,8 +53,9 @@ inline void thread_pool::execute(F &&task) else { execute(std::make_unique( - [btask = std::forward(task)]() mutable - { std::invoke(btask); })); + [btask = std::forward(task)]() mutable { + std::invoke(btask); + })); } } @@ -87,7 +88,7 @@ class pooled_work_tracker : public thread_pool thread_pool *const mPool; std::atomic_int mWorkCtr; -#if __cpp_lib_atomic_wait < 201907L // TODO: remove after gcc11 release +#if __cpp_lib_atomic_wait < 201'907L // TODO: remove after gcc11 release std::mutex mSync; std::condition_variable mOnDecr; #endif diff --git a/include/vefs/utils/bit.hpp b/include/vefs/utils/bit.hpp index 1d3d366..4e27d32 100644 --- a/include/vefs/utils/bit.hpp +++ b/include/vefs/utils/bit.hpp @@ -7,11 +7,11 @@ #include -#if __cplusplus > 201703L && __has_include() +#if __cplusplus > 201'703L && __has_include() #include #endif -#if __cpp_lib_bitops >= 201907L +#if __cpp_lib_bitops >= 201'907L #include namespace vefs::utils diff --git a/include/vefs/utils/bitset_overlay.hpp b/include/vefs/utils/bitset_overlay.hpp index b5a43e1..ae2bf7a 100644 --- a/include/vefs/utils/bitset_overlay.hpp +++ b/include/vefs/utils/bitset_overlay.hpp @@ -80,8 +80,8 @@ inline void set_n(Unit *begin, const std::size_t numBits) if (auto const remaining = numBits % byte_limits::digits) { constexpr std::array lut - = {0b0000'0000, 0b0000'0001, 0b0000'0011, 0b0000'0111, - 0b0000'1111, 0b0001'1111, 0b0011'1111, 0b0111'1111}; + = {0b00000000, 0b00000001, 0b00000011, 0b00000111, + 0b00001111, 0b00011111, 0b00111111, 0b01111111}; *pend |= lut[remaining]; } } diff --git a/include/vefs/utils/enum_bitset.hpp b/include/vefs/utils/enum_bitset.hpp index 2e566bd..e7569e8 100644 --- a/include/vefs/utils/enum_bitset.hpp +++ b/include/vefs/utils/enum_bitset.hpp @@ -22,7 +22,7 @@ std::false_type allow_enum_bitset(E &&); template constexpr bool enum_bitsets_allowed = std::is_enum_v - && decltype(allow_enum_bitset(std::declval()))::value; + && decltype(allow_enum_bitset(std::declval()))::value; /** * Wrapper for enums to enable bitoperations diff --git a/include/vefs/utils/misc.hpp b/include/vefs/utils/misc.hpp index f16404f..3683dd0 100644 --- a/include/vefs/utils/misc.hpp +++ b/include/vefs/utils/misc.hpp @@ -25,20 +25,19 @@ concept none_of = (!std::same_as && ...); template concept integer = std::integral - && none_of, - bool, - char, - wchar_t, - char8_t, - char16_t, - char32_t>; + && none_of, + bool, + char, + wchar_t, + char8_t, + char16_t, + char32_t>; template concept signed_integer = integer && std::is_signed_v; template -concept unsigned_integer = integer && ! -signed_integer; +concept unsigned_integer = integer && !signed_integer; template constexpr T div_ceil(T dividend, T divisor) diff --git a/include/vefs/utils/random.hpp b/include/vefs/utils/random.hpp index b0b5ef1..a979d81 100644 --- a/include/vefs/utils/random.hpp +++ b/include/vefs/utils/random.hpp @@ -36,14 +36,14 @@ class splitmix64 std::array data; init.generate(data.begin(), data.end()); s = static_cast(data[0]) - | (static_cast(data[1]) << 32); + | (static_cast(data[1]) << 32); } inline result_type operator()() { - std::uint64_t z = (s += 0x9E3779B97F4A7C15ull); - z = (z ^ (z >> 30)) * 0xBF58476D1CE4E5B9ull; - z = (z ^ (z >> 27)) * 0x94D049BB133111EBull; + std::uint64_t z = (s += 0x9E37'79B9'7F4A'7C15ull); + z = (z ^ (z >> 30)) * 0xBF58'476D'1CE4'E5B9ull; + z = (z ^ (z >> 27)) * 0x94D0'49BB'1331'11EBull; return z ^ (z >> 31); } @@ -51,7 +51,7 @@ class splitmix64 { for (unsigned long long i = 0; i < j; ++i) { - s += 0x9E3779B97F4A7C15ull; + s += 0x9E37'79B9'7F4A'7C15ull; } } @@ -103,9 +103,9 @@ class xoroshiro128plus std::array data; init.generate(data.begin(), data.end()); s[0] = static_cast(data[0]) - | (static_cast(data[1]) << 32); + | (static_cast(data[1]) << 32); s[1] = static_cast(data[2]) - | (static_cast(data[3]) << 32); + | (static_cast(data[3]) << 32); } inline void seed(std::uint64_t s1, std::uint64_t s2) { diff --git a/src/vefs/archive.cpp b/src/vefs/archive.cpp index ea4410e..36a2318 100644 --- a/src/vefs/archive.cpp +++ b/src/vefs/archive.cpp @@ -317,8 +317,7 @@ auto archive_handle::purge_corruption(llfio::path_handle const &base, VEFS_TRY(auto workingCopy, llfio::file(base, workingCopyPath, llfio::file_handle::mode::write, llfio::file_handle::creation::only_if_not_exist)); - utils::scope_guard cleanup = [&] - { + utils::scope_guard cleanup = [&] { if (workingCopy.is_valid()) { // if purging fails @@ -378,7 +377,7 @@ auto archive_handle::purge_corruption(llfio::file_handle &&file, else { return std::move(openFsRx).assume_error() - << ed::archive_file{"[archive-index]"}; + << ed::archive_file{"[archive-index]"}; } VEFS_TRY(filesystem->replace_corrupted_sectors()); diff --git a/src/vefs/cache/cache_mt.hpp b/src/vefs/cache/cache_mt.hpp index 118386c..fe877c2 100644 --- a/src/vefs/cache/cache_mt.hpp +++ b/src/vefs/cache/cache_mt.hpp @@ -192,7 +192,8 @@ class cache_mt break; } } - } while (numPinned != numPinnedPreviously); + } + while (numPinned != numPinnedPreviously); if (numPinned > 0) { @@ -281,8 +282,7 @@ class cache_mt if (!mIndex.uprase_fn( key, [this, &h, - &foundEntry](entry_info const &indexEntry) noexcept - { + &foundEntry](entry_info const &indexEntry) noexcept { // someone was faster than us // forcefully reference the page in order to prevent its // untimely unbecoming during the retry @@ -303,15 +303,15 @@ class cache_mt entry = foundEntry; goto retry; } - dplx::scope_guard indexRollback = [this, &key, &entry, &ctrl]() noexcept - { - if (entry.generation != page_state::invalid_generation) - { - mIndex.erase(key); - ctrl.cancel_replace(); - release_page(entry.index); - } - }; + dplx::scope_guard indexRollback + = [this, &key, &entry, &ctrl]() noexcept { + if (entry.generation != page_state::invalid_generation) + { + mIndex.erase(key); + ctrl.cancel_replace(); + release_page(entry.index); + } + }; if (shouldEvictOne) { @@ -322,8 +322,7 @@ class cache_mt std::lock_guard evictionLock{mEvictionSync}; mEvictionPolicy.insert(key, entry.index); } - dplx::scope_guard evictionRollback = [this, &key, &entry]() noexcept - { + dplx::scope_guard evictionRollback = [this, &key, &entry]() noexcept { if (entry.generation != page_state::invalid_generation) { std::lock_guard evictionLock{mEvictionSync}; @@ -420,7 +419,8 @@ class cache_mt handle{std::move(h), mPage[i].pointer()}); } } - } while (++i < numPages && syncQueue.size() < syncQueue.capacity()); + } + while (++i < numPages && syncQueue.size() < syncQueue.capacity()); anyDirty = anyDirty || syncQueue.size() > 0U; for (auto &h : syncQueue) diff --git a/src/vefs/cache/cache_page.hpp b/src/vefs/cache/cache_page.hpp index 866295f..c587d2c 100644 --- a/src/vefs/cache/cache_page.hpp +++ b/src/vefs/cache/cache_page.hpp @@ -27,21 +27,21 @@ enum class [[nodiscard]] cache_replacement_result /** * @brief failed; the page is currently used */ - pinned = 0b0'0000, + pinned = 0b00000, /** * @brief succeeded; the page is unoccupied */ - dead = 0b1'0010, + dead = 0b10010, /** * @brief succeeded; the page is occupied and clean */ - clean = 0b1'0000, + clean = 0b10000, /** * @brief succeeded; the page is occupied and dirty/modified * * This indicates that changes need to be synchronized. */ - dirty = 0b1'0001, + dirty = 0b10001, }; #if defined(DPLX_COMP_MSVC_AVAILABLE) @@ -101,11 +101,11 @@ class alignas(32) cache_page_state static constexpr int ref_ctr_offset = 0; static constexpr int ref_ctr_digits = 16; static constexpr state_type ref_ctr_mask = ((one << ref_ctr_digits) - 1U) - << ref_ctr_offset; + << ref_ctr_offset; static constexpr state_type ref_ctr_one = one << ref_ctr_offset; - static constexpr state_type dirt_flag = one - << (ref_ctr_offset + ref_ctr_digits); + static constexpr state_type dirt_flag + = one << (ref_ctr_offset + ref_ctr_digits); static constexpr state_type tombstone_flag = dirt_flag << 1; // this serves as an exclusive lock static constexpr state_type dirty_tombstone = dirt_flag | tombstone_flag; @@ -170,8 +170,8 @@ class alignas(32) cache_page_state { auto const state = mValue.load(std::memory_order::acquire); return (state & (tombstone_flag | generation_mask)) - == (expectedGeneration & generation_mask) - && expectedKey == key(); + == (expectedGeneration & generation_mask) + && expectedKey == key(); } auto try_acquire_wait() noexcept -> bool @@ -306,12 +306,13 @@ class alignas(32) cache_page_state // wrap around as intended static_assert(generation_one == (dirt_flag << 2)); next = (state + ((~state & dirt_flag) << 2)) | dirty_tombstone - | ref_ctr_one; - } while (!mValue.compare_exchange_weak(state, next, acq_rel, acquire)); + | ref_ctr_one; + } + while (!mValue.compare_exchange_weak(state, next, acq_rel, acquire)); nextGeneration = (state + generation_one) & generation_mask; return static_cast( - 0b1'0000U | ((state & dirty_tombstone) >> ref_ctr_digits)); + 0b10000U | ((state & dirty_tombstone) >> ref_ctr_digits)); } /** * @brief Updates the generation counter after @ref try_start_replace @@ -378,7 +379,8 @@ class alignas(32) cache_page_state } next = state | dirty_tombstone; - } while (mValue.compare_exchange_weak(state, next, acq_rel, acquire)); + } + while (mValue.compare_exchange_weak(state, next, acq_rel, acquire)); return true; } @@ -552,13 +554,13 @@ class cache_handle { base_type::get_handle()->mark_clean(); } - auto as_writable() &&noexcept -> cache_handle + auto as_writable() && noexcept -> cache_handle { auto *const alias = const_cast(get()); return cache_handle{ static_cast(*this).get_handle(), alias}; } - auto as_writable() const &noexcept -> cache_handle + auto as_writable() const & noexcept -> cache_handle { return cache_handle{base_type::get_handle(), const_cast(get())}; diff --git a/src/vefs/cache/w-tinylfu_policy.hpp b/src/vefs/cache/w-tinylfu_policy.hpp index d8ee2b5..121daf8 100644 --- a/src/vefs/cache/w-tinylfu_policy.hpp +++ b/src/vefs/cache/w-tinylfu_policy.hpp @@ -80,8 +80,8 @@ class wtinylfu_policy replacement_iterator const &right) noexcept -> bool { return left.mOwner == right.mOwner - && left.mWindowHand == right.mWindowHand - && left.mMainHand == right.mMainHand; + && left.mWindowHand == right.mWindowHand + && left.mMainHand == right.mMainHand; } // constructs an end iterator @@ -187,7 +187,7 @@ class wtinylfu_policy const noexcept -> bool { return mOwner->estimate(windowHand->key()) - <= mOwner->estimate(mainHand->key()); + <= mOwner->estimate(mainHand->key()); } }; @@ -276,15 +276,15 @@ class wtinylfu_policy auto on_purge(key_type const &key, index_type const where) noexcept -> bool { return mWindowPolicy.on_purge(key, where) - || mMainPolicy.on_purge(key, where); + || mMainPolicy.on_purge(key, where); } private: auto estimate(key_type const &key) const noexcept -> std::uint32_t { return mDoorkeeper.estimate(key) > 0U - ? 1U + mFrequencySketch.estimate(key) - : 1U; + ? 1U + mFrequencySketch.estimate(key) + : 1U; } }; diff --git a/src/vefs/crypto/blake2.hpp b/src/vefs/crypto/blake2.hpp index 8efd596..6912c13 100644 --- a/src/vefs/crypto/blake2.hpp +++ b/src/vefs/crypto/blake2.hpp @@ -38,7 +38,7 @@ enum class blake2_errc update_failed, }; -} +} // namespace vefs::crypto::detail // TODO: fixme template <> diff --git a/src/vefs/crypto/boringssl_aead.hpp b/src/vefs/crypto/boringssl_aead.hpp index 4da0bc7..c2b3890 100644 --- a/src/vefs/crypto/boringssl_aead.hpp +++ b/src/vefs/crypto/boringssl_aead.hpp @@ -30,8 +30,7 @@ namespace vefs::crypto::detail { inline std::string read_openssl_errors(std::string str = std::string{}) { - auto printCb = [](char const *msg, size_t msgSize, void *ctx) - { + auto printCb = [](char const *msg, size_t msgSize, void *ctx) { auto &cbStr = *reinterpret_cast(ctx); cbStr.append(msg, msgSize); cbStr.push_back('\n'); @@ -111,8 +110,8 @@ class boringssl_aead final nullptr)) { return archive_errc::bad - << ed::error_code_api_origin{"EVP_AEAD_CTX_init"sv} - << make_openssl_errinfo(); + << ed::error_code_api_origin{"EVP_AEAD_CTX_init"sv} + << make_openssl_errinfo(); } ctx.mInitialized = true; return ctx; @@ -184,8 +183,8 @@ class boringssl_aead final { // #TODO appropriately wrap the boringssl packed error return archive_errc::bad - << ed::error_code_api_origin{"EVP_AEAD_CTX_seal_scatter"sv} - << make_openssl_errinfo(); + << ed::error_code_api_origin{"EVP_AEAD_CTX_seal_scatter"sv} + << make_openssl_errinfo(); } outTag = outTag.subspan(0, outTagLen); @@ -253,8 +252,8 @@ class boringssl_aead final return archive_errc::tag_mismatch; } return archive_errc::bad - << ed::error_code_api_origin{"EVP_AEAD_CTX_open_gather"} - << make_openssl_errinfo(); + << ed::error_code_api_origin{"EVP_AEAD_CTX_open_gather"} + << make_openssl_errinfo(); } return outcome::success(); } diff --git a/src/vefs/crypto/counter.cpp b/src/vefs/crypto/counter.cpp index 80b8b8e..238b8cc 100644 --- a/src/vefs/crypto/counter.cpp +++ b/src/vefs/crypto/counter.cpp @@ -14,8 +14,7 @@ auto dplx::dp::codec::decode(parse_context &ctx, -> result { boost::container::static_vector state{}; - dplx::scope_guard cleanupState = [&state] - { + dplx::scope_guard cleanupState = [&state] { vefs::utils::secure_memzero(state); }; @@ -104,8 +103,7 @@ inline unsigned char add_carry(unsigned char carry, T a, T b, T *out) static_assert(std::is_integral_v); static_assert(std::is_unsigned_v); - [[maybe_unused]] auto const upcast_impl = [&]([[maybe_unused]] auto acc) - { + [[maybe_unused]] auto const upcast_impl = [&]([[maybe_unused]] auto acc) { acc += a; acc += b; *out = static_cast(acc); diff --git a/src/vefs/detail/archive_file_id.hpp b/src/vefs/detail/archive_file_id.hpp index 1940882..20d9924 100644 --- a/src/vefs/detail/archive_file_id.hpp +++ b/src/vefs/detail/archive_file_id.hpp @@ -66,12 +66,12 @@ inline auto file_id::generate() noexcept -> result VEFS_TRY(random_bytes(as_writable_bytes(std::span(bytes)))); // variant must be 10xxxxxx - bytes[8] &= 0b0011'1111; - bytes[8] |= 0b1000'0000; + bytes[8] &= 0b00111111; + bytes[8] |= 0b10000000; // version must be 0100xxxx - bytes[6] &= 0b0000'1111; - bytes[6] |= 0b0100'0000; + bytes[6] &= 0b00001111; + bytes[6] |= 0b01000000; return file_id{uuid{bytes}}; } diff --git a/src/vefs/detail/archive_sector_allocator.cpp b/src/vefs/detail/archive_sector_allocator.cpp index 3f54352..0f2cdf4 100644 --- a/src/vefs/detail/archive_sector_allocator.cpp +++ b/src/vefs/detail/archive_sector_allocator.cpp @@ -129,7 +129,7 @@ auto archive_sector_allocator::mine_new_raw(int num) noexcept if (auto resizerx = mSectorDevice.resize(oldSize + num); !resizerx) { return archive_errc::resource_exhausted - << ed::wrapped_error(std::move(resizerx).assume_error()); + << ed::wrapped_error(std::move(resizerx).assume_error()); } sector_id first{oldSize}; return id_range_t{first, id_range_t::advance(first, num)}; @@ -185,7 +185,7 @@ auto archive_sector_allocator::initialize_from( idContainer)); auto const lastSectorPos = (rootInfo.maximum_extent - 1) - / sector_device::sector_payload_size; + / sector_device::sector_payload_size; if (lastSectorPos != 0) { VEFS_TRY(freeSectorTree->move_to(lastSectorPos)); @@ -339,15 +339,14 @@ auto archive_sector_allocator::finalize( for (;;) { VEFS_TRY(freeSectorTree->commit( - [&](root_sector_info rootInfo) noexcept -> result - { + [&](root_sector_info rootInfo) noexcept -> result { if (!idContainer.empty()) { return success(); } rootInfo.maximum_extent = (freeSectorTree->position().position() + 1) - * sector_device::sector_payload_size; + * sector_device::sector_payload_size; VEFS_TRY(mSectorDevice.update_header(filesystemCryptoCtx, filesystemRoot, diff --git a/src/vefs/detail/block_manager.hpp b/src/vefs/detail/block_manager.hpp index be3d3ee..a650019 100644 --- a/src/vefs/detail/block_manager.hpp +++ b/src/vefs/detail/block_manager.hpp @@ -412,7 +412,7 @@ inline auto id_range::contains(id_type id) const noexcept -> bool { auto const idValue = static_cast(id); return static_cast(mFirstId) <= idValue - && static_cast(mLastId) >= idValue; + && static_cast(mLastId) >= idValue; } #pragma endregion @@ -685,12 +685,10 @@ inline auto block_manager::parse_bitset(const const_bitset_overlay data, template void block_manager::clear() noexcept { - mFreeBlocks.clear_and_dispose( - [this](range_type *p) - { - allocator_traits::destroy(mAllocator, p); - allocator_traits::deallocate(mAllocator, p, 1); - }); + mFreeBlocks.clear_and_dispose([this](range_type *p) { + allocator_traits::destroy(mAllocator, p); + allocator_traits::deallocate(mAllocator, p, 1); + }); } template @@ -744,7 +742,8 @@ inline auto block_manager::merge_from(block_manager &other) noexcept num -= range_type::distance(first, nxt2->last()) + 1; first = range_type::advance(nxt2->last(), 1); } - } while (!(last < first)); + } + while (!(last < first)); } other.clear(); return success(); @@ -787,13 +786,10 @@ template inline void block_manager::dispose(typename block_set::const_iterator cit) noexcept { - mFreeBlocks.erase_and_dispose(cit, - [this](range_type *p) - { - allocator_traits::destroy(mAllocator, p); - allocator_traits::deallocate(mAllocator, - p, 1); - }); + mFreeBlocks.erase_and_dispose(cit, [this](range_type *p) { + allocator_traits::destroy(mAllocator, p); + allocator_traits::deallocate(mAllocator, p, 1); + }); } template @@ -801,13 +797,10 @@ inline void block_manager::dispose(typename block_set::const_iterator cbegin, typename block_set::const_iterator cend) noexcept { - mFreeBlocks.erase_and_dispose(cbegin, cend, - [this](range_type *p) - { - allocator_traits::destroy(mAllocator, p); - allocator_traits::deallocate(mAllocator, - p, 1); - }); + mFreeBlocks.erase_and_dispose(cbegin, cend, [this](range_type *p) { + allocator_traits::destroy(mAllocator, p); + allocator_traits::deallocate(mAllocator, p, 1); + }); } #pragma endregion } // namespace vefs::utils diff --git a/src/vefs/detail/cow_tree_allocator_mt.hpp b/src/vefs/detail/cow_tree_allocator_mt.hpp index c99e81e..31d1e74 100644 --- a/src/vefs/detail/cow_tree_allocator_mt.hpp +++ b/src/vefs/detail/cow_tree_allocator_mt.hpp @@ -168,8 +168,7 @@ class cow_tree_allocator_mt final std::back_inserter(mAllocationBuffer)); std::for_each(split, mOverwrittenAllocations.end(), - [this](sector_id allocation) - { + [this](sector_id allocation) { mSourceAllocator.dealloc_one( allocation, source_allocator_type::leak_on_failure); diff --git a/src/vefs/detail/file_descriptor.cpp b/src/vefs/detail/file_descriptor.cpp index 7d673f0..eeb07db 100644 --- a/src/vefs/detail/file_descriptor.cpp +++ b/src/vefs/detail/file_descriptor.cpp @@ -12,14 +12,12 @@ auto dplx::dp::codec::decode( return dp::decode_object(ctx, value); } auto dplx::dp::codec::size_of( - emit_context &ctx, value_type const &value) noexcept - -> std::uint64_t + emit_context &ctx, value_type const &value) noexcept -> std::uint64_t { return dp::size_of_object(ctx, value); } auto dplx::dp::codec::encode( - emit_context &ctx, value_type const &value) noexcept - -> result + emit_context &ctx, value_type const &value) noexcept -> result { return dp::encode_object(ctx, value); } diff --git a/src/vefs/detail/file_descriptor.hpp b/src/vefs/detail/file_descriptor.hpp index 77e4789..a705829 100644 --- a/src/vefs/detail/file_descriptor.hpp +++ b/src/vefs/detail/file_descriptor.hpp @@ -59,7 +59,7 @@ struct file_descriptor } #if defined BOOST_COMP_MSVC_AVAILABLE \ - && BOOST_COMP_MSVC < BOOST_VERSION_NUMBER(19, 35, 32215) + && BOOST_COMP_MSVC < BOOST_VERSION_NUMBER(19, 35, 32'215) struct root_sector_accessor : dplx::dp::member_accessor_base { @@ -101,7 +101,7 @@ struct file_descriptor dplx::dp::property_def<3U, &file_descriptor::secret>{}, dplx::dp::property_def<4U, &file_descriptor::secretCounter>{}, #if defined BOOST_COMP_MSVC_AVAILABLE \ - && BOOST_COMP_MSVC < BOOST_VERSION_NUMBER(19, 35, 32215) + && BOOST_COMP_MSVC < BOOST_VERSION_NUMBER(19, 35, 32'215) dplx::dp::property_fun<5U, root_sector_accessor>{}, dplx::dp::property_fun<6U, root_mac_accessor>{}, dplx::dp::property_fun<7U, max_extent_accessor>{}, diff --git a/src/vefs/detail/sector_device.cpp b/src/vefs/detail/sector_device.cpp index fb40a8f..2d6a277 100644 --- a/src/vefs/detail/sector_device.cpp +++ b/src/vefs/detail/sector_device.cpp @@ -57,9 +57,10 @@ class dplx::dp::codec -> std::uint64_t { return dp::encoded_item_head_size(3U) - + dp::item_size_of_integer(ctx, 0U) - + dp::encoded_size_of(ctx, value.master_secret) - + dp::item_size_of_binary(ctx, vefs::crypto::counter::state_size); + + dp::item_size_of_integer(ctx, 0U) + + dp::encoded_size_of(ctx, value.master_secret) + + dp::item_size_of_binary(ctx, + vefs::crypto::counter::state_size); } static auto encode(emit_context &ctx, master_header const &value) noexcept -> result @@ -238,8 +239,8 @@ auto sector_device::open_existing(llfio::file_handle fileHandle, else { return std::move(headerRx).assume_error() - << ed::archive_file{"[archive-header]"} - << ed::sector_idx{sector_id::master}; + << ed::archive_file{"[archive-header]"} + << ed::sector_idx{sector_id::master}; } } @@ -328,7 +329,7 @@ result sector_device::parse_static_archive_header(ro_blob<32> userPRK) if (rx.has_error() && rx.assume_error() == archive_errc::tag_mismatch) { return archive_errc::wrong_user_prk - << ed::wrapped_error{std::move(rx).assume_error()}; + << ed::wrapped_error{std::move(rx).assume_error()}; } return std::move(rx).as_failure(); } @@ -451,7 +452,7 @@ auto sector_device::parse_archive_header() -> result else { return archive_errc::no_archive_header - << ed::wrapped_error{std::move(header[0]).assume_error()}; + << ed::wrapped_error{std::move(header[0]).assume_error()}; } return std::move(header[selector]); @@ -552,8 +553,7 @@ auto sector_device::read_sector(rw_blob contentDest, } VEFS_TRY(auto ioBuffer, mIoBufferManager.allocate()); - utils::scope_guard deallocationGuard = [&] - { + utils::scope_guard deallocationGuard = [&] { mIoBufferManager.deallocate(ioBuffer); }; @@ -602,8 +602,7 @@ auto sector_device::write_sector( } VEFS_TRY(auto const ioBuffer, mIoBufferManager.allocate()); - utils::scope_guard deallocationGuard = [&] - { + utils::scope_guard deallocationGuard = [&] { mIoBufferManager.deallocate(ioBuffer); }; @@ -630,8 +629,7 @@ auto sector_device::erase_sector(sector_id const sectorIdx) noexcept } VEFS_TRY(auto const ioBuffer, mIoBufferManager.allocate()); - utils::scope_guard deallocationGuard = [&] - { + utils::scope_guard deallocationGuard = [&] { mIoBufferManager.deallocate(ioBuffer); }; auto const writeBuffer = ioBuffer.first(io_buffer_manager::page_size); diff --git a/src/vefs/detail/sector_device.hpp b/src/vefs/detail/sector_device.hpp index aff616a..c641093 100644 --- a/src/vefs/detail/sector_device.hpp +++ b/src/vefs/detail/sector_device.hpp @@ -67,7 +67,7 @@ class sector_device static constexpr size_t sector_size = 1 << 15; // 2^15 static constexpr size_t sector_payload_size - = sector_size - (1 << 5); // 2^15-2^5 + = sector_size - (1 << 5); // 2^15-2^5 static constexpr std::size_t static_header_size = 1 << 12; static constexpr std::size_t personalization_area_size = 1 << 12; @@ -219,7 +219,7 @@ constexpr auto sector_device::header_offset(header_id which) const noexcept -> std::size_t { return static_header_size + personalization_area_size - + ((-static_cast(which)) & pheader_size); + + ((-static_cast(which)) & pheader_size); } inline void sector_device::switch_header() noexcept { diff --git a/src/vefs/detail/sector_tree_mt.hpp b/src/vefs/detail/sector_tree_mt.hpp index 7c46279..58348af 100644 --- a/src/vefs/detail/sector_tree_mt.hpp +++ b/src/vefs/detail/sector_tree_mt.hpp @@ -536,11 +536,11 @@ class sector_tree_mt using base_type::operator->; using base_type::get; - auto as_writable() &&noexcept -> write_handle + auto as_writable() && noexcept -> write_handle { return write_handle(static_cast(*this).as_writable()); } - auto as_writable() const &noexcept -> write_handle + auto as_writable() const & noexcept -> write_handle { return write_handle(base_type::as_writable()); } @@ -772,11 +772,12 @@ class sector_tree_mt -> result { sector_handle base; - auto it = std::find_if( - std::make_reverse_iterator(pathEnd), - std::make_reverse_iterator(pathBegin), - [this, &base](tree_position position) - { return (base = mSectorCache.try_pin(position)); }) + auto it = std::find_if(std::make_reverse_iterator(pathEnd), + std::make_reverse_iterator(pathBegin), + [this, &base](tree_position position) { + return (base + = mSectorCache.try_pin(position)); + }) .base(); // current root is always in cache, i.e. if nothing is hit, it's out of diff --git a/src/vefs/detail/tree_lut.hpp b/src/vefs/detail/tree_lut.hpp index d6857b0..3b8f852 100644 --- a/src/vefs/detail/tree_lut.hpp +++ b/src/vefs/detail/tree_lut.hpp @@ -70,10 +70,10 @@ constexpr int required_tree_depth(std::uint64_t sectorPos) { static_assert(ref_width.size() == 5); // safe guard for ref_width changes. return 0 + static_cast(sectorPos >= ref_width[0]) - + static_cast(sectorPos >= ref_width[1]) - + static_cast(sectorPos >= ref_width[2]) - + static_cast(sectorPos >= ref_width[3]) - + static_cast(sectorPos >= ref_width[4]); + + static_cast(sectorPos >= ref_width[1]) + + static_cast(sectorPos >= ref_width[2]) + + static_cast(sectorPos >= ref_width[3]) + + static_cast(sectorPos >= ref_width[4]); } /** diff --git a/src/vefs/detail/tree_walker.hpp b/src/vefs/detail/tree_walker.hpp index cefba09..0f5534f 100644 --- a/src/vefs/detail/tree_walker.hpp +++ b/src/vefs/detail/tree_walker.hpp @@ -25,7 +25,7 @@ struct tree_position final using storage_type = std::uint64_t; static constexpr auto layer_offset = 56; static constexpr storage_type layer_mask = static_cast(0xFF) - << layer_offset; + << layer_offset; static constexpr storage_type position_mask = ~layer_mask; /** @@ -221,7 +221,7 @@ constexpr auto tree_position::compress(std::uint64_t position, int layer) -> storage_type { return (static_cast(layer) << layer_offset) - | (position & position_mask); + | (position & position_mask); } constexpr tree_position::tree_position() noexcept @@ -251,7 +251,7 @@ constexpr int tree_position::layer() const noexcept constexpr void tree_position::layer(int layer_no) noexcept { mLayerPosition = (mLayerPosition & position_mask) - | static_cast(layer_no) << 56; + | static_cast(layer_no) << 56; } constexpr std::uint64_t tree_position::position() const noexcept diff --git a/src/vefs/platform/platform.cpp b/src/vefs/platform/platform.cpp index 68a935c..4db1319 100644 --- a/src/vefs/platform/platform.cpp +++ b/src/vefs/platform/platform.cpp @@ -14,8 +14,7 @@ using set_native_thread_name_fn = HRESULT (*)(HANDLE hThread, PCWSTR name); set_native_thread_name_fn set_native_thread_name() { - static set_native_thread_name_fn fn = []() -> set_native_thread_name_fn - { + static set_native_thread_name_fn fn = []() -> set_native_thread_name_fn { set_native_thread_name_fn dfn = nullptr; if (auto dll = LoadLibraryW(L"Kernel32.dll")) { @@ -52,7 +51,7 @@ void set_current_thread_name_legacy(std::string const &name) // adapted from // https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code - constexpr DWORD MS_VC_EXCEPTION = 0x406D1388; + constexpr DWORD MS_VC_EXCEPTION = 0x406D'1388; struct THREADNAME_INFO { @@ -85,8 +84,8 @@ void set_current_thread_name_legacy(std::string const &name) void set_current_thread_name(std::string const &name) { static set_thread_name_fn impl = set_native_thread_name() - ? &set_current_thread_name_spicey - : &set_current_thread_name_legacy; + ? &set_current_thread_name_spicey + : &set_current_thread_name_legacy; impl(name); } diff --git a/src/vefs/platform/sysrandom.cpp b/src/vefs/platform/sysrandom.cpp index 5567cdc..e31f1fe 100644 --- a/src/vefs/platform/sysrandom.cpp +++ b/src/vefs/platform/sysrandom.cpp @@ -27,7 +27,7 @@ vefs::result vefs::detail::random_bytes(rw_dynblob buffer) noexcept if (buffer.empty()) { return errc::invalid_argument - << ed::error_code_api_origin{"random_bytes"sv}; + << ed::error_code_api_origin{"random_bytes"sv}; } do { @@ -39,10 +39,11 @@ vefs::result vefs::detail::random_bytes(rw_dynblob buffer) noexcept if (!RtlGenRandom(buffer.data(), portion)) { return collect_system_error() - << ed::error_code_api_origin{"SystemFunction036"sv}; + << ed::error_code_api_origin{"SystemFunction036"sv}; } buffer = buffer.subspan(portion); - } while (!buffer.empty()); + } + while (!buffer.empty()); return outcome::success(); } @@ -68,14 +69,14 @@ vefs::result vefs::detail::random_bytes(rw_dynblob buffer) noexcept if (buffer.empty()) { return errc::invalid_argument - << ed::error_code_api_origin{"random_bytes"sv}; + << ed::error_code_api_origin{"random_bytes"sv}; } int urandom = open("/dev/urandom", O_RDONLY); if (urandom == -1) { return collect_system_error() - << ed::error_code_api_origin{"open(\"/dev/urandom\")"sv}; + << ed::error_code_api_origin{"open(\"/dev/urandom\")"sv}; } VEFS_SCOPE_EXIT { @@ -92,12 +93,12 @@ vefs::result vefs::detail::random_bytes(rw_dynblob buffer) noexcept if (tmp == -1) { return collect_system_error() - << ed::error_code_api_origin{"read(\"/dev/urandom\")"sv}; + << ed::error_code_api_origin{"read(\"/dev/urandom\")"sv}; } if (tmp == 0) { return archive_errc::bad - << ed::error_code_api_origin{"read(\"/dev/urandom\")"sv}; + << ed::error_code_api_origin{"read(\"/dev/urandom\")"sv}; } buffer = buffer.subspan(static_cast(tmp)); } @@ -114,24 +115,24 @@ vefs::result vefs::detail::random_bytes(rw_dynblob buffer) noexcept if (buffer.empty()) { return errc::invalid_argument - << ed::error_code_api_origin{"random_bytes"sv}; + << ed::error_code_api_origin{"random_bytes"sv}; } while (!buffer.empty()) { - constexpr size_t max_portion = static_cast(33554431); + constexpr size_t max_portion = static_cast(33'554'431); auto const portion = std::min(max_portion, buffer.size()); ssize_t tmp = getrandom(static_cast(buffer.data()), portion, 0); if (tmp == -1) { return collect_system_error() - << ed::error_code_api_origin{"getrandom"sv}; + << ed::error_code_api_origin{"getrandom"sv}; } if (tmp == 0) { return archive_errc::bad - << ed::error_code_api_origin{"getrandom"sv}; + << ed::error_code_api_origin{"getrandom"sv}; } buffer = buffer.subspan(static_cast(tmp)); } diff --git a/src/vefs/platform/thread_pool.cpp b/src/vefs/platform/thread_pool.cpp index 261f478..0227cee 100644 --- a/src/vefs/platform/thread_pool.cpp +++ b/src/vefs/platform/thread_pool.cpp @@ -33,7 +33,7 @@ void thread_pool::xdo(task_t &work) noexcept } } -#if __cpp_lib_atomic_wait < 201907L +#if __cpp_lib_atomic_wait < 201'907L pooled_work_tracker::pooled_work_tracker(thread_pool *pool) : mPool{pool} , mWorkCtr{0} @@ -51,10 +51,11 @@ pooled_work_tracker::pooled_work_tracker(thread_pool *pool) void pooled_work_tracker::wait() { -#if __cpp_lib_atomic_wait < 201907L +#if __cpp_lib_atomic_wait < 201'907L std::unique_lock lock{mSync}; - mOnDecr.wait(lock, [this]() - { return mWorkCtr.load(std::memory_order_acquire) == 0; }); + mOnDecr.wait(lock, [this]() { + return mWorkCtr.load(std::memory_order_acquire) == 0; + }); #else auto currentValue = mWorkCtr.load(std::memory_order::acquire); while (currentValue > 0) @@ -74,7 +75,7 @@ void pooled_work_tracker::execute(std::unique_ptr task) { if (0 == mWorkCtr.fetch_sub(1, std::memory_order::acq_rel)) { -#if __cpp_lib_atomic_wait < 201907L +#if __cpp_lib_atomic_wait < 201'907L mOnDecr.notify_all(); #else mWorkCtr.notify_all(); @@ -82,23 +83,21 @@ void pooled_work_tracker::execute(std::unique_ptr task) } }; - mPool->execute( - [this, xtask = std::move(*task)]() mutable + mPool->execute([this, xtask = std::move(*task)]() mutable { + VEFS_SCOPE_EXIT + { + if (0 == mWorkCtr.fetch_sub(1, std::memory_order::acq_rel)) { - VEFS_SCOPE_EXIT - { - if (0 == mWorkCtr.fetch_sub(1, std::memory_order::acq_rel)) - { -#if __cpp_lib_atomic_wait < 201907L - mOnDecr.notify_all(); +#if __cpp_lib_atomic_wait < 201'907L + mOnDecr.notify_all(); #else - mWorkCtr.notify_all(); + mWorkCtr.notify_all(); #endif - } - }; + } + }; - xtask(); - }); + xtask(); + }); } } // namespace vefs::detail diff --git a/src/vefs/vfile.cpp b/src/vefs/vfile.cpp index eaa51f1..3ab1880 100644 --- a/src/vefs/vfile.cpp +++ b/src/vefs/vfile.cpp @@ -161,8 +161,8 @@ auto vfile::truncate(std::uint64_t size) -> result { newSize = std::max(newSize, maximumExtent); } - - } while (++it <= end); + } + while (++it <= end); } else if (it > end) { @@ -180,8 +180,8 @@ auto vfile::truncate(std::uint64_t size) -> result { newSize = std::min(newSize, maximumExtent); } - - } while (--it != 0 && it >= end); + } + while (--it != 0 && it >= end); if (end == 0) { @@ -217,8 +217,9 @@ auto vfile::commit() -> result mWriteFlag.unmark(); auto commitRx = mFileTree->commit( - [this](detail::root_sector_info committedRootInfo) noexcept - { return sync_commit_info(committedRootInfo); }); + [this](detail::root_sector_info committedRootInfo) noexcept { + return sync_commit_info(committedRootInfo); + }); if (!commitRx) { mWriteFlag.mark(); diff --git a/src/vefs/vfilesystem.cpp b/src/vefs/vfilesystem.cpp index eedf1e0..a2360ad 100644 --- a/src/vefs/vfilesystem.cpp +++ b/src/vefs/vfilesystem.cpp @@ -59,7 +59,7 @@ class vfilesystem::index_tree_layout auto const treeOffset = wblock % blocks_per_sector; return treePosition * sector_payload_size + alloc_map_size - + treeOffset * block_size; + + treeOffset * block_size; } using map_bucket_type = std::size_t; @@ -105,7 +105,7 @@ class vfilesystem::index_tree_layout if (eblock != 0) { return offset * map_bucket_size + start - + utils::countr_zero(eblock); + + utils::countr_zero(eblock); } start = 0; } @@ -186,7 +186,7 @@ class vfilesystem::index_tree_layout auto const sectorContentBegin = as_span(mCurrentSector).data(); auto const blockOffset = state.remaining_begin() - - sectorContentBegin - alloc_map_size; + - sectorContentBegin - alloc_map_size; auto const nextBlock = static_cast( utils::div_ceil(blockOffset, block_size)); @@ -316,8 +316,8 @@ class vfilesystem::index_tree_layout auto firstPosition = detail::lut::sector_position_of(offset); auto inSectorOffset = offset - - firstPosition - * detail::sector_device::sector_payload_size; + - firstPosition + * detail::sector_device::sector_payload_size; VEFS_TRY(auto &&firstSector, owner.mIndexTree.access( @@ -332,7 +332,7 @@ class vfilesystem::index_tree_layout auto const remainingSectorSize = detail::sector_device::sector_payload_size - - (inSectorOffset + prefixSize); + - (inSectorOffset + prefixSize); return tree_writer( owner, std::move(writeHandle), inSectorOffset + prefixSize, size <= remainingSectorSize ? size : remainingSectorSize, @@ -475,7 +475,7 @@ class vfilesystem::index_tree_layout as_span(sector).first()); auto const ptr = (position % sector_payload_size - alloc_map_size) - / block_size; + / block_size; int numBlocks = ptr + utils::div_ceil(size, block_size); for (int i = ptr; i < numBlocks; ++i) @@ -789,22 +789,19 @@ auto vfilesystem::open(const std::string_view filePath, auto vfilesystem::open(detail::file_id const id) -> result { result rx = archive_errc::no_such_vfile; - mFiles.update_fn(id, - [&](vfilesystem_entry &e) - { - if (auto h = e.instance.lock()) - { - rx = h; - return; - } - rx = vfile::open_existing( - this, mDeviceExecutor, mSectorAllocator, id, - mDevice, *e.crypto_ctx, e.tree_info); - if (rx) - { - e.instance = rx.assume_value(); - } - }); + mFiles.update_fn(id, [&](vfilesystem_entry &e) { + if (auto h = e.instance.lock()) + { + rx = h; + return; + } + rx = vfile::open_existing(this, mDeviceExecutor, mSectorAllocator, id, + mDevice, *e.crypto_ctx, e.tree_info); + if (rx) + { + e.instance = rx.assume_value(); + } + }); return rx; } @@ -821,16 +818,14 @@ auto vfilesystem::erase(std::string_view filePath) -> result bool erased = false; vfilesystem_entry victim; - bool found = mFiles.erase_fn(id, - [&](vfilesystem_entry &e) - { - erased = e.instance.expired(); - if (erased) - { - victim = std::move(e); - } - return erased; - }); + bool found = mFiles.erase_fn(id, [&](vfilesystem_entry &e) { + erased = e.instance.expired(); + if (erased) + { + victim = std::move(e); + } + return erased; + }); if (!found) { @@ -916,8 +911,9 @@ auto vfilesystem::extractAll(llfio::path_view targetBasePath) -> result for (auto const &indexEntry : mIndex.lock_table()) { VEFS_TRY(extract(indexEntry.first, targetBasePath, - [this, &indexEntry]() -> result - { return open(indexEntry.second); })); + [this, &indexEntry]() -> result { + return open(indexEntry.second); + })); } return success(); } @@ -930,18 +926,15 @@ auto vfilesystem::query(const std::string_view filePath) result rx = archive_errc::no_such_vfile; if (mIndex.find_fn(filePath, [&](file_id const &e) { id = e; })) { - mFiles.find_fn(id, - [&](vfilesystem_entry const &e) - { - auto maxExtent = e.tree_info.maximum_extent; - if (auto h = e.instance.lock()) - { - maxExtent = h->maximum_extent(); - } - - rx = file_query_result{file_open_mode::readwrite, - maxExtent}; - }); + mFiles.find_fn(id, [&](vfilesystem_entry const &e) { + auto maxExtent = e.tree_info.maximum_extent; + if (auto h = e.instance.lock()) + { + maxExtent = h->maximum_extent(); + } + + rx = file_query_result{file_open_mode::readwrite, maxExtent}; + }); } return rx; } @@ -950,12 +943,10 @@ auto vfilesystem::on_vfile_commit(detail::file_id fileId, detail::root_sector_info updatedRootInfo) -> result { - bool found = mFiles.update_fn(fileId, - [&](vfilesystem_entry &e) - { - e.needs_index_update = true; - e.tree_info = updatedRootInfo; - }); + bool found = mFiles.update_fn(fileId, [&](vfilesystem_entry &e) { + e.needs_index_update = true; + e.tree_info = updatedRootInfo; + }); if (!found) { return archive_errc::no_such_vfile; @@ -986,31 +977,27 @@ auto vfilesystem::commit() -> result descriptor.fileId = fid.as_uuid(); auto pathBytes = as_bytes(std::span(path)); - mFiles.update_fn( - fid, - [&](vfilesystem_entry &e) - { - if (!e.needs_index_update) - { - return; - } - - // reuse allocation if possible - descriptor.filePath.resize(pathBytes.size()); - // #TODO #char8_t convert vfilesystem to u8string - vefs::copy(pathBytes, as_writable_bytes(std::span( - descriptor.filePath))); - - if (auto syncrx = layout.sync_to_tree(e, descriptor); - !syncrx) - { - syncrx.assume_error() - << ed::archive_file{"[archive-index]"}; - - // note that this isn't a child of std::exception - throw std::move(syncrx).assume_error(); - } - }); + mFiles.update_fn(fid, [&](vfilesystem_entry &e) { + if (!e.needs_index_update) + { + return; + } + + // reuse allocation if possible + descriptor.filePath.resize(pathBytes.size()); + // #TODO #char8_t convert vfilesystem to u8string + vefs::copy(pathBytes, + as_writable_bytes(std::span(descriptor.filePath))); + + if (auto syncrx = layout.sync_to_tree(e, descriptor); !syncrx) + { + syncrx.assume_error() + << ed::archive_file{"[archive-index]"}; + + // note that this isn't a child of std::exception + throw std::move(syncrx).assume_error(); + } + }); } catch (system_error::error const &error) { @@ -1023,11 +1010,10 @@ auto vfilesystem::commit() -> result } auto maxExtent = (layout.last_allocated().position() + 1) - * detail::sector_device::sector_payload_size; + * detail::sector_device::sector_payload_size; return mIndexTree->commit( - [this, maxExtent]( - detail::root_sector_info rootInfo) noexcept -> result - { return sync_commit_info(rootInfo, maxExtent); }); + [this, maxExtent](detail::root_sector_info rootInfo) noexcept + -> result { return sync_commit_info(rootInfo, maxExtent); }); } auto vfilesystem::sync_commit_info(detail::root_sector_info rootInfo, @@ -1196,17 +1182,16 @@ auto vfilesystem::replace_corrupted_sectors() -> result ed::archive_file_id{id}); } - VEFS_TRY_INJECT(tree->commit( - [this, &it](detail::root_sector_info newRoot) - { - if (it->second.tree_info != newRoot) - { - it->second.tree_info = newRoot; - it->second.needs_index_update = true; - mWriteFlag.mark(); - } - }), - ed::archive_file_id{id}); + VEFS_TRY_INJECT( + tree->commit([this, &it](detail::root_sector_info newRoot) { + if (it->second.tree_info != newRoot) + { + it->second.tree_info = newRoot; + it->second.needs_index_update = true; + mWriteFlag.mark(); + } + }), + ed::archive_file_id{id}); std::advance(it, 1); } diff --git a/tests/archive-integration-tests.cpp b/tests/archive-integration-tests.cpp index 73af8f9..240ab4f 100644 --- a/tests/archive-integration-tests.cpp +++ b/tests/archive-integration-tests.cpp @@ -94,17 +94,17 @@ BOOST_AUTO_TEST_CASE(sqlite_bridge_regression_1) TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 4 * 8192)); dataGenerator.fill(fileData); - TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 32772)); + TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 32'772)); dataGenerator.fill(fileData); - TEST_RESULT_REQUIRE(testSubject.write(f, fileData.subspan(0, 4), 40964)); - TEST_RESULT_REQUIRE(testSubject.write(f, fileData.subspan(4, 4), 40968)); + TEST_RESULT_REQUIRE(testSubject.write(f, fileData.subspan(0, 4), 40'964)); + TEST_RESULT_REQUIRE(testSubject.write(f, fileData.subspan(4, 4), 40'968)); dataGenerator.fill(fileData); - TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 40972)); + TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 40'972)); dataGenerator.fill(fileData); - TEST_RESULT_REQUIRE(testSubject.write(f, fileData.subspan(0, 4), 49164)); + TEST_RESULT_REQUIRE(testSubject.write(f, fileData.subspan(0, 4), 49'164)); TEST_RESULT_REQUIRE(testSubject.commit(f)); f = nullptr; @@ -133,42 +133,42 @@ BOOST_AUTO_TEST_CASE(sqlite_bridge_regression_2) TEST_RESULT_REQUIRE(testSubject.commit()); - TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 0x00000000)); + TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 0x0000'0000)); for (int i = 0; i < 0xf6; ++i) { BOOST_TEST_INFO_SCOPE(i); - TEST_RESULT_REQUIRE( - testSubject.write(f, fileData, 0x0000000ull + i * 0x1000u)); + TEST_RESULT_REQUIRE(testSubject.write(f, fileData, + 0x000'0000ull + i * 0x1000u)); } TEST_RESULT_REQUIRE(testSubject.commit(f)); TEST_RESULT_REQUIRE(testSubject.commit()); - TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 0x0000b000)); + TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 0x0000'b000)); for (int j = 0; j < 98; ++j) { BOOST_TEST_INFO_SCOPE(j); - TEST_RESULT_REQUIRE(testSubject.write(f, fileData, - 0x000f5000ull + j * 0x1000u)); + TEST_RESULT_REQUIRE(testSubject.write( + f, fileData, 0x000f'5000ull + j * 0x1000u)); } TEST_RESULT_REQUIRE(testSubject.commit(f)); TEST_RESULT_REQUIRE(testSubject.commit()); - TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 0x000f4000)); + TEST_RESULT_REQUIRE(testSubject.write(f, fileData, 0x000f'4000)); for (int j = 0; j < 111; ++j) { BOOST_TEST_INFO_SCOPE(j); - TEST_RESULT_REQUIRE(testSubject.write(f, fileData, - 0x0010d000ull + j * 0x1000u)); + TEST_RESULT_REQUIRE(testSubject.write( + f, fileData, 0x0010'd000ull + j * 0x1000u)); } TEST_RESULT_REQUIRE(testSubject.commit(f)); diff --git a/tests/io_buffer_manager.test.cpp b/tests/io_buffer_manager.test.cpp index 5c6603b..5b9313f 100644 --- a/tests/io_buffer_manager.test.cpp +++ b/tests/io_buffer_manager.test.cpp @@ -29,8 +29,7 @@ BOOST_AUTO_TEST_CASE(allocate_more_than_buffered) auto const subject = std::move(rx).assume_value(); std::array, 17> allocations{}; - vefs::utils::scope_guard freeAllocs = [&] - { + vefs::utils::scope_guard freeAllocs = [&] { for (std::size_t i = 0; i < allocations.size() && !allocations[i].empty(); ++i) { @@ -61,15 +60,13 @@ BOOST_AUTO_TEST_CASE(allocations_are_aligned) auto tmpAllocRx = subject.allocate(); TEST_RESULT_REQUIRE(tmpAllocRx); - vefs::utils::scope_guard freeTmpAlloc = [&] - { + vefs::utils::scope_guard freeTmpAlloc = [&] { subject.deallocate(tmpAllocRx.assume_value()); }; auto allocRx = subject.allocate(); TEST_RESULT_REQUIRE(allocRx); - vefs::utils::scope_guard freeAlloc = [&] - { + vefs::utils::scope_guard freeAlloc = [&] { subject.deallocate(allocRx.assume_value()); }; diff --git a/tests/sector_device-tests.cpp b/tests/sector_device-tests.cpp index 63c72b0..3aa4edc 100644 --- a/tests/sector_device-tests.cpp +++ b/tests/sector_device-tests.cpp @@ -21,16 +21,15 @@ struct sector_device_test_fixture .WillRepeatedly( testing::Return(vefs::utils::secure_byte_array<16>{})); EXPECT_CALL(cryptoProviderMock, random_bytes(testing::_)) - .WillRepeatedly( - [](vefs::rw_dynblob out) - { - vefs::fill_blob(out, static_cast(0x11)); - return vefs::outcome::success(); - }); + .WillRepeatedly([](vefs::rw_dynblob out) { + vefs::fill_blob(out, static_cast(0x11)); + return vefs::outcome::success(); + }); EXPECT_CALL(cryptoProviderMock, box_seal(testing::_, testing::_, testing::_, testing::_)) - .WillRepeatedly([](auto &&...) -> vefs::result - { return vefs::outcome::success(); }); + .WillRepeatedly([](auto &&...) -> vefs::result { + return vefs::outcome::success(); + }); testSubject = vefs::detail::sector_device::create_new( testFile.reopen().value(), &cryptoProviderMock, @@ -108,10 +107,10 @@ BOOST_AUTO_TEST_CASE(open_existing_sector_device_throws_error_for_empty_file) BOOST_AUTO_TEST_CASE(write_sector_does_not_work_for_master_sector) { std::byte mac_data[16]; - std::byte ro_data[32736]; - vefs::fill_blob(vefs::rw_blob<32736>(ro_data), std::byte(0x1a)); + std::byte ro_data[32'736]; + vefs::fill_blob(vefs::rw_blob<32'736>(ro_data), std::byte(0x1a)); auto mac = vefs::rw_blob<16>(mac_data); - auto data_bla = vefs::ro_blob<32736>(ro_data); + auto data_bla = vefs::ro_blob<32'736>(ro_data); auto fileCryptoCtx = vefs::detail::file_crypto_ctx( vefs::detail::file_crypto_ctx::zero_init_t{}); auto masterSectorId = vefs::detail::sector_id::master; @@ -127,7 +126,7 @@ BOOST_AUTO_TEST_CASE( write_sector_gives_invalid_errc_for_sector_ids_that_is_to_great) { std::byte mac_data[16]; - std::byte ro_data[32736]; + std::byte ro_data[32'736]; auto mac = vefs::rw_blob<16>(mac_data); auto fileCryptoCtx = vefs::detail::file_crypto_ctx( vefs::detail::file_crypto_ctx::zero_init_t{}); @@ -136,7 +135,7 @@ BOOST_AUTO_TEST_CASE( auto sectorId = static_cast(sectorIdxLimit + 1); auto result = testSubject->write_sector(mac, fileCryptoCtx, sectorId, - vefs::ro_blob<32736>(ro_data)); + vefs::ro_blob<32'736>(ro_data)); BOOST_TEST(result.has_error()); BOOST_TEST(result.assume_error() == vefs::errc::invalid_argument); @@ -146,7 +145,7 @@ BOOST_AUTO_TEST_CASE( read_sector_gives_invalid_errc_for_sector_ids_that_is_to_great) { std::byte mac_data[16]; - std::byte rw_data[32736]; + std::byte rw_data[32'736]; auto mac = vefs::ro_blob<16>(mac_data); auto fileCryptoCtx = vefs::detail::file_crypto_ctx( vefs::detail::file_crypto_ctx::zero_init_t{}); @@ -154,7 +153,7 @@ BOOST_AUTO_TEST_CASE( = std::numeric_limits::max() / (1 << 15); auto sectorId = static_cast(sectorIdxLimit + 1); - auto result = testSubject->read_sector(vefs::rw_blob<32736>(rw_data), + auto result = testSubject->read_sector(vefs::rw_blob<32'736>(rw_data), fileCryptoCtx, sectorId, mac); BOOST_TEST(result.has_error()); @@ -164,14 +163,14 @@ BOOST_AUTO_TEST_CASE( BOOST_AUTO_TEST_CASE(read_sector_does_not_work_for_master_sector) { std::byte mac_data[16]; - std::byte rw_data[32736]; - vefs::fill_blob(vefs::rw_blob<32736>(rw_data), std::byte(0x1a)); + std::byte rw_data[32'736]; + vefs::fill_blob(vefs::rw_blob<32'736>(rw_data), std::byte(0x1a)); auto mac = vefs::rw_blob<16>(mac_data); auto fileCryptoCtx = vefs::detail::file_crypto_ctx( vefs::detail::file_crypto_ctx::zero_init_t{}); auto masterSectorId = vefs::detail::sector_id::master; - auto result = testSubject->read_sector(vefs::rw_blob<32736>(rw_data), + auto result = testSubject->read_sector(vefs::rw_blob<32'736>(rw_data), fileCryptoCtx, masterSectorId, mac); BOOST_TEST(result.has_error()); diff --git a/tests/sector_tree_mt-tests.cpp b/tests/sector_tree_mt-tests.cpp index 70f8eab..5473326 100644 --- a/tests/sector_tree_mt-tests.cpp +++ b/tests/sector_tree_mt-tests.cpp @@ -144,8 +144,8 @@ BOOST_FIXTURE_TEST_CASE(new_sector_tree_has_id_one, sector_tree_mt_dependencies) TEST_RESULT_REQUIRE(createrx); auto newTree = std::move(createrx).assume_value(); root_sector_info newRootInfo; - TEST_RESULT_REQUIRE(newTree->commit([&newRootInfo](root_sector_info rsi) - { newRootInfo = rsi; })); + TEST_RESULT_REQUIRE(newTree->commit( + [&newRootInfo](root_sector_info rsi) { newRootInfo = rsi; })); BOOST_TEST(newRootInfo.root.sector == sector_id{2}); BOOST_TEST(newRootInfo.tree_depth == 0); @@ -158,8 +158,8 @@ BOOST_FIXTURE_TEST_CASE(check_initial_sector_tree_mac, TEST_RESULT_REQUIRE(createrx); auto newTree = std::move(createrx).assume_value(); root_sector_info newRootInfo; - TEST_RESULT_REQUIRE(newTree->commit([&newRootInfo](root_sector_info rsi) - { newRootInfo = rsi; })); + TEST_RESULT_REQUIRE(newTree->commit( + [&newRootInfo](root_sector_info rsi) { newRootInfo = rsi; })); auto expectedRootMac = dplx::cncr::make_byte_array<16>( {0xe8, 0xfc, 0xa8, 0xd7, 0x5c, 0xd8, 0x51, 0xe1, 0xd6, 0xe3, 0x9e, @@ -225,7 +225,7 @@ BOOST_AUTO_TEST_CASE(creation_of_a_new_node_changes_mac) // given auto createRx = existingTree->access_or_create(tree_position(1)); TEST_RESULT_REQUIRE(createRx); - as_span(createRx.assume_value().as_writable())[0] = std::byte{0b1010'1010}; + as_span(createRx.assume_value().as_writable())[0] = std::byte{0b10101010}; createRx.assume_value() = read_handle(); root_sector_info newRootInfo; @@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE(created_node_can_be_read) TEST_RESULT_REQUIRE(createRx); write_handle writeHandle = createRx.assume_value().as_writable(); BOOST_TEST_REQUIRE(writeHandle.operator bool()); - as_span(writeHandle)[0] = std::byte{0b1010'1010}; + as_span(writeHandle)[0] = std::byte{0b10101010}; writeHandle = write_handle(); // when @@ -259,7 +259,7 @@ BOOST_AUTO_TEST_CASE(created_node_can_be_read) TEST_RESULT_REQUIRE(rootAccessRx); auto rootSpan = as_span(rootAccessRx.assume_value()); - BOOST_TEST(rootSpan[0] == std::byte{0b1010'1010}); + BOOST_TEST(rootSpan[0] == std::byte{0b10101010}); } BOOST_AUTO_TEST_CASE(creation_of_a_new_node_expands_to_two_sectors) diff --git a/tests/sector_tree_seq-tests.cpp b/tests/sector_tree_seq-tests.cpp index bfaef53..c1d36d0 100644 --- a/tests/sector_tree_seq-tests.cpp +++ b/tests/sector_tree_seq-tests.cpp @@ -130,8 +130,8 @@ BOOST_FIXTURE_TEST_CASE(create_new, sector_tree_seq_pre_create_fixture) auto tree = std::move(createrx).assume_value(); root_sector_info newRootInfo; - TEST_RESULT_REQUIRE(tree->commit([&newRootInfo](root_sector_info cri) - { newRootInfo = cri; })); + TEST_RESULT_REQUIRE(tree->commit( + [&newRootInfo](root_sector_info cri) { newRootInfo = cri; })); auto expectedRootMac = vefs::utils::make_byte_array( 0xe2, 0x1b, 0x52, 0x74, 0xe1, 0xd5, 0x8b, 0x69, 0x87, 0x36, 0x88, @@ -165,8 +165,8 @@ BOOST_AUTO_TEST_CASE(open_existing) BOOST_AUTO_TEST_CASE(open_lazy) { TEST_RESULT_REQUIRE(testTree->move_forward(tree_type::access_mode::create)); - TEST_RESULT_REQUIRE(testTree->commit([this](root_sector_info newRoot) - { rootSectorInfo = newRoot; })); + TEST_RESULT_REQUIRE(testTree->commit( + [this](root_sector_info newRoot) { rootSectorInfo = newRoot; })); testTree.reset(); auto openrx = tree_type::open_lazy(*device, fileCryptoContext, @@ -185,11 +185,11 @@ BOOST_AUTO_TEST_CASE(open_lazy) BOOST_AUTO_TEST_CASE(expand_to_two_sectors) { TEST_RESULT_REQUIRE(testTree->move_forward(tree_type::access_mode::create)); - testTree->writeable_bytes()[0] = std::byte{0b1010'1010}; + testTree->writeable_bytes()[0] = std::byte{0b10101010}; root_sector_info newRootInfo; - TEST_RESULT_REQUIRE(testTree->commit([&newRootInfo](root_sector_info cri) - { newRootInfo = cri; })); + TEST_RESULT_REQUIRE(testTree->commit( + [&newRootInfo](root_sector_info cri) { newRootInfo = cri; })); auto expectedRootMac = vefs::utils::make_byte_array( 0xc2, 0xaa, 0x29, 0x03, 0x00, 0x60, 0xb8, 0x4e, 0x3f, 0xc3, 0x57, @@ -205,8 +205,8 @@ BOOST_AUTO_TEST_CASE(shrink_on_commit_if_possible) TEST_RESULT_REQUIRE( testTree->move_to(2019, tree_type::access_mode::create)); - TEST_RESULT_REQUIRE(testTree->commit([this](root_sector_info cri) - { rootSectorInfo = cri; })); + TEST_RESULT_REQUIRE(testTree->commit( + [this](root_sector_info cri) { rootSectorInfo = cri; })); [[maybe_unused]] auto expectedRootMac = vefs::utils::make_byte_array( 0xe2, 0x1b, 0x52, 0x74, 0xe1, 0xd5, 0x8b, 0x69, 0x87, 0x36, 0x88, @@ -224,8 +224,8 @@ BOOST_AUTO_TEST_CASE(shrink_on_commit_if_possible) TEST_RESULT_REQUIRE(testTree->erase_leaf(2019)); root_sector_info newRootInfo; - TEST_RESULT_REQUIRE(testTree->commit([&newRootInfo](root_sector_info cri) - { newRootInfo = cri; })); + TEST_RESULT_REQUIRE(testTree->commit( + [&newRootInfo](root_sector_info cri) { newRootInfo = cri; })); // BOOST_TEST(newRootInfo.root.mac == expectedRootMac); BOOST_TEST(newRootInfo.root.sector == sector_id{1}); diff --git a/tests/test_utils/test-utils.cpp b/tests/test_utils/test-utils.cpp index b2ec882..38a8bfb 100644 --- a/tests/test_utils/test-utils.cpp +++ b/tests/test_utils/test-utils.cpp @@ -5,8 +5,7 @@ namespace vefs_tests { -vefs::llfio::path_handle const current_path = [] -{ +vefs::llfio::path_handle const current_path = [] { auto currentPath = std::filesystem::current_path(); return vefs::llfio::path(currentPath).value(); }(); diff --git a/tests/tree_lut-tests.cpp b/tests/tree_lut-tests.cpp index 32e99d2..cd1e9df 100644 --- a/tests/tree_lut-tests.cpp +++ b/tests/tree_lut-tests.cpp @@ -19,14 +19,14 @@ BOOST_AUTO_TEST_CASE(tree_ref_width_lut) BOOST_AUTO_TEST_CASE(calculate_sector_pos_for_byte_in_sector_five) { - auto sector_position = vefs::detail::lut::sector_position_of(5 * 32702); + auto sector_position = vefs::detail::lut::sector_position_of(5 * 32'702); BOOST_TEST(sector_position == 4u); } BOOST_AUTO_TEST_CASE(calculate_sector_pos_for_byte_in_sector_three) { - auto sector_position = vefs::detail::lut::sector_position_of(3 * 32702); + auto sector_position = vefs::detail::lut::sector_position_of(3 * 32'702); BOOST_TEST(sector_position == 2u); } diff --git a/tests/tree_walker-tests.cpp b/tests/tree_walker-tests.cpp index 93f8eb7..5d9fcf0 100644 --- a/tests/tree_walker-tests.cpp +++ b/tests/tree_walker-tests.cpp @@ -19,24 +19,24 @@ BOOST_AUTO_TEST_CASE(tree_position_only_considers_eight_layer_bits) vefs::detail::tree_position test_subject = vefs::detail::tree_position(0xF, 0xf6e5); - BOOST_TEST(test_subject.raw() == (0xe50000000000000f)); + BOOST_TEST(test_subject.raw() == (0xe500'0000'0000'000f)); } BOOST_AUTO_TEST_CASE(tree_position_only_considers_56_position_bits) { - std::uint64_t position_inside_layer = 0x1122334455667788; + std::uint64_t position_inside_layer = 0x1122'3344'5566'7788; vefs::detail::tree_position test_subject = vefs::detail::tree_position(position_inside_layer, 0xf6); - BOOST_TEST(test_subject.raw() == (0xf622334455667788u)); + BOOST_TEST(test_subject.raw() == (0xf622'3344'5566'7788u)); } BOOST_AUTO_TEST_CASE(tree_position_init_with_max_value) { vefs::detail::tree_position test_subject = vefs::detail::tree_position(); - BOOST_TEST(test_subject.raw() == 0xffffffffffffffffu); + BOOST_TEST(test_subject.raw() == 0xffff'ffff'ffff'ffffu); } BOOST_AUTO_TEST_CASE(tree_position_sets_new_layer) @@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(tree_position_sets_new_layer) test_subject.layer(0xab); - BOOST_TEST(test_subject.raw() == 0xab0000000000000fu); + BOOST_TEST(test_subject.raw() == 0xab00'0000'0000'000fu); } BOOST_AUTO_TEST_CASE(position_returns_position_potion_of_position) @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(tree_position_sets_new_position) test_subject.position(0xabu); - BOOST_TEST(test_subject.raw() == 0xf6000000000000abu); + BOOST_TEST(test_subject.raw() == 0xf600'0000'0000'00abu); } BOOST_AUTO_TEST_CASE(parent_returns_position_of_parent) @@ -91,9 +91,9 @@ BOOST_AUTO_TEST_CASE(parent_array_offset) BOOST_AUTO_TEST_CASE(bool_comparison_returns_true_for_equal_positions) { vefs::detail::tree_position test_subject - = vefs::detail::tree_position(123456, 78); + = vefs::detail::tree_position(123'456, 78); vefs::detail::tree_position tree_position_to_compare - = vefs::detail::tree_position(123456, 78); + = vefs::detail::tree_position(123'456, 78); auto result = test_subject == tree_position_to_compare; @@ -103,9 +103,9 @@ BOOST_AUTO_TEST_CASE(bool_comparison_returns_true_for_equal_positions) BOOST_AUTO_TEST_CASE(bool_comparison_returns_false_for_unequal_positions) { vefs::detail::tree_position test_subject - = vefs::detail::tree_position(123456, 78); + = vefs::detail::tree_position(123'456, 78); vefs::detail::tree_position tree_position_to_compare - = vefs::detail::tree_position(123456, 79); + = vefs::detail::tree_position(123'456, 79); auto result = test_subject != tree_position_to_compare; @@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE(iterator_test_previous_in_beginning_of_layer) auto path = test_subject.previous(); BOOST_TEST(0u == path.position(3)); - BOOST_TEST(0xffffffffffffffffu == path.position(2)); + BOOST_TEST(0xffff'ffff'ffff'ffffu == path.position(2)); } BOOST_AUTO_TEST_CASE(iterator_test_end) diff --git a/tests/vefs/cache/lru_policy.test.cpp b/tests/vefs/cache/lru_policy.test.cpp index 2f75808..d731568 100644 --- a/tests/vefs/cache/lru_policy.test.cpp +++ b/tests/vefs/cache/lru_policy.test.cpp @@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE(ctor_with_pages) BOOST_AUTO_TEST_CASE(insert_one) { test_policy::page_state::state_type gen; - test_key key = 0xdeadbeef; + test_key key = 0xdead'beef; test_index idx = 1U; BOOST_TEST_REQUIRE((pages[idx].try_start_replace(gen) diff --git a/tests/vefs/cache/slru_policy.test.cpp b/tests/vefs/cache/slru_policy.test.cpp index de7a23f..b8a0f7d 100644 --- a/tests/vefs/cache/slru_policy.test.cpp +++ b/tests/vefs/cache/slru_policy.test.cpp @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(ctor_with_pages) BOOST_AUTO_TEST_CASE(insert_one) { test_policy::page_state::state_type gen; - test_key key = 0xdeadbeef; + test_key key = 0xdead'beef; test_index idx = 1U; BOOST_TEST_REQUIRE((pages[idx].try_start_replace(gen) @@ -103,7 +103,7 @@ BOOST_FIXTURE_TEST_CASE(move_to_back_on_access, with_elements) BOOST_FIXTURE_TEST_CASE(newly_inserted_are_due_before_protected, with_elements) { test_key protectedKey = 0U; - test_key newElementKey = 0xdeadbeef; + test_key newElementKey = 0xdead'beef; test_index newElementIndex = 32U; BOOST_TEST(subject.on_access(protectedKey, 0U)); { diff --git a/tests/vefs/cache/w-tinylfu_policy.test.cpp b/tests/vefs/cache/w-tinylfu_policy.test.cpp index 8220c18..68cd2d5 100644 --- a/tests/vefs/cache/w-tinylfu_policy.test.cpp +++ b/tests/vefs/cache/w-tinylfu_policy.test.cpp @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(ctor_with_pages) BOOST_AUTO_TEST_CASE(insert_one) { test_policy::page_state::state_type gen; - test_key key = 0xdeadbeef; + test_key key = 0xdead'beef; test_index idx = 1U; BOOST_TEST_REQUIRE((pages[idx].try_start_replace(gen) diff --git a/tests/vefs/hash/hash_algorithm.test.cpp b/tests/vefs/hash/hash_algorithm.test.cpp index e48cfa4..120ef03 100644 --- a/tests/vefs/hash/hash_algorithm.test.cpp +++ b/tests/vefs/hash/hash_algorithm.test.cpp @@ -11,7 +11,7 @@ enum class non_trivially_hashable : std::uint32_t { }; -} +} // namespace vefs_tests::hash_algorithm_tmp template <> inline constexpr bool vefs::disable_trivially_hashable< From 5993fb57dc674aec3111bfef114b454a3bad194b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20S=2E=20Ga=C3=9Fmann?= Date: Sun, 26 Nov 2023 21:32:45 +0000 Subject: [PATCH 6/6] style: Blame-ignore reformatting with clang-format 16 --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..a1e9f02 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# style: Reformat sources with clang-format v16 +f00b51e62fefccd752a2d1ce13e947105ffed370