[FEATURE] Bind conventional multibyte conversion to the current locale #87

Open
opened 2026-11-08 12:26:39 +01:00 by erikinkinen · 1 comment
Owner

Problem and motivation

The existing multibyte interfaces require an explicit encoding and nonnull caller state. Conventional toolchain consumers need current-locale behavior, zero-initialized mbstate_t and function-private state when the state argument is null.

Proposed behavior and scope

Supply conventional scalar, restartable, bounded string, legacy and C11 UTF-16/UTF-32 conversion families over the existing checked conversion core. Obtain the current encoding from the bound original locale runtime. Use separate conversion cells in the original thread runtime for implicit state; retain explicit caller state and current-call consumption semantics. Publish C declarations and matching source-owned native workload inputs.

Authority, security and reliability

Depend on the original process locale binding and original live thread state. Neither a pointer, encoding label nor saved TCB address establishes ownership. Never discover host locale/TLS or substitute process-global conversion state. Preserve caller storage, errno, cursor, failure and cleanup contracts. Initialize zero states for the current encoding; reject incompatible pending-state use without silently discarding it. No host libc symbol interposition is enabled during host tests.

Acceptance criteria

  • Implement all required conventional conversion entry points and headers over the sole checked core.
  • Bind current encoding and function-private default state to the genuine process/thread runtime, including lifecycle and thread isolation.
  • Cover initial states, split sequences, null/reset/query cases, bounds, errors, errno preservation, locale changes and independent function/thread state.
  • Update native producer inputs, original C workload, inline/component/manual contracts and affected API references.
  • Run matching native and guest acceptance through the actual owners; retain unsupported upstream requirements explicitly.

Alternatives and tradeoffs

Aliases alone retain the extended signatures and cannot satisfy conventional contracts. A process-global singleton introduces interference across threads; an address-indexed table can inherit state after TCB reuse. Reuse the original per-thread state allocation instead.

Tracking and rollout

Depends on owned thread runtime state and process/thread locales. Preserve existing explicit-state interfaces and legacy native profiles while selecting the new conventional runtime explicitly.

## Problem and motivation The existing multibyte interfaces require an explicit encoding and nonnull caller state. Conventional toolchain consumers need current-locale behavior, zero-initialized mbstate_t and function-private state when the state argument is null. ## Proposed behavior and scope Supply conventional scalar, restartable, bounded string, legacy and C11 UTF-16/UTF-32 conversion families over the existing checked conversion core. Obtain the current encoding from the bound original locale runtime. Use separate conversion cells in the original thread runtime for implicit state; retain explicit caller state and current-call consumption semantics. Publish C declarations and matching source-owned native workload inputs. ## Authority, security and reliability Depend on the original process locale binding and original live thread state. Neither a pointer, encoding label nor saved TCB address establishes ownership. Never discover host locale/TLS or substitute process-global conversion state. Preserve caller storage, errno, cursor, failure and cleanup contracts. Initialize zero states for the current encoding; reject incompatible pending-state use without silently discarding it. No host libc symbol interposition is enabled during host tests. ## Acceptance criteria - [ ] Implement all required conventional conversion entry points and headers over the sole checked core. - [ ] Bind current encoding and function-private default state to the genuine process/thread runtime, including lifecycle and thread isolation. - [ ] Cover initial states, split sequences, null/reset/query cases, bounds, errors, errno preservation, locale changes and independent function/thread state. - [ ] Update native producer inputs, original C workload, inline/component/manual contracts and affected API references. - [ ] Run matching native and guest acceptance through the actual owners; retain unsupported upstream requirements explicitly. ## Alternatives and tradeoffs Aliases alone retain the extended signatures and cannot satisfy conventional contracts. A process-global singleton introduces interference across threads; an address-indexed table can inherit state after TCB reuse. Reuse the original per-thread state allocation instead. ## Tracking and rollout Depends on [owned thread runtime state](https://git.erikinkinen.fi/erix/lib-cstd/issues/85) and [process/thread locales](https://git.erikinkinen.fi/erix/lib-cstd/issues/86). Preserve existing explicit-state interfaces and legacy native profiles while selecting the new conventional runtime explicitly.
erikinkinen added this to the Alpha 1 milestone 2026-11-08 12:26:39 +01:00
Author
Owner

The upstream interface mapping now separates actual calls, conditional sanitizer paths and Rust libc declarations. The inspected GNU binding has an 8-byte mbstate_t; EriX requires its own 32-byte layout. The target libc port must preserve that distinction.

The declared LLVM recipes also request libc++ and libc++abi sources that the admitted Rust archive does not contain. Matching runtime sources, C++ link configuration and complete selected-consumer headers remain prerequisites for toolchain acceptance.

The [upstream interface mapping](https://git.erikinkinen.fi/erix/lib-cstd/src/commit/85e1e9b2982386177d5a267ac14003b633bb27ae/docs/upstream-multibyte-use.md) now separates actual calls, conditional sanitizer paths and Rust libc declarations. The inspected GNU binding has an 8-byte mbstate_t; EriX requires its own 32-byte layout. The target libc port must preserve that distinction. The declared LLVM recipes also request libc++ and libc++abi sources that the admitted Rust archive does not contain. Matching runtime sources, C++ link configuration and complete selected-consumer headers remain prerequisites for toolchain acceptance.
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#87
No description provided.