Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: libringqueue
on:
push:
tags:
- 'v*.*.*' # Triggers on version tags
branches:
- '**' # Triggers on all branches
workflow_dispatch:

jobs:
build:
name: ${{ matrix.build-name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
build-name: linux
additional-args: "['-DCMAKE_CXX_COMPILER=g++-14']"
- os: windows-2025
build-name: windows
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: '0'

- uses: lukka/get-cmake@latest

- name: Build the project
uses: lukka/run-cmake@v10
with:
configurePreset: Release
buildPreset: Release
configurePresetAdditionalArgs: ${{ matrix.additional-args }}

- name: Create Github Artifact
uses: actions/upload-artifact@v4.1.0
with:
name: libringqueue-${{ matrix.build-name }}
path: ${{ github.workspace }}/build/Release/libringqueue*

finalize:
runs-on: ubuntu-latest
needs:
- build
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: '0'

- name: Get Next Version
id: getver
uses: anothrNick/github-tag-action@v1
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref_name == 'main')
env:
GITHUB_TOKEN: ${{ github.token }}
TAG_PREFIX: v
DEFAULT_BUMP: patch

- name: Download Artifact
uses: actions/download-artifact@v4
with:
merge-multiple: true

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
if: github.event_name == 'push' && ((startsWith(github.ref, 'refs/tags') || github.ref_name == 'main'))
with:
files: |
${{ github.workspace }}/libringqueue.so
${{ github.workspace }}/libringqueue.dll

tag_name: ${{ steps.getver.outputs.new_tag }}
env:
GITHUB_TOKEN: ${{ github.token }}
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set_target_properties (ringqueue PROPERTIES
DEFINE_SYMBOL LIBRINGQUEUE_BUILD
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -pedantic-errors -Wpedantic -Wall -Werror -Wextra -Wabi -fPIC -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -pedantic-errors -Wpedantic -Wall -Werror -Wextra -fPIC -fvisibility=hidden")

target_sources(ringqueue PRIVATE
${PROJECT_SOURCE_DIR}/src/ringbuffer_interface.cpp
Expand All @@ -23,7 +23,7 @@ target_include_directories(ringqueue PUBLIC
target_link_options(ringqueue PRIVATE -shared -fPIC -fvisibility=hidden)

if (WIN32)
target_link_options(ringqueue PRIVATE -static-libgcc -static-libstdc++ LINKER:-Bstatic,--whole-archive -lwinpthread LINKER:-Bdynamic,--no-whole-archive -lonecore)
target_link_libraries(ringqueue PRIVATE -static-libgcc -static-libstdc++ LINKER:-Bstatic,--whole-archive -lwinpthread LINKER:-Bdynamic,--no-whole-archive -lonecore)
endif ()

install(TARGETS ringqueue DESTINATION .)
Expand Down
3 changes: 2 additions & 1 deletion include/ringqueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ class RingQueue {
#ifdef __linux

int fd = memfd_create(ANONYMOUS_FILENAME, MFD_CLOEXEC);
ftruncate(fd, size);
const int _ = ftruncate(fd, size);
static_cast<void>(_);

void *const shm = mmap(nullptr, size * 2zu, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0l);

Expand Down
4 changes: 2 additions & 2 deletions src/ringbuffer_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" {
try {
reinterpret_cast<RingQueue<uint8_t>*>(handle)->enqueueMany(std::span<uint8_t>(static_cast<uint8_t*>(item), size));
} catch (const std::length_error &e) {
fprintf(stderr, e.what());
fprintf(stderr, "%s\n", e.what());
return false;
}

Expand All @@ -31,7 +31,7 @@ extern "C" {
try {
return reinterpret_cast<RingQueue<uint8_t>*>(handle)->popMany(static_cast<uint8_t*>(out), size);
} catch (const std::out_of_range &e) {
fprintf(stderr, e.what());
fprintf(stderr, "%s\n", e.what());
return false;
}

Expand Down