Skip to content

cpu/native,core: better contain ugly hacks#21955

Merged
maribu merged 2 commits intoRIOT-OS:masterfrom
maribu:core/drop-native_sched
Dec 15, 2025
Merged

cpu/native,core: better contain ugly hacks#21955
maribu merged 2 commits intoRIOT-OS:masterfrom
maribu:core/drop-native_sched

Conversation

@maribu
Copy link
Copy Markdown
Member

@maribu maribu commented Dec 14, 2025

Contribution description

RIOT's sched.h sadly has the same name as POSIX's sched.h. The file core/include/native_sched.h provided the workarounds needed - but we do not want CPU specific hacks in core.

Instead:

  1. Add a sched_yield() compat function to core/sched and document that code in RIOT should be using thread_yield() instead
    • this is needed for glibcxx and the ESP32 SDK, which include sched.h and expect the POSIX sched.h API
  2. Add a sched.h in native that injects some glibc specific workarounds and an #include_next "sched.h"
    • this fixes issues with other glibc functions that expect cpu_set_t being provided by sched.h (and which glibc's sched.h would actually do, but RIOT's sched.h does not).
    • the actual define is just a dummy, but apparently good enough

Testing procedure

If that code had any function, Murdock will find it. (Even if the function would only show at runtime, we actually run the tests on native in any CI run.)

Issues/PRs references

None

@maribu maribu requested a review from kaspar030 as a code owner December 14, 2025 17:47
@github-actions github-actions bot added the Area: core Area: RIOT kernel. Handle PRs marked with this with care! label Dec 14, 2025
@maribu maribu added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 14, 2025
@riot-ci
Copy link
Copy Markdown

riot-ci commented Dec 14, 2025

Murdock results

✔️ PASSED

646c8b4 cpu/native: move native hack from core here

Success Failures Total Runtime
10950 0 10950 11m:53s

Artifacts

@maribu maribu requested a review from gschorcht as a code owner December 14, 2025 18:37
@github-actions github-actions bot added Platform: ESP Platform: This PR/issue effects ESP-based platforms Area: cpu Area: CPU/MCU ports labels Dec 14, 2025
@crasbe crasbe added Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: no fast fail don't abort PR build after first error labels Dec 14, 2025
@crasbe
Copy link
Copy Markdown
Contributor

crasbe commented Dec 14, 2025

Murdock will find it.

dramatic voice

...and Murdock found them.

@maribu maribu force-pushed the core/drop-native_sched branch from 79cc98a to 276452a Compare December 14, 2025 19:32
@github-actions github-actions bot removed Platform: ESP Platform: This PR/issue effects ESP-based platforms Area: cpu Area: CPU/MCU ports labels Dec 14, 2025
External code may assume that RIOT's `sched.h` header is the same as
[POSIX's sched.h][1] header. This adds a slim wrapper to not have to
patch external code (which in case of glibcxx will be difficult to do).

[1]: https://pubs.opengroup.org/onlinepubs/009604299/basedefs/sched.h.html
@maribu maribu force-pushed the core/drop-native_sched branch from 276452a to 02ea45f Compare December 14, 2025 20:02
@github-actions github-actions bot added Platform: native Platform: This PR/issue effects the native platform Area: build system Area: Build system Area: cpu Area: CPU/MCU ports labels Dec 14, 2025
@maribu maribu changed the title core: drop native_sched.h cpu/native,core: better contain ugly hacks Dec 14, 2025
Copy link
Copy Markdown
Member

@AnnsAnns AnnsAnns left a comment

Choose a reason for hiding this comment

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

Small 0 o'clock thoughts

CPU specific hacks never should go to `core`. This simplifies the hack
and moves it to `cpu/native` by providing a custom `sched.h` that adds
the workarounds for glibc and adds an `#include_next "sched.h"`.

It's a bit of a pity that RIOT's sched.h has a name conflict with
POSIX's sched.h - otherwise those hacks wouldn't really be needed.
@maribu maribu force-pushed the core/drop-native_sched branch from 02ea45f to 646c8b4 Compare December 15, 2025 07:21
Copy link
Copy Markdown
Member

@AnnsAnns AnnsAnns left a comment

Choose a reason for hiding this comment

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

Ty for the PR

@AnnsAnns AnnsAnns enabled auto-merge December 15, 2025 11:46
@AnnsAnns AnnsAnns added this pull request to the merge queue Dec 15, 2025
github-merge-queue bot pushed a commit that referenced this pull request Dec 15, 2025
cpu/native,core: better contain ugly hacks
@maribu maribu removed this pull request from the merge queue due to a manual request Dec 15, 2025
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Dec 15, 2025

This might need a 2nd ACK, depending on how strict one is with our policies

@AnnsAnns
Copy link
Copy Markdown
Member

Sure, we can make this a 2ack

@AnnsAnns AnnsAnns added the Process: needs >1 ACK Integration Process: This PR requires more than one ACK label Dec 15, 2025
@github-actions github-actions bot added the Process: missing approvals Integration Process: PR needs more ACKS (handled by action) label Dec 15, 2025
@maribu maribu requested review from benpicco and crasbe December 15, 2025 14:18
@maribu maribu removed the Process: missing approvals Integration Process: PR needs more ACKS (handled by action) label Dec 15, 2025
@maribu maribu enabled auto-merge December 15, 2025 15:05
@maribu maribu added this pull request to the merge queue Dec 15, 2025
Merged via the queue into RIOT-OS:master with commit 789c3ab Dec 15, 2025
29 of 30 checks passed
@maribu maribu deleted the core/drop-native_sched branch December 15, 2025 18:00
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Dec 15, 2025

🎉 Thx

@leandrolanzieri leandrolanzieri added this to the Release 2026.01 milestone Jan 13, 2026
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Feb 22, 2026

This had the unintended side-effect of braking libsocketcan on some hosts, e.g. on Ubuntu 24.04 LTS.

That is going to be interesting to figure out why that breaks it there, and why doesn't it break it on BUILD_IN_DOCKER=1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: cpu Area: CPU/MCU ports CI: no fast fail don't abort PR build after first error CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: native Platform: This PR/issue effects the native platform Process: needs >1 ACK Integration Process: This PR requires more than one ACK Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants