Complete the standard memory and string family #92

Open
opened 2026-11-08 17:19:19 +01:00 by erikinkinen · 1 comment
Owner

Problem and motivation

The selected libc++ headers and locale adapter need wide memory/string operations and collation interfaces that EriX does not yet provide. LLVM and libc++ also use the POSIX error-message interface. Standard byte tokenization remains missing from the authored string header.

Proposed behavior and scope

Implement the remaining standard family together: wmemchr, wmemcmp, wmemcpy, wmemmove, wmemset; wcslen, wcscmp, wcsncmp, wcscpy, wcsncpy, wcscat, wcsncat, wcschr, wcsrchr, wcsspn, wcscspn, wcspbrk, wcsstr, wcstok; strcoll, strxfrm, wcscoll, wcsxfrm and their _l forms; strerror, POSIX int strerror_r, and strtok.

Add matching standard headers and native companions. C/POSIX and C.UTF-8 use their explicit binary collation profiles. Wide operations preserve signed 32-bit code units without imposing Unicode validation. Wide I/O, numeric conversion and the actual libc++ port remain separate work. The observed LLVM path uses the existing strtok_r; adding strtok completes the authored standard interface, rather than claiming a new upstream call.

Authority, security and reliability

Pure operations use caller-owned ranges and full-width counts, without allocation or hidden locale lookup. Returned pointers preserve source permissions and lifetimes. Collation uses the sole installed process locale and original current-thread binding; _l validates the original live locale object.

Keep the tokenizer cursor in the actual heap-owned thread registration, with a typed synchronous borrow and reentry refusal. Do not reuse conversion slots, keys, spare TCB words or a thread-pointer lookup table. Initialize it before publication and retain it through original native retirement. This requires no change to the 592-byte thread image ABI.

Reuse the immutable error catalog. strerror_r uses caller storage, returns POSIX errors directly and preserves errno. Do not export GNU semantics under the same symbol or invent a fixed error-buffer limit. Native exports retain the existing process root, runtime, source and companion lifetimes.

Acceptance criteria

  • Implement all thirty functions with documented range, overlap, termination, padding and error behavior.
  • Provide matching C/C++ headers, public/hidden native exports and original Integration producer bindings.
  • Cover signed wide comparisons, pointer provenance, guard boundaries, overlapping moves, uninitialized destinations and adversarial linear substring searches.
  • Cover real current-thread cursor isolation, changed separator sets, reentry refusal, invalid/retired locale handles and atomic buffer failures.
  • Update runtime documentation and manual contracts; pass the affected strict Rust and native companion checks.

Alternatives and tradeoffs

A process-global tokenizer cursor would break thread isolation. A thread-pointer table would create a second owner registry. The existing thread registration already supplies the required storage lifetime. Generic Unicode collation is unnecessary for the installed locale profiles; silently disabling upstream localization would hide missing port work.

Tracking and rollout

Build on #88, #89, #90 and #91. Implementation: #93. Native producer bindings: Integration #613. Manual and API contracts: Docs #93. Actual workload adoption and complete cross/guest toolchain builds remain separately required.

## Problem and motivation The selected libc++ headers and locale adapter need wide memory/string operations and collation interfaces that EriX does not yet provide. LLVM and libc++ also use the POSIX error-message interface. Standard byte tokenization remains missing from the authored string header. ## Proposed behavior and scope Implement the remaining standard family together: `wmemchr`, `wmemcmp`, `wmemcpy`, `wmemmove`, `wmemset`; `wcslen`, `wcscmp`, `wcsncmp`, `wcscpy`, `wcsncpy`, `wcscat`, `wcsncat`, `wcschr`, `wcsrchr`, `wcsspn`, `wcscspn`, `wcspbrk`, `wcsstr`, `wcstok`; `strcoll`, `strxfrm`, `wcscoll`, `wcsxfrm` and their `_l` forms; `strerror`, POSIX `int strerror_r`, and `strtok`. Add matching standard headers and native companions. C/POSIX and C.UTF-8 use their explicit binary collation profiles. Wide operations preserve signed 32-bit code units without imposing Unicode validation. Wide I/O, numeric conversion and the actual libc++ port remain separate work. The observed LLVM path uses the existing `strtok_r`; adding `strtok` completes the authored standard interface, rather than claiming a new upstream call. ## Authority, security and reliability Pure operations use caller-owned ranges and full-width counts, without allocation or hidden locale lookup. Returned pointers preserve source permissions and lifetimes. Collation uses the sole installed process locale and original current-thread binding; `_l` validates the original live locale object. Keep the tokenizer cursor in the actual heap-owned thread registration, with a typed synchronous borrow and reentry refusal. Do not reuse conversion slots, keys, spare TCB words or a thread-pointer lookup table. Initialize it before publication and retain it through original native retirement. This requires no change to the 592-byte thread image ABI. Reuse the immutable error catalog. `strerror_r` uses caller storage, returns POSIX errors directly and preserves errno. Do not export GNU semantics under the same symbol or invent a fixed error-buffer limit. Native exports retain the existing process root, runtime, source and companion lifetimes. ## Acceptance criteria - [x] Implement all thirty functions with documented range, overlap, termination, padding and error behavior. - [x] Provide matching C/C++ headers, public/hidden native exports and original Integration producer bindings. - [x] Cover signed wide comparisons, pointer provenance, guard boundaries, overlapping moves, uninitialized destinations and adversarial linear substring searches. - [x] Cover real current-thread cursor isolation, changed separator sets, reentry refusal, invalid/retired locale handles and atomic buffer failures. - [x] Update runtime documentation and manual contracts; pass the affected strict Rust and native companion checks. ## Alternatives and tradeoffs A process-global tokenizer cursor would break thread isolation. A thread-pointer table would create a second owner registry. The existing thread registration already supplies the required storage lifetime. Generic Unicode collation is unnecessary for the installed locale profiles; silently disabling upstream localization would hide missing port work. ## Tracking and rollout Build on #88, #89, #90 and #91. Implementation: #93. Native producer bindings: [Integration #613](https://git.erikinkinen.fi/erix/integration/pulls/613). Manual and API contracts: [Docs #93](https://git.erikinkinen.fi/erix/docs/pulls/93). Actual workload adoption and complete cross/guest toolchain builds remain separately required.
erikinkinen added this to the Alpha 1 milestone 2026-11-08 17:19:19 +01:00
Author
Owner

The thirty-function standard family is implemented in #93, with producer bindings in Integration #613 and the manual/API contracts in Docs #93. The native thread image stays unchanged. Workload adoption and the broader source inventory remain separate; #94 tracks the next confirmed POSIX pair.

The thirty-function standard family is implemented in #93, with producer bindings in Integration #613 and the manual/API contracts in Docs #93. The native thread image stays unchanged. Workload adoption and the broader source inventory remain separate; #94 tracks the next confirmed POSIX pair.
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#92
No description provided.