[FEATURE] Add C poll and select adapters #16

Open
opened 2026-10-27 23:26:08 +01:00 by erikinkinen · 2 comments
Owner

Problem and motivation

C event loops need poll and select through the existing Posixd descriptor bridge.
The service already supports readiness waits; the C runtime has no adapters.

Proposed behavior and scope

Add erix_c_poll and erix_c_select to the process I/O companion, with Rust
interfaces, C/C++ declarations and native exports. Poll uses eight-byte records
(int32_t fd, uint16_t events, uint16_t revents). Select uses counted arrays
of 64-bit words and signed nfds, without a fixed fd-set ceiling. Its optional
timeout has signed 64-bit seconds and microseconds; NULL means infinite.

Preserve duplicate poll rows, negative-descriptor handling and select bits outside
nfds. Validate timeout and storage ranges before effects. Success preserves
errno; expected errors set thread-local errno and leave caller output unchanged.
Conventional aliases, ppoll/pselect and C signal-handler delivery remain separate.

Authority, security and reliability

Use the admitted original realm, shared heap and existing mediated clock and
subscriptions. Each concurrent call snapshots inputs and retains its own request,
result storage and actual native observations until positive retirement. Check
complete reply correlation before writing caller output. Preserve the first
failure and original owners on uncertain returns or cleanup; never replay a wait
or hold a global backend lock across it. Descriptor numbers and timeouts grant
no provider or clock authority.

Acceptance criteria

  • Implement the C/Rust layouts, flags, checked pointer/count arithmetic and
    finite, immediate and infinite waits.
  • Connect both adapters to the original realm with independent concurrent
    storage, correlated replies, retirement and failure-atomic output.
  • Cover duplicate/invalid descriptors, overlapping select interests, EOF,
    timeout ranges, uninitialized poll outputs, partial words, capacity/allocation
    failures and malformed or unreturned calls.
  • Add the native C workload, producer/header/export checks and guest coverage;
    retain existing workload and authority requirements.
  • Update component contracts, partial headers and the technical manual, and
    record remaining signal and compatibility-startup requirements.

Alternatives and tradeoffs

Counted sets need explicit storage geometry but avoid an arbitrary descriptor
limit. Reusing mediated readiness preserves its lifetime and timeout contracts;
provider discovery and repeated byte-I/O probes would duplicate that machinery.

Tracking and rollout

Build on the descriptor bridge,
file adapters and
service readiness.
Coordinate LibCstd, Posixd, Integration and the manual under
phase 6.

## Problem and motivation C event loops need poll and select through the existing Posixd descriptor bridge. The service already supports readiness waits; the C runtime has no adapters. ## Proposed behavior and scope Add `erix_c_poll` and `erix_c_select` to the process I/O companion, with Rust interfaces, C/C++ declarations and native exports. Poll uses eight-byte records (`int32_t fd`, `uint16_t events`, `uint16_t revents`). Select uses counted arrays of 64-bit words and signed `nfds`, without a fixed fd-set ceiling. Its optional timeout has signed 64-bit seconds and microseconds; NULL means infinite. Preserve duplicate poll rows, negative-descriptor handling and select bits outside `nfds`. Validate timeout and storage ranges before effects. Success preserves errno; expected errors set thread-local errno and leave caller output unchanged. Conventional aliases, ppoll/pselect and C signal-handler delivery remain separate. ## Authority, security and reliability Use the admitted original realm, shared heap and existing mediated clock and subscriptions. Each concurrent call snapshots inputs and retains its own request, result storage and actual native observations until positive retirement. Check complete reply correlation before writing caller output. Preserve the first failure and original owners on uncertain returns or cleanup; never replay a wait or hold a global backend lock across it. Descriptor numbers and timeouts grant no provider or clock authority. ## Acceptance criteria - [x] Implement the C/Rust layouts, flags, checked pointer/count arithmetic and finite, immediate and infinite waits. - [x] Connect both adapters to the original realm with independent concurrent storage, correlated replies, retirement and failure-atomic output. - [ ] Cover duplicate/invalid descriptors, overlapping select interests, EOF, timeout ranges, uninitialized poll outputs, partial words, capacity/allocation failures and malformed or unreturned calls. - [ ] Add the native C workload, producer/header/export checks and guest coverage; retain existing workload and authority requirements. - [x] Update component contracts, partial headers and the technical manual, and record remaining signal and compatibility-startup requirements. ## Alternatives and tradeoffs Counted sets need explicit storage geometry but avoid an arbitrary descriptor limit. Reusing mediated readiness preserves its lifetime and timeout contracts; provider discovery and repeated byte-I/O probes would duplicate that machinery. ## Tracking and rollout Build on [the descriptor bridge](https://git.erikinkinen.fi/erix/lib-cstd/issues/13), [file adapters](https://git.erikinkinen.fi/erix/lib-cstd/issues/14) and [service readiness](https://git.erikinkinen.fi/erix/posixd/issues/33). Coordinate LibCstd, Posixd, Integration and the manual under [phase 6](https://git.erikinkinen.fi/erix/integration/issues/65).
Author
Owner

The namespaced erix_c_poll and erix_c_select interfaces are implemented in LibCstd and connected to the original realm in Posixd. Counted LP64 storage, per-call input snapshots and positive retirement keep ordinary errors from changing caller outputs.

The manual documents these contracts. Test and native-workload acceptance remain open, alongside conventional aliases and C signal-handler delivery.

The namespaced `erix_c_poll` and `erix_c_select` interfaces are implemented in [LibCstd](https://git.erikinkinen.fi/erix/lib-cstd/commit/5ee02280128f6ba583a5f378866d3861ab48214b) and connected to the original realm in [Posixd](https://git.erikinkinen.fi/erix/posixd/commit/e048a034c4b335551f7f3d3b81a11d44375e0422). Counted LP64 storage, per-call input snapshots and positive retirement keep ordinary errors from changing caller outputs. The [manual](https://git.erikinkinen.fi/erix/docs/commit/7c6a32b52a6e5e4af8e427075130764339dfe82c) documents these contracts. Test and native-workload acceptance remain open, alongside conventional aliases and C signal-handler delivery.
Author
Owner

The six regenerated API references now include the C file, pipe and readiness interfaces. Generation and an independent second conversion completed while the original producers retained their sources and JSON outputs.

The native command owner also retains failed status publication on its original invocation and handles cancellation after completed retirement. The C runtime and documentation builds now select these fixes through the coordinated consumers. Guest C execution and the complete build inside EriX remain outstanding.

The six [regenerated API references](https://git.erikinkinen.fi/erix/docs/commit/91374fb0a139cee1d4f346ce2d25fd08eae8e8f3) now include the C file, pipe and readiness interfaces. Generation and an independent second conversion completed while the original producers retained their sources and JSON outputs. The [native command owner](https://git.erikinkinen.fi/erix/integration/commit/7bf80c35d2b5a950d6525418a7e0487bffad95ba) also retains failed status publication on its original invocation and handles cancellation after completed retirement. The C runtime and documentation builds now select these fixes through the [coordinated consumers](https://git.erikinkinen.fi/erix/integration/commit/fbe198a23ea9adc65df0ca01042daadfc4f84422). Guest C execution and the complete build inside EriX remain outstanding.
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:34:40 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
erix/lib-cstd#16
No description provided.