From 830470a54ec72092a7c26a148dbf16685eb62dff Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Wed, 26 Feb 2025 23:55:20 +0000 Subject: [PATCH 01/37] Add FreeBSD CI build --- .github/workflows/coverage.yml | 3 +- .github/workflows/freebsd.yaml | 46 +++++++++++++++++++++ .github/workflows/macos.yml | 4 +- .github/workflows/{linux.yml => ubuntu.yml} | 4 +- .github/workflows/windows.yml | 5 ++- 5 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/freebsd.yaml rename .github/workflows/{linux.yml => ubuntu.yml} (98%) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 929dca6b..d3218844 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,4 +1,4 @@ -name: coverage +name: Coverage on: push: @@ -7,6 +7,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + - 'scripts/**' jobs: build: diff --git a/.github/workflows/freebsd.yaml b/.github/workflows/freebsd.yaml new file mode 100644 index 00000000..42e4ab35 --- /dev/null +++ b/.github/workflows/freebsd.yaml @@ -0,0 +1,46 @@ +name: FreeBSD + +on: + push: + branches: + - master + paths-ignore: + - '**.md' + - 'docs/**' + - 'scripts/**' + + pull_request: + branches: + - master + paths-ignore: + - '**.md' + - 'docs/**' + - 'scripts/**' + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + build_type: [ Debug, Release ] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up FreeBSD VM + uses: vmactions/freebsd-vm@v1 + with: + freebsd-version: '14.2' + architecture: 'x86_64' + + - name: Configure, Build, and Test (${{ matrix.build_type }}) + run: | + freebsd-run "cd /github/workspace && mkdir -p build && cd build && \ + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_CXX_STANDARD=17 \ + -DQUILL_VERBOSE_MAKEFILE=ON \ + -DQUILL_BUILD_TESTS=ON \ + -DQUILL_BUILD_EXAMPLES=ON .. && \ + threads=\$(sysctl -n hw.ncpu) && \ + cmake --build . --config ${{ matrix.build_type }} --parallel \$threads && \ + ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel \$threads --output-on-failure" diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 0a67fecd..a49322d0 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -1,4 +1,4 @@ -name: macos +name: macOS on: push: @@ -7,6 +7,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + - 'scripts/**' pull_request: branches: @@ -14,6 +15,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + - 'scripts/**' jobs: build: diff --git a/.github/workflows/linux.yml b/.github/workflows/ubuntu.yml similarity index 98% rename from .github/workflows/linux.yml rename to .github/workflows/ubuntu.yml index 52e83f27..71450cb0 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/ubuntu.yml @@ -1,4 +1,4 @@ -name: linux +name: Ubuntu on: push: @@ -7,6 +7,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + - 'scripts/**' pull_request: branches: @@ -14,6 +15,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + - 'scripts/**' jobs: build: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 960f1031..c80b316e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,5 +1,4 @@ - -name: windows +name: Windows on: push: @@ -8,6 +7,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + - 'scripts/**' pull_request: branches: @@ -15,6 +15,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + - 'scripts/**' jobs: msvc: From 74bc69b7dfcd98d186cf9791c1cc9499d8d7ec2f Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 00:00:34 +0000 Subject: [PATCH 02/37] Add FreeBSD CI build --- .github/workflows/freebsd.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/freebsd.yaml b/.github/workflows/freebsd.yaml index 42e4ab35..6529502c 100644 --- a/.github/workflows/freebsd.yaml +++ b/.github/workflows/freebsd.yaml @@ -35,7 +35,7 @@ jobs: - name: Configure, Build, and Test (${{ matrix.build_type }}) run: | - freebsd-run "cd /github/workspace && mkdir -p build && cd build && \ + CMD="cd /github/workspace && mkdir -p build && cd build && \ cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_CXX_STANDARD=17 \ -DQUILL_VERBOSE_MAKEFILE=ON \ @@ -44,3 +44,4 @@ jobs: threads=\$(sysctl -n hw.ncpu) && \ cmake --build . --config ${{ matrix.build_type }} --parallel \$threads && \ ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel \$threads --output-on-failure" + freebsd-run "$CMD" From 7ea37d90fb1ef400b24bf16de1b879318965109f Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 00:02:39 +0000 Subject: [PATCH 03/37] Add FreeBSD CI build --- .github/workflows/freebsd.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/freebsd.yaml b/.github/workflows/freebsd.yaml index 6529502c..6483315c 100644 --- a/.github/workflows/freebsd.yaml +++ b/.github/workflows/freebsd.yaml @@ -35,13 +35,13 @@ jobs: - name: Configure, Build, and Test (${{ matrix.build_type }}) run: | - CMD="cd /github/workspace && mkdir -p build && cd build && \ + cd /github/workspace + mkdir -p build && cd build cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_CXX_STANDARD=17 \ -DQUILL_VERBOSE_MAKEFILE=ON \ -DQUILL_BUILD_TESTS=ON \ - -DQUILL_BUILD_EXAMPLES=ON .. && \ - threads=\$(sysctl -n hw.ncpu) && \ - cmake --build . --config ${{ matrix.build_type }} --parallel \$threads && \ - ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel \$threads --output-on-failure" - freebsd-run "$CMD" + -DQUILL_BUILD_EXAMPLES=ON .. + threads=$(sysctl -n hw.ncpu) + cmake --build . --config ${{ matrix.build_type }} --parallel $threads + ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel $threads --output-on-failure From e6caf4982091f699b2ef5083c9335940d5f89d4a Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 00:34:00 +0000 Subject: [PATCH 04/37] Add FreeBSD CI build --- .github/workflows/freebsd.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/freebsd.yaml b/.github/workflows/freebsd.yaml index 6483315c..52836946 100644 --- a/.github/workflows/freebsd.yaml +++ b/.github/workflows/freebsd.yaml @@ -35,7 +35,6 @@ jobs: - name: Configure, Build, and Test (${{ matrix.build_type }}) run: | - cd /github/workspace mkdir -p build && cd build cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_CXX_STANDARD=17 \ From a95838a57bcd6821401879dfcdc5ad7d1caef834 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 00:38:30 +0000 Subject: [PATCH 05/37] Add FreeBSD CI build --- .github/workflows/freebsd.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/freebsd.yaml b/.github/workflows/freebsd.yaml index 52836946..80ca254c 100644 --- a/.github/workflows/freebsd.yaml +++ b/.github/workflows/freebsd.yaml @@ -35,7 +35,6 @@ jobs: - name: Configure, Build, and Test (${{ matrix.build_type }}) run: | - mkdir -p build && cd build cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_CXX_STANDARD=17 \ -DQUILL_VERBOSE_MAKEFILE=ON \ From d405c6c891de704e75606626616d65da1167a12a Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 00:42:23 +0000 Subject: [PATCH 06/37] Add FreeBSD CI build --- .github/workflows/freebsd.yaml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/freebsd.yaml b/.github/workflows/freebsd.yaml index 80ca254c..bb96b874 100644 --- a/.github/workflows/freebsd.yaml +++ b/.github/workflows/freebsd.yaml @@ -27,19 +27,17 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up FreeBSD VM + - name: FreeBSD Build and Test (${{ matrix.build_type }}) uses: vmactions/freebsd-vm@v1 with: freebsd-version: '14.2' architecture: 'x86_64' - - - name: Configure, Build, and Test (${{ matrix.build_type }}) - run: | - cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DCMAKE_CXX_STANDARD=17 \ - -DQUILL_VERBOSE_MAKEFILE=ON \ - -DQUILL_BUILD_TESTS=ON \ - -DQUILL_BUILD_EXAMPLES=ON .. - threads=$(sysctl -n hw.ncpu) - cmake --build . --config ${{ matrix.build_type }} --parallel $threads - ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel $threads --output-on-failure + run: | + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_CXX_STANDARD=17 \ + -DQUILL_VERBOSE_MAKEFILE=ON \ + -DQUILL_BUILD_TESTS=ON \ + -DQUILL_BUILD_EXAMPLES=ON $GITHUB_WORKSPACE + threads=\$(sysctl -n hw.ncpu) + cmake --build . --config ${{ matrix.build_type }} --parallel $threads + ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel $threads --output-on-failure From 66c32b01ef3495befa1a16d325a160aa80007350 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 00:55:10 +0000 Subject: [PATCH 07/37] Add FreeBSD CI build --- .github/workflows/freebsd.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/freebsd.yaml b/.github/workflows/freebsd.yaml index bb96b874..49990ef8 100644 --- a/.github/workflows/freebsd.yaml +++ b/.github/workflows/freebsd.yaml @@ -32,6 +32,7 @@ jobs: with: freebsd-version: '14.2' architecture: 'x86_64' + usesh: true run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_CXX_STANDARD=17 \ From d77c0fd30651566c5cd3b6b0778f9f10098cac0b Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 00:55:51 +0000 Subject: [PATCH 08/37] Add FreeBSD CI build --- .github/workflows/freebsd.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/freebsd.yaml b/.github/workflows/freebsd.yaml index 49990ef8..1234459a 100644 --- a/.github/workflows/freebsd.yaml +++ b/.github/workflows/freebsd.yaml @@ -33,6 +33,8 @@ jobs: freebsd-version: '14.2' architecture: 'x86_64' usesh: true + prepare: | + pkg install -y cmake gcc run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_CXX_STANDARD=17 \ From 59a736b0615f6856cb979acd539cf5dc338d56f6 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 01:03:56 +0000 Subject: [PATCH 09/37] Add FreeBSD CI build --- .github/workflows/freebsd.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/freebsd.yaml b/.github/workflows/freebsd.yaml index 1234459a..2c716f33 100644 --- a/.github/workflows/freebsd.yaml +++ b/.github/workflows/freebsd.yaml @@ -36,11 +36,7 @@ jobs: prepare: | pkg install -y cmake gcc run: | - cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DCMAKE_CXX_STANDARD=17 \ - -DQUILL_VERBOSE_MAKEFILE=ON \ - -DQUILL_BUILD_TESTS=ON \ - -DQUILL_BUILD_EXAMPLES=ON $GITHUB_WORKSPACE - threads=\$(sysctl -n hw.ncpu) - cmake --build . --config ${{ matrix.build_type }} --parallel $threads - ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel $threads --output-on-failure + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE"; \ + threads=\$(sysctl -n hw.ncpu); \ + cmake --build . --config ${{ matrix.build_type }} --parallel \$threads; \ + ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel \$threads --output-on-failure From a866bd630944f4798e7457f43dffe440b5929ea5 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 01:05:33 +0000 Subject: [PATCH 10/37] Add FreeBSD CI build --- .github/workflows/{freebsd.yaml => freebsd.yml} | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) rename .github/workflows/{freebsd.yaml => freebsd.yml} (78%) diff --git a/.github/workflows/freebsd.yaml b/.github/workflows/freebsd.yml similarity index 78% rename from .github/workflows/freebsd.yaml rename to .github/workflows/freebsd.yml index 2c716f33..06b44f76 100644 --- a/.github/workflows/freebsd.yaml +++ b/.github/workflows/freebsd.yml @@ -36,7 +36,6 @@ jobs: prepare: | pkg install -y cmake gcc run: | - cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE"; \ - threads=\$(sysctl -n hw.ncpu); \ - cmake --build . --config ${{ matrix.build_type }} --parallel \$threads; \ - ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel \$threads --output-on-failure + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" + cmake --build . --config ${{ matrix.build_type }} + ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --output-on-failure From 75d38f8bbe9d5adcd559aa780b51f664902354d4 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 01:11:20 +0000 Subject: [PATCH 11/37] Add FreeBSD CI build --- .github/workflows/freebsd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 06b44f76..005118ff 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -37,5 +37,5 @@ jobs: pkg install -y cmake gcc run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" - cmake --build . --config ${{ matrix.build_type }} - ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --output-on-failure + cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel 4 --output-on-failure From 144cc91dd2b8b9f850acb2eef16e4d22f3c20e99 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 01:13:35 +0000 Subject: [PATCH 12/37] Add FreeBSD CI build --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 489decf4..9c0e43e4 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@

Asynchronous Low Latency C++ Logging Library

- - linux-ci + + linux-ci macos-ci From 6bf3cc7fbc1bc22aa502dce3e1d01390fd348391 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 01:17:56 +0000 Subject: [PATCH 13/37] Add FreeBSD CI build --- .github/workflows/freebsd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 005118ff..b7fc5bdd 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -34,7 +34,7 @@ jobs: architecture: 'x86_64' usesh: true prepare: | - pkg install -y cmake gcc + pkg install -y cmake run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 From 24d9a9259d361ed5a37f3a632260bcce24b61c7e Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 01:33:06 +0000 Subject: [PATCH 14/37] Add FreeBSD CI build --- include/quill/backend/BackendUtilities.h | 2 ++ include/quill/backend/ThreadUtilities.h | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/quill/backend/BackendUtilities.h b/include/quill/backend/BackendUtilities.h index 37bbe9f4..a26e14b5 100644 --- a/include/quill/backend/BackendUtilities.h +++ b/include/quill/backend/BackendUtilities.h @@ -42,11 +42,13 @@ #elif defined(__NetBSD__) #include #include + #include #elif defined(__FreeBSD__) #include #include #include #elif defined(__DragonFly__) + #include #include #include #else diff --git a/include/quill/backend/ThreadUtilities.h b/include/quill/backend/ThreadUtilities.h index f5613916..2943f9f5 100644 --- a/include/quill/backend/ThreadUtilities.h +++ b/include/quill/backend/ThreadUtilities.h @@ -37,11 +37,14 @@ #include #elif defined(__NetBSD__) #include + #include #include #elif defined(__FreeBSD__) + #include #include #include #elif defined(__DragonFly__) + #include #include #include #endif @@ -159,15 +162,13 @@ QUILL_NODISCARD QUILL_EXPORT QUILL_ATTRIBUTE_USED inline std::string get_thread_ #else // Apple, linux char thread_name[16] = {'\0'}; - #if defined(__FreeBSD__) - pthread_get_name_np(pthread_self(), &thread_name[0], 16); - #else auto res = pthread_getname_np(pthread_self(), &thread_name[0], 16); + if (res != 0) { QUILL_THROW(QuillError{"Failed to get thread name. error: " + std::to_string(res)}); } - #endif + return std::string{&thread_name[0], strlen(&thread_name[0])}; #endif } From 2bcd23906e1d4b448a0d2b670811d63efa6528b6 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 01:51:13 +0000 Subject: [PATCH 15/37] Add FreeBSD CI build --- .github/workflows/freebsd.yml | 1 + include/quill/backend/ThreadUtilities.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index b7fc5bdd..d5917b91 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -32,6 +32,7 @@ jobs: with: freebsd-version: '14.2' architecture: 'x86_64' + mem: 16384 usesh: true prepare: | pkg install -y cmake diff --git a/include/quill/backend/ThreadUtilities.h b/include/quill/backend/ThreadUtilities.h index 2943f9f5..cfaf7073 100644 --- a/include/quill/backend/ThreadUtilities.h +++ b/include/quill/backend/ThreadUtilities.h @@ -163,7 +163,7 @@ QUILL_NODISCARD QUILL_EXPORT QUILL_ATTRIBUTE_USED inline std::string get_thread_ // Apple, linux char thread_name[16] = {'\0'}; auto res = pthread_getname_np(pthread_self(), &thread_name[0], 16); - + if (res != 0) { QUILL_THROW(QuillError{"Failed to get thread name. error: " + std::to_string(res)}); From 2c064a648c36e11a620edda302b4086cb323a3ce Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 02:28:15 +0000 Subject: [PATCH 16/37] Add FreeBSD CI build --- .github/workflows/bsd.yml | 110 ++++++++++++++++++++++++++++++++++ .github/workflows/freebsd.yml | 42 ------------- 2 files changed, 110 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/bsd.yml delete mode 100644 .github/workflows/freebsd.yml diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml new file mode 100644 index 00000000..f2c92c2a --- /dev/null +++ b/.github/workflows/bsd.yml @@ -0,0 +1,110 @@ +name: BSD + +on: + push: + branches: + - master + paths-ignore: + - '**.md' + - 'docs/**' + - 'scripts/**' + pull_request: + branches: + - master + paths-ignore: + - '**.md' + - 'docs/**' + - 'scripts/**' + +jobs: + freebsd: + runs-on: ubuntu-latest + strategy: + matrix: + build_type: [ Debug, Release ] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: FreeBSD Build and Test (${{ matrix.build_type }}) + uses: vmactions/freebsd-vm@v1 + with: + freebsd-version: '14.2' + architecture: 'x86_64' + mem: 16384 + usesh: true + prepare: | + pkg install -y cmake + run: | + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" + cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure + + netbsd: + runs-on: ubuntu-latest + strategy: + matrix: + build_type: [ Debug, Release ] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: NetBSD Build and Test (${{ matrix.build_type }}) + uses: vmactions/netbsd-vm@v1 + with: + netbsd-version: '10.0' + architecture: 'x86_64' + mem: 16384 + usesh: true + prepare: | + pkgin install -y cmake + run: | + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" + cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure + + openbsd: + runs-on: ubuntu-latest + strategy: + matrix: + build_type: [ Debug, Release ] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: OpenBSD Build and Test (${{ matrix.build_type }}) + uses: vmactions/openbsd-vm@v1 + with: + openbsd-version: '7.5' + architecture: 'x86_64' + mem: 16384 + usesh: true + prepare: | + pkg_add cmake + run: | + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" + cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure + + dragonfly: + runs-on: ubuntu-latest + strategy: + matrix: + build_type: [ Debug, Release ] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: DragonFly Build and Test (${{ matrix.build_type }}) + uses: vmactions/dragonfly-vm@v1 + with: + dragonfly-version: '6.4.0' + architecture: 'x86_64' + mem: 16384 + usesh: true + prepare: | + pkg install -y cmake + run: | + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" + cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml deleted file mode 100644 index d5917b91..00000000 --- a/.github/workflows/freebsd.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: FreeBSD - -on: - push: - branches: - - master - paths-ignore: - - '**.md' - - 'docs/**' - - 'scripts/**' - - pull_request: - branches: - - master - paths-ignore: - - '**.md' - - 'docs/**' - - 'scripts/**' - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - build_type: [ Debug, Release ] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: FreeBSD Build and Test (${{ matrix.build_type }}) - uses: vmactions/freebsd-vm@v1 - with: - freebsd-version: '14.2' - architecture: 'x86_64' - mem: 16384 - usesh: true - prepare: | - pkg install -y cmake - run: | - cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" - cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} ${{ matrix.ctest_options }} --parallel 4 --output-on-failure From 89d0e52e744757c429a38c3ba3a55aabcfc880e3 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 02:30:30 +0000 Subject: [PATCH 17/37] Add FreeBSD CI build --- .github/workflows/bsd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index f2c92c2a..9179660b 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -96,7 +96,7 @@ jobs: uses: actions/checkout@v4 - name: DragonFly Build and Test (${{ matrix.build_type }}) - uses: vmactions/dragonfly-vm@v1 + uses: vmactions/dragonflybsd-vm@v1 with: dragonfly-version: '6.4.0' architecture: 'x86_64' From 8f887fb181fd932cfdd3330b2d0065660504fc61 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 02:47:52 +0000 Subject: [PATCH 18/37] Add FreeBSD CI build --- .github/workflows/bsd.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 9179660b..5a1ffb8f 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -17,7 +17,7 @@ on: - 'scripts/**' jobs: - freebsd: + FreeBSD: runs-on: ubuntu-latest strategy: matrix: @@ -40,7 +40,7 @@ jobs: cmake --build . --config ${{ matrix.build_type }} --parallel 4 ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure - netbsd: + NetBSD: runs-on: ubuntu-latest strategy: matrix: @@ -57,13 +57,13 @@ jobs: mem: 16384 usesh: true prepare: | - pkgin install -y cmake + pkg_add cmake run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure - openbsd: + OpenBSD: runs-on: ubuntu-latest strategy: matrix: @@ -86,7 +86,7 @@ jobs: cmake --build . --config ${{ matrix.build_type }} --parallel 4 ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure - dragonfly: + DragonFlyBSD: runs-on: ubuntu-latest strategy: matrix: @@ -103,7 +103,10 @@ jobs: mem: 16384 usesh: true prepare: | - pkg install -y cmake + pkg install -y cmake gcc10 + # Set the new GCC as the default compiler for the build. + export CC=/usr/local/bin/gcc-10 + export CXX=/usr/local/bin/g++-10 run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 From d97a1d4e1ad4675b704fb45ea0ca41722ed28099 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 02:55:22 +0000 Subject: [PATCH 19/37] Add FreeBSD CI build --- .github/workflows/bsd.yml | 2 +- include/quill/backend/BackendUtilities.h | 5 ++--- include/quill/backend/ThreadUtilities.h | 6 ++++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 5a1ffb8f..ab5957f1 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -57,7 +57,7 @@ jobs: mem: 16384 usesh: true prepare: | - pkg_add cmake + pkgin install -y cmake run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 diff --git a/include/quill/backend/BackendUtilities.h b/include/quill/backend/BackendUtilities.h index a26e14b5..9853a928 100644 --- a/include/quill/backend/BackendUtilities.h +++ b/include/quill/backend/BackendUtilities.h @@ -146,18 +146,17 @@ QUILL_ATTRIBUTE_COLD inline void set_thread_name(char const* name) std::strncpy(truncated_name, name, 15); truncated_name[15] = '\0'; - #if defined(__FreeBSD__) + #if defined(__OpenBSD__) pthread_set_name_np(pthread_self(), name); - auto const res = 0; #else auto const res = pthread_setname_np(pthread_self(), name); - #endif if (res != 0) { QUILL_THROW(QuillError{std::string{"Failed to set thread name - error: " + std::to_string(res) + " error: " + strerror(res)}}); } + #endif #endif } diff --git a/include/quill/backend/ThreadUtilities.h b/include/quill/backend/ThreadUtilities.h index cfaf7073..566ac0b9 100644 --- a/include/quill/backend/ThreadUtilities.h +++ b/include/quill/backend/ThreadUtilities.h @@ -162,13 +162,15 @@ QUILL_NODISCARD QUILL_EXPORT QUILL_ATTRIBUTE_USED inline std::string get_thread_ #else // Apple, linux char thread_name[16] = {'\0'}; + #if defined(__OpenBSD__) + pthread_get_name_np(pthread_self(), &thread_name[0], 16); + #else auto res = pthread_getname_np(pthread_self(), &thread_name[0], 16); - if (res != 0) { QUILL_THROW(QuillError{"Failed to get thread name. error: " + std::to_string(res)}); } - + #endif return std::string{&thread_name[0], strlen(&thread_name[0])}; #endif } From 79cd7fbda112674c073dffafe7b6befd4e21f22f Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 02:57:22 +0000 Subject: [PATCH 20/37] Add FreeBSD CI build --- .github/workflows/bsd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index ab5957f1..6034749e 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -57,7 +57,7 @@ jobs: mem: 16384 usesh: true prepare: | - pkgin install -y cmake + /usr/sbin/pkg_add cmake run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 From 009901f30ba757993d1082bd06e5d14b55f6c57b Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 03:10:07 +0000 Subject: [PATCH 21/37] Add FreeBSD CI build --- include/quill/backend/BackendUtilities.h | 19 ++++++------------- include/quill/backend/ThreadUtilities.h | 19 ++++++------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/include/quill/backend/BackendUtilities.h b/include/quill/backend/BackendUtilities.h index 9853a928..aacaced8 100644 --- a/include/quill/backend/BackendUtilities.h +++ b/include/quill/backend/BackendUtilities.h @@ -35,23 +35,13 @@ #elif defined(__CYGWIN__) #include #include -#elif defined(__linux__) - #include - #include - #include -#elif defined(__NetBSD__) - #include - #include - #include -#elif defined(__FreeBSD__) - #include +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) #include #include -#elif defined(__DragonFly__) #include - #include - #include #else + // linux + #include #include #include #endif @@ -99,6 +89,9 @@ QUILL_ATTRIBUTE_COLD inline void set_cpu_affinity(uint16_t cpu_id) CPU_ZERO(&cpuset); CPU_SET(cpu_id, &cpuset); auto const err = pthread_setaffinity_np(pthread_self(), sizeof(cpuset_t), &cpuset); + #elif defined(__OpenBSD__) + // OpenBSD doesn't support CPU affinity, so we'll use a placeholder + auto const err = 0; // Assume success #else cpu_set_t cpuset; CPU_ZERO(&cpuset); diff --git a/include/quill/backend/ThreadUtilities.h b/include/quill/backend/ThreadUtilities.h index 566ac0b9..7b2ea15d 100644 --- a/include/quill/backend/ThreadUtilities.h +++ b/include/quill/backend/ThreadUtilities.h @@ -31,21 +31,14 @@ #include #include #include -#elif defined(__linux__) - #include - #include - #include -#elif defined(__NetBSD__) - #include - #include +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) + #include #include -#elif defined(__FreeBSD__) #include - #include - #include -#elif defined(__DragonFly__) - #include - #include +#else + // linux + #include + #include #include #endif From 0a17c678d5f4b12b4e595764ce21cd79f03a5a78 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 03:32:01 +0000 Subject: [PATCH 22/37] Add FreeBSD CI build --- include/quill/backend/BackendUtilities.h | 6 +++--- include/quill/backend/ThreadUtilities.h | 19 ++++++++++++++++--- include/quill/core/BoundedSPSCQueue.h | 21 --------------------- include/quill/sinks/FileSink.h | 12 ------------ 4 files changed, 19 insertions(+), 39 deletions(-) diff --git a/include/quill/backend/BackendUtilities.h b/include/quill/backend/BackendUtilities.h index aacaced8..d6dbd8fa 100644 --- a/include/quill/backend/BackendUtilities.h +++ b/include/quill/backend/BackendUtilities.h @@ -35,12 +35,12 @@ #elif defined(__CYGWIN__) #include #include -#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) + #include #include #include - #include #else - // linux + // linux, anything else #include #include #include diff --git a/include/quill/backend/ThreadUtilities.h b/include/quill/backend/ThreadUtilities.h index 7b2ea15d..017ba2be 100644 --- a/include/quill/backend/ThreadUtilities.h +++ b/include/quill/backend/ThreadUtilities.h @@ -31,14 +31,25 @@ #include #include #include -#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) - #include +#elif defined(__NetBSD__) + #include + #include #include +#elif defined(__FreeBSD__) #include + #include + #include +#elif defined(__DragonFly__) + #include + #include + #include +#elif defined(__OpenBSD__) + #include + #include #else // linux #include - #include + #include #include #endif @@ -193,6 +204,8 @@ QUILL_NODISCARD QUILL_EXPORT QUILL_ATTRIBUTE_USED inline uint32_t get_thread_id( return static_cast(lwpid); #elif defined(__DragonFly__) return static_cast(lwp_gettid()); +#elif defined(__OpenBSD__) + return static_cast(getthrid()); #else return reinterpret_cast(pthread_self()); // (Ab)use pthread_self as a last resort option #endif diff --git a/include/quill/core/BoundedSPSCQueue.h b/include/quill/core/BoundedSPSCQueue.h index f39bc10f..6bc3642b 100644 --- a/include/quill/core/BoundedSPSCQueue.h +++ b/include/quill/core/BoundedSPSCQueue.h @@ -15,29 +15,8 @@ #if defined(_WIN32) #include -#elif defined(__APPLE__) - #include - #include -#elif defined(__CYGWIN__) - #include - #include -#elif defined(__linux__) - #include -#elif defined(__NetBSD__) - #include - #include - #include -#elif defined(__FreeBSD__) - #include - #include - #include -#elif defined(__DragonFly__) - #include - #include - #include #else #include - #include #include #endif diff --git a/include/quill/sinks/FileSink.h b/include/quill/sinks/FileSink.h index da46cfaa..2e820e6c 100644 --- a/include/quill/sinks/FileSink.h +++ b/include/quill/sinks/FileSink.h @@ -37,18 +37,6 @@ #include #include -#elif defined(__APPLE__) - #include -#elif defined(__CYGWIN__) - #include -#elif defined(__linux__) - #include -#elif defined(__NetBSD__) - #include -#elif defined(__FreeBSD__) - #include -#elif defined(__DragonFly__) - #include #else #include #endif From c44d4da9ebfad895a90a9eb399a1939899e48d40 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 03:49:39 +0000 Subject: [PATCH 23/37] Add FreeBSD CI build --- .github/workflows/bsd.yml | 5 +---- include/quill/backend/BackendUtilities.h | 10 +++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 6034749e..ce7d5647 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -104,10 +104,7 @@ jobs: usesh: true prepare: | pkg install -y cmake gcc10 - # Set the new GCC as the default compiler for the build. - export CC=/usr/local/bin/gcc-10 - export CXX=/usr/local/bin/g++-10 run: | - cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=/usr/local/bin/gcc-10 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-10 -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure diff --git a/include/quill/backend/BackendUtilities.h b/include/quill/backend/BackendUtilities.h index d6dbd8fa..9ea292bb 100644 --- a/include/quill/backend/BackendUtilities.h +++ b/include/quill/backend/BackendUtilities.h @@ -82,6 +82,12 @@ QUILL_ATTRIBUTE_COLD inline void set_cpu_affinity(uint16_t cpu_id) #if defined(__NetBSD__) cpuset_t* cpuset; cpuset = cpuset_create(); + if (cpuset == nullptr) + { + QUILL_THROW(QuillError{"Failed to create cpuset"}); + } + cpuset_zero(cpuset); + cpuset_set(cpu_id, cpuset); auto const err = pthread_setaffinity_np(pthread_self(), cpuset_size(cpuset), cpuset); cpuset_destroy(cpuset); #elif defined(__FreeBSD__) @@ -91,7 +97,7 @@ QUILL_ATTRIBUTE_COLD inline void set_cpu_affinity(uint16_t cpu_id) auto const err = pthread_setaffinity_np(pthread_self(), sizeof(cpuset_t), &cpuset); #elif defined(__OpenBSD__) // OpenBSD doesn't support CPU affinity, so we'll use a placeholder - auto const err = 0; // Assume success + auto const err = cpu_id; // Assume success #else cpu_set_t cpuset; CPU_ZERO(&cpuset); @@ -141,6 +147,8 @@ QUILL_ATTRIBUTE_COLD inline void set_thread_name(char const* name) #if defined(__OpenBSD__) pthread_set_name_np(pthread_self(), name); + #elif defined(__NetBSD__) + auto const res = pthread_setname_np(pthread_self(), name, nullptr); #else auto const res = pthread_setname_np(pthread_self(), name); From 9c160ed45ab2f7ca1e3eccd8f96b72d67b9d828e Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 04:00:18 +0000 Subject: [PATCH 24/37] Add FreeBSD CI build --- .github/workflows/bsd.yml | 2 +- include/quill/backend/BackendUtilities.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index ce7d5647..2bc76d86 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -105,6 +105,6 @@ jobs: prepare: | pkg install -y cmake gcc10 run: | - cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=/usr/local/bin/gcc-10 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-10 -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=$(which gcc10) -DCMAKE_CXX_COMPILER=$(which g++10) -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure diff --git a/include/quill/backend/BackendUtilities.h b/include/quill/backend/BackendUtilities.h index 9ea292bb..d3a8cc2b 100644 --- a/include/quill/backend/BackendUtilities.h +++ b/include/quill/backend/BackendUtilities.h @@ -97,7 +97,8 @@ QUILL_ATTRIBUTE_COLD inline void set_cpu_affinity(uint16_t cpu_id) auto const err = pthread_setaffinity_np(pthread_self(), sizeof(cpuset_t), &cpuset); #elif defined(__OpenBSD__) // OpenBSD doesn't support CPU affinity, so we'll use a placeholder - auto const err = cpu_id; // Assume success + (void)cpu_id; + auto const err = 0; // Assume success #else cpu_set_t cpuset; CPU_ZERO(&cpuset); From 1dffc9ee5ca73cd70c893f423aab3f20c907cea4 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 04:01:24 +0000 Subject: [PATCH 25/37] Add FreeBSD CI build --- include/quill/backend/BackendUtilities.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/quill/backend/BackendUtilities.h b/include/quill/backend/BackendUtilities.h index d3a8cc2b..6e828e7d 100644 --- a/include/quill/backend/BackendUtilities.h +++ b/include/quill/backend/BackendUtilities.h @@ -150,6 +150,12 @@ QUILL_ATTRIBUTE_COLD inline void set_thread_name(char const* name) pthread_set_name_np(pthread_self(), name); #elif defined(__NetBSD__) auto const res = pthread_setname_np(pthread_self(), name, nullptr); + + if (res != 0) + { + QUILL_THROW(QuillError{std::string{"Failed to set thread name - error: " + std::to_string(res) + + " error: " + strerror(res)}}); + } #else auto const res = pthread_setname_np(pthread_self(), name); From 9eea6942e8a277c5387ea414165db6c2ff7d51fc Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 04:15:28 +0000 Subject: [PATCH 26/37] Add FreeBSD CI build --- .github/workflows/bsd.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 2bc76d86..32d06a40 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -29,8 +29,8 @@ jobs: - name: FreeBSD Build and Test (${{ matrix.build_type }}) uses: vmactions/freebsd-vm@v1 with: - freebsd-version: '14.2' - architecture: 'x86_64' + release: '14.2' + arch: 'x86_64' mem: 16384 usesh: true prepare: | @@ -52,8 +52,8 @@ jobs: - name: NetBSD Build and Test (${{ matrix.build_type }}) uses: vmactions/netbsd-vm@v1 with: - netbsd-version: '10.0' - architecture: 'x86_64' + release: '10.0' + arch: 'x86_64' mem: 16384 usesh: true prepare: | @@ -75,8 +75,8 @@ jobs: - name: OpenBSD Build and Test (${{ matrix.build_type }}) uses: vmactions/openbsd-vm@v1 with: - openbsd-version: '7.5' - architecture: 'x86_64' + release: '7.5' + arch: 'x86_64' mem: 16384 usesh: true prepare: | @@ -98,8 +98,8 @@ jobs: - name: DragonFly Build and Test (${{ matrix.build_type }}) uses: vmactions/dragonflybsd-vm@v1 with: - dragonfly-version: '6.4.0' - architecture: 'x86_64' + release: '6.4.0' + arch: 'x86_64' mem: 16384 usesh: true prepare: | @@ -107,4 +107,4 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=$(which gcc10) -DCMAKE_CXX_COMPILER=$(which g++10) -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure +# ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure From 01fee980f96baa9f8ed4abb6457a58864709e8f6 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 04:36:28 +0000 Subject: [PATCH 27/37] Add FreeBSD CI build --- .github/workflows/bsd.yml | 2 +- include/quill/backend/RdtscClock.h | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 32d06a40..42ae6c56 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -107,4 +107,4 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=$(which gcc10) -DCMAKE_CXX_COMPILER=$(which g++10) -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 -# ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure + ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure diff --git a/include/quill/backend/RdtscClock.h b/include/quill/backend/RdtscClock.h index 645612d1..fc8522a8 100644 --- a/include/quill/backend/RdtscClock.h +++ b/include/quill/backend/RdtscClock.h @@ -59,16 +59,16 @@ class RdtscClock for (size_t i = 0; i < trials; ++i) { - auto const beg_ts = - std::chrono::nanoseconds{std::chrono::steady_clock::now().time_since_epoch().count()}; + auto const beg_ts = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()); uint64_t const beg_tsc = rdtsc(); std::chrono::nanoseconds elapsed_ns; uint64_t end_tsc; do { - auto const end_ts = - std::chrono::nanoseconds{std::chrono::steady_clock::now().time_since_epoch().count()}; + auto const end_ts = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()); end_tsc = rdtsc(); elapsed_ns = end_ts - beg_ts; // calculates ns between two timespecs @@ -163,8 +163,9 @@ class RdtscClock { uint64_t const beg = rdtsc(); // we force convert to nanoseconds because the precision of system_clock::time-point is not portable across platforms. - int64_t const wall_time = - std::chrono::nanoseconds{std::chrono::system_clock::now().time_since_epoch()}.count(); + int64_t const wall_time = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); uint64_t const end = rdtsc(); if (QUILL_LIKELY(end - beg <= lag)) From 5a0c54e18f9f9c30ac319a8142b59eabb8f2ae74 Mon Sep 17 00:00:00 2001 From: odygrd Date: Thu, 27 Feb 2025 12:34:24 +0000 Subject: [PATCH 28/37] Fix builds --- .github/workflows/bsd.yml | 12 ++++++++---- .../BackendExceptionNotifierTest.cpp | 6 +++--- test/integration_tests/SignalHandlerLoggerTest.cpp | 2 +- test/integration_tests/SignalHandlerTest.cpp | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 42ae6c56..c34cd303 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -32,13 +32,14 @@ jobs: release: '14.2' arch: 'x86_64' mem: 16384 + cpu: 4 usesh: true prepare: | pkg install -y cmake run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure + ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure NetBSD: runs-on: ubuntu-latest @@ -55,13 +56,14 @@ jobs: release: '10.0' arch: 'x86_64' mem: 16384 + cpu: 4 usesh: true prepare: | /usr/sbin/pkg_add cmake run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure + ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure OpenBSD: runs-on: ubuntu-latest @@ -78,13 +80,14 @@ jobs: release: '7.5' arch: 'x86_64' mem: 16384 + cpu: 4 usesh: true prepare: | pkg_add cmake run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure + ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure DragonFlyBSD: runs-on: ubuntu-latest @@ -101,10 +104,11 @@ jobs: release: '6.4.0' arch: 'x86_64' mem: 16384 + cpu: 4 usesh: true prepare: | pkg install -y cmake gcc10 run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=$(which gcc10) -DCMAKE_CXX_COMPILER=$(which g++10) -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 4 --output-on-failure + ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure diff --git a/test/integration_tests/BackendExceptionNotifierTest.cpp b/test/integration_tests/BackendExceptionNotifierTest.cpp index a924af4b..d1d22dd1 100644 --- a/test/integration_tests/BackendExceptionNotifierTest.cpp +++ b/test/integration_tests/BackendExceptionNotifierTest.cpp @@ -39,7 +39,7 @@ TEST_CASE("backend_exception_notifier") // Set invalid thread name BackendOptions backend_options; - #if !defined(__FreeBSD__) + #if !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)) // On FreeBSD CPU_SET(cpu_id, &cpuset); with a big number crashes. // Setting to an invalid CPU. When we call quill::start() our error handler will be invoked and an error will be logged backend_options.cpu_affinity = static_cast(std::numeric_limits::max() - 1); @@ -68,7 +68,7 @@ TEST_CASE("backend_exception_notifier") LOG_INFO(logger, "frontend"); logger->flush_log(); - #if !defined(__FreeBSD__) + #if !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)) // Check our handler was invoked since either set_backend_thread_name or set_backend_thread_cpu_affinity should have failed REQUIRE_GE(error_notifier_invoked.load(), 1); #endif @@ -99,7 +99,7 @@ TEST_CASE("backend_exception_notifier") std::vector const file_contents = quill::testing::file_contents(filename); - #if !defined(__FreeBSD__) + #if !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)) // Look for the async errors std::string const expected_string_1 = "error handler invoked Failed to set cpu affinity "; std::string const expected_string_2 = "error handler invoked Failed to set thread name "; diff --git a/test/integration_tests/SignalHandlerLoggerTest.cpp b/test/integration_tests/SignalHandlerLoggerTest.cpp index bead501e..3b99e32d 100644 --- a/test/integration_tests/SignalHandlerLoggerTest.cpp +++ b/test/integration_tests/SignalHandlerLoggerTest.cpp @@ -87,7 +87,7 @@ TEST_CASE("signal_handler_logger") #elif defined(__apple_build_version__) REQUIRE(quill::testing::file_contains( file_contents_b, std::string{"Received signal: Abort trap: 6 (signum: 6)"})); -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) REQUIRE(quill::testing::file_contains(file_contents_b, std::string{"Received signal: Abort trap (signum: 6)"})); #else REQUIRE(quill::testing::file_contains(file_contents_b, std::string{"Received signal: Aborted (signum: 6)"})); diff --git a/test/integration_tests/SignalHandlerTest.cpp b/test/integration_tests/SignalHandlerTest.cpp index 952ca6d3..622074b8 100644 --- a/test/integration_tests/SignalHandlerTest.cpp +++ b/test/integration_tests/SignalHandlerTest.cpp @@ -117,7 +117,7 @@ TEST_CASE("signal_handler") REQUIRE(quill::testing::file_contains(file_contents, std::string{"Received signal: 22 (signum: 22)"})); #elif defined(__apple_build_version__) REQUIRE(quill::testing::file_contains(file_contents, std::string{"Received signal: Abort trap: 6 (signum: 6)"})); -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) REQUIRE(quill::testing::file_contains(file_contents, std::string{"Received signal: Abort trap (signum: 6)"})); #else REQUIRE(quill::testing::file_contains(file_contents, std::string{"Received signal: Aborted (signum: 6)"})); From d895778e5a922c75c69db5412ad11db9659bed46 Mon Sep 17 00:00:00 2001 From: odygrd Date: Thu, 27 Feb 2025 12:39:48 +0000 Subject: [PATCH 29/37] Fix builds --- .github/workflows/bsd.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index c34cd303..354edc14 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -63,7 +63,6 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure OpenBSD: runs-on: ubuntu-latest @@ -87,7 +86,6 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure DragonFlyBSD: runs-on: ubuntu-latest @@ -111,4 +109,3 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=$(which gcc10) -DCMAKE_CXX_COMPILER=$(which g++10) -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure From 51cb618b377233622569164b02ddfa5950b859e6 Mon Sep 17 00:00:00 2001 From: odygrd Date: Thu, 27 Feb 2025 13:27:10 +0000 Subject: [PATCH 30/37] Fix builds --- .github/workflows/bsd.yml | 4 +++- include/quill/backend/RdtscClock.h | 34 ++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 354edc14..6490369b 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -63,6 +63,7 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure OpenBSD: runs-on: ubuntu-latest @@ -86,6 +87,7 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure DragonFlyBSD: runs-on: ubuntu-latest @@ -100,7 +102,6 @@ jobs: uses: vmactions/dragonflybsd-vm@v1 with: release: '6.4.0' - arch: 'x86_64' mem: 16384 cpu: 4 usesh: true @@ -109,3 +110,4 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=$(which gcc10) -DCMAKE_CXX_COMPILER=$(which g++10) -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure diff --git a/include/quill/backend/RdtscClock.h b/include/quill/backend/RdtscClock.h index fc8522a8..1d9e2728 100644 --- a/include/quill/backend/RdtscClock.h +++ b/include/quill/backend/RdtscClock.h @@ -97,10 +97,7 @@ class RdtscClock if (!resync(2500)) { // try to resync again with higher lag - if (!resync(10000)) - { - std::fprintf(stderr, "Failed to sync RdtscClock. Timestamps will be incorrect\n"); - } + resync(10000, true); } } @@ -154,19 +151,25 @@ class RdtscClock } /***/ - bool resync(uint32_t lag) const noexcept + bool resync(uint32_t lag, bool print_error = false) const noexcept { // Sometimes we might get an interrupt and might never resync, so we will try again up to max_attempts constexpr uint8_t max_attempts{4}; + uint64_t beg; + uint64_t end; + int64_t wall_time; + for (uint8_t attempt = 0; attempt < max_attempts; ++attempt) { - uint64_t const beg = rdtsc(); + beg = rdtsc(); + // we force convert to nanoseconds because the precision of system_clock::time-point is not portable across platforms. - int64_t const wall_time = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count(); - uint64_t const end = rdtsc(); + wall_time = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); + + end = rdtsc(); if (QUILL_LIKELY(end - beg <= lag)) { @@ -181,9 +184,18 @@ class RdtscClock } } - // we failed to return earlier and we never resynced, but we don't really want to keep retrying on each call + // we failed to return earlier, and we never re-synced, but we don't really want to keep retrying on each call // to time_since_epoch() so we do non accurate resync we will increase the resync duration to resync later _resync_interval_ticks = _resync_interval_ticks * 2; + + if (QUILL_UNLIKELY(print_error)) + { + std::fprintf(stderr, + "Failed to sync RdtscClock. Timestamps will be incorrect.\n" + "beg: %llu, end: %llu, lag: %u, diff: %llu, wall_time: %lld, ns_per_tick: %f\n", + beg, end, lag, end - beg, wall_time, _ns_per_tick); + } + return false; } From 5dc2cb3d8cd1abd3ccf6a5af994af9660ac192e1 Mon Sep 17 00:00:00 2001 From: odygrd Date: Thu, 27 Feb 2025 13:57:35 +0000 Subject: [PATCH 31/37] Revert "Fix builds" This reverts commit 51cb618b377233622569164b02ddfa5950b859e6. --- .github/workflows/bsd.yml | 4 +--- include/quill/backend/RdtscClock.h | 34 ++++++++++-------------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 6490369b..354edc14 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -63,7 +63,6 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure OpenBSD: runs-on: ubuntu-latest @@ -87,7 +86,6 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure DragonFlyBSD: runs-on: ubuntu-latest @@ -102,6 +100,7 @@ jobs: uses: vmactions/dragonflybsd-vm@v1 with: release: '6.4.0' + arch: 'x86_64' mem: 16384 cpu: 4 usesh: true @@ -110,4 +109,3 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=$(which gcc10) -DCMAKE_CXX_COMPILER=$(which g++10) -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure diff --git a/include/quill/backend/RdtscClock.h b/include/quill/backend/RdtscClock.h index 1d9e2728..fc8522a8 100644 --- a/include/quill/backend/RdtscClock.h +++ b/include/quill/backend/RdtscClock.h @@ -97,7 +97,10 @@ class RdtscClock if (!resync(2500)) { // try to resync again with higher lag - resync(10000, true); + if (!resync(10000)) + { + std::fprintf(stderr, "Failed to sync RdtscClock. Timestamps will be incorrect\n"); + } } } @@ -151,25 +154,19 @@ class RdtscClock } /***/ - bool resync(uint32_t lag, bool print_error = false) const noexcept + bool resync(uint32_t lag) const noexcept { // Sometimes we might get an interrupt and might never resync, so we will try again up to max_attempts constexpr uint8_t max_attempts{4}; - uint64_t beg; - uint64_t end; - int64_t wall_time; - for (uint8_t attempt = 0; attempt < max_attempts; ++attempt) { - beg = rdtsc(); - + uint64_t const beg = rdtsc(); // we force convert to nanoseconds because the precision of system_clock::time-point is not portable across platforms. - wall_time = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count(); - - end = rdtsc(); + int64_t const wall_time = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); + uint64_t const end = rdtsc(); if (QUILL_LIKELY(end - beg <= lag)) { @@ -184,18 +181,9 @@ class RdtscClock } } - // we failed to return earlier, and we never re-synced, but we don't really want to keep retrying on each call + // we failed to return earlier and we never resynced, but we don't really want to keep retrying on each call // to time_since_epoch() so we do non accurate resync we will increase the resync duration to resync later _resync_interval_ticks = _resync_interval_ticks * 2; - - if (QUILL_UNLIKELY(print_error)) - { - std::fprintf(stderr, - "Failed to sync RdtscClock. Timestamps will be incorrect.\n" - "beg: %llu, end: %llu, lag: %u, diff: %llu, wall_time: %lld, ns_per_tick: %f\n", - beg, end, lag, end - beg, wall_time, _ns_per_tick); - } - return false; } From f0194291568abed7682d6970b2e8b1567afb270c Mon Sep 17 00:00:00 2001 From: odygrd Date: Thu, 27 Feb 2025 13:57:57 +0000 Subject: [PATCH 32/37] Fix builds --- .github/workflows/bsd.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 354edc14..9fe74b28 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -100,7 +100,6 @@ jobs: uses: vmactions/dragonflybsd-vm@v1 with: release: '6.4.0' - arch: 'x86_64' mem: 16384 cpu: 4 usesh: true From 6c19e8210a0f7fb2ed2fbbf27cd165707bd56d3a Mon Sep 17 00:00:00 2001 From: odygrd Date: Thu, 27 Feb 2025 15:51:58 +0000 Subject: [PATCH 33/37] Fix builds --- .github/workflows/bsd.yml | 3 +++ CMakeLists.txt | 1 + include/quill/Logger.h | 5 ++--- include/quill/StopWatch.h | 14 ++++++------ include/quill/backend/BackendWorker.h | 5 ++--- include/quill/backend/RdtscClock.h | 18 ++++++---------- include/quill/core/ChronoTimeUtils.h | 31 +++++++++++++++++++++++++++ include/quill/core/Rdtsc.h | 18 ++++------------ test/unit_tests/RdtscClockTest.cpp | 2 +- 9 files changed, 57 insertions(+), 40 deletions(-) create mode 100644 include/quill/core/ChronoTimeUtils.h diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 9fe74b28..f3284333 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -63,6 +63,7 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} --output-on-failure -R TEST_MultiFrontendThreads OpenBSD: runs-on: ubuntu-latest @@ -86,6 +87,7 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} --output-on-failure -R TEST_MultiFrontendThreads DragonFlyBSD: runs-on: ubuntu-latest @@ -108,3 +110,4 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=$(which gcc10) -DCMAKE_CXX_COMPILER=$(which g++10) -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 + ctest --build-config ${{ matrix.build_type }} --output-on-failure -R TEST_MultiFrontendThreads diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b34439e..ca8dbe2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -187,6 +187,7 @@ set(HEADER_FILES include/quill/core/Attributes.h include/quill/core/BoundedSPSCQueue.h + include/quill/core/ChronoTimeUtils.h include/quill/core/Common.h include/quill/core/DynamicFormatArgStore.h include/quill/core/Codec.h diff --git a/include/quill/Logger.h b/include/quill/Logger.h index 4e045149..b744eec1 100644 --- a/include/quill/Logger.h +++ b/include/quill/Logger.h @@ -8,6 +8,7 @@ #include "quill/UserClockSource.h" #include "quill/core/Attributes.h" +#include "quill/core/ChronoTimeUtils.h" #include "quill/core/Codec.h" #include "quill/core/Common.h" #include "quill/core/FrontendOptions.h" @@ -108,9 +109,7 @@ class LoggerImpl : public detail::LoggerBase } else if (clock_source == ClockSourceType::System) { - current_timestamp = static_cast(std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count()); + current_timestamp = detail::get_timestamp_ns(); } else { diff --git a/include/quill/StopWatch.h b/include/quill/StopWatch.h index 189917cd..49b52b40 100644 --- a/include/quill/StopWatch.h +++ b/include/quill/StopWatch.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include "quill/DeferredFormatCodec.h" @@ -13,6 +14,7 @@ #include "quill/core/Attributes.h" #include "quill/core/Common.h" #include "quill/core/Rdtsc.h" +#include "quill/core/ChronoTimeUtils.h" #include "quill/bundled/fmt/format.h" #include "quill/std/Chrono.h" @@ -58,9 +60,7 @@ class StopWatch } else { - _start_tp = std::chrono::duration_cast( - std::chrono::steady_clock::now().time_since_epoch()) - .count(); + _start_tp = detail::get_timestamp_ns(); } } @@ -78,7 +78,7 @@ class StopWatch else { return std::chrono::duration(std::chrono::nanoseconds{ - std::chrono::steady_clock::now().time_since_epoch().count() - _start_tp}); + detail::get_timestamp_ns() - _start_tp}); } } @@ -97,7 +97,7 @@ class StopWatch else { return std::chrono::duration_cast(std::chrono::nanoseconds{ - std::chrono::steady_clock::now().time_since_epoch().count() - _start_tp}); + detail::get_timestamp_ns() - _start_tp}); } } @@ -112,9 +112,7 @@ class StopWatch } else { - _start_tp = std::chrono::duration_cast( - std::chrono::steady_clock::now().time_since_epoch()) - .count(); + _start_tp = detail::get_timestamp_ns(); } } diff --git a/include/quill/backend/BackendWorker.h b/include/quill/backend/BackendWorker.h index 3cb2c3f9..eff4234a 100644 --- a/include/quill/backend/BackendWorker.h +++ b/include/quill/backend/BackendWorker.h @@ -21,6 +21,7 @@ #include "quill/core/Attributes.h" #include "quill/core/BoundedSPSCQueue.h" +#include "quill/core/ChronoTimeUtils.h" #include "quill/core/Codec.h" #include "quill/core/Common.h" #include "quill/core/DynamicFormatArgStore.h" @@ -416,9 +417,7 @@ class BackendWorker QUILL_ATTRIBUTE_HOT size_t _populate_transit_events_from_frontend_queues() { uint64_t const ts_now = _options.log_timestamp_ordering_grace_period.count() - ? static_cast((std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - - _options.log_timestamp_ordering_grace_period) + ? static_cast((detail::get_timestamp() - _options.log_timestamp_ordering_grace_period) .count()) : std::numeric_limits::max(); diff --git a/include/quill/backend/RdtscClock.h b/include/quill/backend/RdtscClock.h index fc8522a8..ff380b2c 100644 --- a/include/quill/backend/RdtscClock.h +++ b/include/quill/backend/RdtscClock.h @@ -7,6 +7,7 @@ #pragma once #include "quill/core/Attributes.h" +#include "quill/core/ChronoTimeUtils.h" #include "quill/core/Common.h" #include "quill/core/Rdtsc.h" @@ -59,19 +60,16 @@ class RdtscClock for (size_t i = 0; i < trials; ++i) { - auto const beg_ts = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()); + auto const beg_ts = detail::get_timestamp(); uint64_t const beg_tsc = rdtsc(); - - std::chrono::nanoseconds elapsed_ns; uint64_t end_tsc; + std::chrono::nanoseconds elapsed_ns; + do { - auto const end_ts = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()); + auto const end_ts = detail::get_timestamp(); end_tsc = rdtsc(); - - elapsed_ns = end_ts - beg_ts; // calculates ns between two timespecs + elapsed_ns = end_ts - beg_ts; } while (elapsed_ns < spin_duration); // busy spin for 10ms rates[i] = static_cast(end_tsc - beg_tsc) / static_cast(elapsed_ns.count()); @@ -163,9 +161,7 @@ class RdtscClock { uint64_t const beg = rdtsc(); // we force convert to nanoseconds because the precision of system_clock::time-point is not portable across platforms. - int64_t const wall_time = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count(); + auto const wall_time = static_cast(detail::get_timestamp_ns()); uint64_t const end = rdtsc(); if (QUILL_LIKELY(end - beg <= lag)) diff --git a/include/quill/core/ChronoTimeUtils.h b/include/quill/core/ChronoTimeUtils.h new file mode 100644 index 00000000..3730bfd3 --- /dev/null +++ b/include/quill/core/ChronoTimeUtils.h @@ -0,0 +1,31 @@ +/** + * @page copyright + * Copyright(c) 2020-present, Odysseas Georgoudis & quill contributors. + * Distributed under the MIT License (http://opensource.org/licenses/MIT) + */ + +#pragma once + +#include "quill/core/Attributes.h" + +#include +#include + +QUILL_BEGIN_NAMESPACE + +namespace detail +{ +template +QUILL_NODISCARD QUILL_ATTRIBUTE_HOT std::chrono::nanoseconds get_timestamp() noexcept +{ + return std::chrono::duration_cast(TClock::now().time_since_epoch()); +} + +template +QUILL_NODISCARD QUILL_ATTRIBUTE_HOT uint64_t get_timestamp_ns() noexcept +{ + return static_cast(get_timestamp().count()); +} +} // namespace detail + +QUILL_END_NAMESPACE \ No newline at end of file diff --git a/include/quill/core/Rdtsc.h b/include/quill/core/Rdtsc.h index 64750df3..94618568 100644 --- a/include/quill/core/Rdtsc.h +++ b/include/quill/core/Rdtsc.h @@ -7,21 +7,11 @@ #pragma once #include "quill/core/Attributes.h" - #include -#if defined(__aarch64__) - #include - #include -#elif defined(__ARM_ARCH) - #include - #include -#elif (defined(_M_ARM) || defined(_M_ARM64)) - #include - #include -#elif (defined(__PPC64__)) +#if (defined(__ARM_ARCH) || defined(_M_ARM) || defined(_M_ARM64) || defined(__PPC64__)) + #include "quill/core/ChronoTimeUtils.h" #include - #include #else // assume x86-64 .. #if defined(_WIN32) @@ -70,13 +60,13 @@ QUILL_NODISCARD QUILL_ATTRIBUTE_HOT inline uint64_t rdtsc() noexcept #endif // soft failover - return static_cast(std::chrono::system_clock::now().time_since_epoch().count()); + return detail::get_timestamp_ns(); } #elif (defined(_M_ARM) || defined(_M_ARM64) || defined(__PPC64__)) QUILL_NODISCARD QUILL_ATTRIBUTE_HOT inline uint64_t rdtsc() noexcept { // soft failover - return static_cast(std::chrono::system_clock::now().time_since_epoch().count()); + return detail::get_timestamp_ns(); } #else /** diff --git a/test/unit_tests/RdtscClockTest.cpp b/test/unit_tests/RdtscClockTest.cpp index a07f0f8d..f1c26ba0 100644 --- a/test/unit_tests/RdtscClockTest.cpp +++ b/test/unit_tests/RdtscClockTest.cpp @@ -11,7 +11,7 @@ void check_wall_time_now(quill::detail::RdtscClock const& tsc_clock, size_t& fai { std::chrono::milliseconds constexpr offset{10}; - auto const wall_time_chrono = std::chrono::system_clock::now().time_since_epoch(); + auto const wall_time_chrono = quill::detail::get_timestamp(); auto const wall_time_tsc = std::chrono::nanoseconds{tsc_clock.time_since_epoch(quill::detail::rdtsc())}; auto const lower_bound = wall_time_chrono - offset; From e63438fe84e5359fcaac7fee02fe90549eac1e2b Mon Sep 17 00:00:00 2001 From: odygrd Date: Thu, 27 Feb 2025 16:27:35 +0000 Subject: [PATCH 34/37] Fix builds --- .github/workflows/bsd.yml | 6 +++--- README.md | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index f3284333..b3d061a4 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -63,7 +63,7 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --output-on-failure -R TEST_MultiFrontendThreads + ctest --build-config ${{ matrix.build_type }} --output-on-failure -R "^multi_frontend_threads$" OpenBSD: runs-on: ubuntu-latest @@ -87,7 +87,7 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --output-on-failure -R TEST_MultiFrontendThreads + ctest --build-config ${{ matrix.build_type }} --output-on-failure -R "^multi_frontend_threads$" DragonFlyBSD: runs-on: ubuntu-latest @@ -110,4 +110,4 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=$(which gcc10) -DCMAKE_CXX_COMPILER=$(which g++10) -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --output-on-failure -R TEST_MultiFrontendThreads + ctest --build-config ${{ matrix.build_type }} --output-on-failure -R "^multi_frontend_threads$" diff --git a/README.md b/README.md index 9c0e43e4..42ab5600 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,16 @@ From c92b917f5e8c1d90d535dadaa152dd104de48c22 Mon Sep 17 00:00:00 2001 From: odygrd Date: Thu, 27 Feb 2025 16:52:58 +0000 Subject: [PATCH 35/37] Fix builds --- README.md | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 42ab5600..f834f594 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@
+ +
logo

Quill

-

Asynchronous Low Latency C++ Logging Library

+

C++ Logging Library

@@ -41,20 +46,21 @@
-

+

๐Ÿ“š Documentation - ยท + ยท โšก Cheat Sheet - ยท + ยท ๐Ÿ› Report Bug - ยท + ยท ๐Ÿ’ก Request Feature

-
- +
Logging Demo
+--- + ## ๐Ÿงญ Table of Contents - [Introduction](#-introduction) @@ -66,10 +72,11 @@ - [Caveats](#-caveats) - [License](#-license) +--- + ## โœจ Introduction -Quill is a high-performance asynchronous logging library. It is particularly suited for performance-critical -applications where every microsecond counts. +**Quill** is a **high-performance asynchronous logging library** written in **C++**. It is designed for low-latency, performance-critical applications where every microsecond counts. - **Performance-Focused**: Quill consistently outperforms many popular logging libraries. - **Feature-Rich**: Packed with advanced features to meet diverse logging needs. @@ -79,6 +86,8 @@ applications where every microsecond counts. Try it on [Compiler Explorer](https://godbolt.org/z/szncr8c8d) +--- + ## โฉ Quick Start Getting started is easy and straightforward. Follow these steps to integrate the library into your project: @@ -121,6 +130,8 @@ int main() } ``` +--- + ## ๐ŸŽฏ Features - **High-Performance**: Ultra-low latency performance. View [Benchmarks](http://github.com/odygrd/quill#performance) @@ -150,6 +161,8 @@ int main() - **Clean Codebase**: Maintained to high standards, warning-free even at strict levels. - **Type-Safe API**: Built on [{fmt}](http://github.com/fmtlib/fmt) library. +--- + ## ๐Ÿš€ Performance ### System Configuration @@ -377,6 +390,8 @@ If Quill were not available, MS BinLog would be a strong alternative. It deliver generates smaller binary log files. However, the binary logs necessitate offline processing with additional tools, which can be less convenient. +--- + ## ๐Ÿงฉ Usage Also, see the [Quick Start Guide](https://quillcpp.readthedocs.io/en/latest/quick_start.html) for a brief introduction. @@ -566,6 +581,8 @@ For manual setup, add Quill to your `BUILD.bazel` file like this: cc_binary(name = "app", srcs = ["main.cpp"], deps = ["//quill_path:quill"]) ``` +--- + ## ๐Ÿ“ Design ### Frontend (caller-thread) @@ -591,6 +608,8 @@ Subsequently, forwards the log message to all Sinks associated with the Logger. ![design.jpg](docs%2Fdesign.jpg) +--- + ## ๐Ÿšจ Caveats Quill may not work well with `fork()` since it spawns a background thread and `fork()` doesn't work well with @@ -641,6 +660,8 @@ int main() } ``` +--- + ## ๐Ÿ“ License Quill is licensed under the [MIT License](http://opensource.org/licenses/MIT) From d72c792daf2a2e6e0b1db546afcd94027e1a72c1 Mon Sep 17 00:00:00 2001 From: odygrd Date: Thu, 27 Feb 2025 16:57:04 +0000 Subject: [PATCH 36/37] Fix builds --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f834f594..aaf2f28e 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,9 @@ -->
- logo + Quill C++ Logging Library

Quill

Asynchronous Low Latency C++ Logging Library

-

C++ Logging Library

From 9ce1c40fbba9ca0cc261dc6df15a6f538af3efc9 Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 27 Feb 2025 17:31:32 +0000 Subject: [PATCH 37/37] Update bsd.yml --- .github/workflows/bsd.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index b3d061a4..8b1027fa 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - build_type: [ Debug, Release ] + build_type: [ Release ] steps: - name: Checkout code uses: actions/checkout@v4 @@ -39,13 +39,13 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=17 -DQUILL_VERBOSE_MAKEFILE=ON -DQUILL_BUILD_TESTS=ON -DQUILL_BUILD_EXAMPLES=ON "$GITHUB_WORKSPACE" cmake --build . --config ${{ matrix.build_type }} --parallel 4 - ctest --build-config ${{ matrix.build_type }} --parallel 2 --output-on-failure + ctest --build-config ${{ matrix.build_type }} --output-on-failure -R "^multi_frontend_threads$" NetBSD: runs-on: ubuntu-latest strategy: matrix: - build_type: [ Debug, Release ] + build_type: [ Release ] steps: - name: Checkout code uses: actions/checkout@v4 @@ -69,7 +69,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - build_type: [ Debug, Release ] + build_type: [ Release ] steps: - name: Checkout code uses: actions/checkout@v4 @@ -93,7 +93,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - build_type: [ Debug, Release ] + build_type: [ Release ] steps: - name: Checkout code uses: actions/checkout@v4