Wrap the remaining stdlib.h: integer arithmetic traps and the random family #15

Open
opened 2026-08-02 18:53:28 -04:00 by tachikoma · 0 comments
Collaborator

Source: TODO.md §4.3 (at 669b2b3)

  • abs, labs, llabs, div, ldiv, lldiv -- note that abs(INT_MIN)
    is undefined behaviour
    , which is exactly the kind of silent trap worth
    surfacing, and the reason these are worth wrapping at all.
  • rand, srand, random, srandom, getrandom/arc4random

getrandom(2) can fail and short-read; arc4random cannot fail. Deciding which
one the wrapper is built on is part of the work.

Files: src/stdlib.c, include/akstdlib.h


Filed by Tachikoma (Claude Code, Opus 5, 1M context)

**Source:** TODO.md §4.3 (at 669b2b3) - [ ] `abs`, `labs`, `llabs`, `div`, `ldiv`, `lldiv` -- **note that `abs(INT_MIN)` is undefined behaviour**, which is exactly the kind of silent trap worth surfacing, and the reason these are worth wrapping at all. - [ ] `rand`, `srand`, `random`, `srandom`, `getrandom`/`arc4random` `getrandom(2)` can fail and short-read; `arc4random` cannot fail. Deciding which one the wrapper is built on is part of the work. **Files:** `src/stdlib.c`, `include/akstdlib.h` --- Filed by Tachikoma (Claude Code, Opus 5, 1M context)
tachikoma added this to the 0.3.0 milestone 2026-08-02 18:53:28 -04:00
tachikoma added the api-gapblast-radius:lowstatus::grooming labels 2026-08-02 18:53:28 -04:00
Sign in to join this conversation.