Skip to content

Add C version#16

Merged
pavel-kirienko merged 17 commits into
masterfrom
dev
Feb 6, 2026
Merged

Add C version#16
pavel-kirienko merged 17 commits into
masterfrom
dev

Conversation

@pavel-kirienko
Copy link
Copy Markdown
Member

This is needed for the ongoing work on Cy.

pavel-kirienko and others added 14 commits February 4, 2026 22:05
…ang-tidy (#14)

CI was failing on two jobs: `style_check` (clang-format rejecting C
files) and `debug` (clang-tidy treating `modernize-use-auto` as errors
in C API tests).

## Changes

**`.clang-format`**
- Removed `Language: Cpp` to enable auto-detection (supports both C and
C++ files)
- Changed `AlignEscapedNewlines: LeftWithLastLine` → `Left` (version
compatibility)

**`.clang-tidy`**
- Disabled `modernize-use-auto` and `hicpp-use-auto` checks
- These are inappropriate for C API testing where explicit types like
`olga_event_t evt = OLGA_EVENT_INIT` are intentional and clearer than
auto-deduced types

> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> -
`https://api.github.com/repos/Zubax/olga_scheduler/actions/runs/21694652909/jobs`
>   - Triggering command: `/usr/bin/curl curl -s REDACTED` (http block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/Zubax/olga_scheduler/settings/copilot/coding_agent)
(admins only)
>
> </details>

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/Zubax/olga_scheduler/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pavel-kirienko <3298404+pavel-kirienko@users.noreply.github.com>
`olga_defer()` previously required events to not be in the scheduler
tree, forcing users to explicitly cancel before rescheduling. This adds
unnecessary ceremony and complexity.

## Changes

- **Implementation**: Added `cavl2_remove_if()` call before reinserting
the event, making `olga_defer()` idempotent
- **Documentation**: Updated to reflect that events can be rescheduled
directly
- **Tests**: Added coverage for rescheduling scenarios (later time,
earlier time, multiple reschedules)

## Example

```c
olga_event_t evt = OLGA_EVENT_INIT;

// Schedule at t=100
olga_defer(&sched, 100, &ctx, handler, &evt);

// Now you can directly reschedule to t=200 without canceling first
olga_defer(&sched, 200, &ctx, handler, &evt);  // Previously undefined behavior, now supported
```

The event must be either zero-initialized (`OLGA_EVENT_INIT`) or
previously used. Backward compatible with existing code.

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/Zubax/olga_scheduler/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pavel-kirienko <3298404+pavel-kirienko@users.noreply.github.com>
Co-authored-by: Pavel Kirienko <pavel.kirienko@gmail.com>
Copilot AI review requested due to automatic review settings February 5, 2026 11:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a C API version of the OLGa (logarithmic) EDF scheduler library to complement the existing C++ implementation, as part of ongoing work on "Cy" (presumably a C-focused project or component).

Changes:

  • Adds complete C API (olga_scheduler.h) with inline implementations
  • Adds comprehensive test suite for C API with 10 test cases covering all major functionality
  • Adds C demo application showing practical usage
  • Vendors CAVL v2 library (cavl2.h) for C support alongside existing C++ CAVL library
  • Reformats codebase with new Mozilla-based clang-format style (previously LLVM-based)
  • Adds coverage reporting infrastructure for the C API
  • Updates CI/CD pipeline and documentation with C usage examples

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
include/olga_scheduler/olga_scheduler.h New C API header with inline implementations for event scheduling, cancellation, and event loop
tests/test_olga_scheduler_c.cpp Comprehensive test suite (10 tests) validating C API functionality including ordering, cancellation, rescheduling, and lateness tracking
tests/olga_scheduler_c_demo.c Practical C demo showing 1Hz event scheduling with POSIX time functions
lib/cavl/cavl2.h Vendored CAVL v2 AVL tree library for C (MIT licensed, single-header)
include/olga_scheduler/olga_scheduler.hpp Formatting-only changes to match new clang-format style
tests/test_olga_scheduler.cpp Adds test for OLGA_EVENT_INIT macro + formatting changes
CMakeLists.txt Adds C API test target, demo target, coverage reporting, and updates format file patterns
README.md Adds C and C++ usage examples, updates description to mention both APIs
.github/workflows/main.yml Adds apt update step, updates clang-format from v18 to v20
.clang-format Switches from detailed LLVM-based config to simpler Mozilla-based style
.clang-tidy Excludes modernize-use-auto and hicpp-use-auto (not applicable for C)
CHANGELOG.md Removed entirely

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pavel-kirienko pavel-kirienko merged commit c1960f8 into master Feb 6, 2026
14 checks passed
@pavel-kirienko pavel-kirienko deleted the dev branch February 6, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants