Skip to content

feat(std): expand system modules and modernize standard library syntax#312

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
LunaStev:feat/(std)-add-`bytes`,-`io`,-`fs`,-`process`-modules-and-update-`std`-APIs-
Apr 10, 2026
Merged

feat(std): expand system modules and modernize standard library syntax#312
LunaStev merged 1 commit into
wavefnd:masterfrom
LunaStev:feat/(std)-add-`bytes`,-`io`,-`fs`,-`process`-modules-and-update-`std`-APIs-

Conversation

@LunaStev
Copy link
Copy Markdown
Member

@LunaStev LunaStev commented Apr 9, 2026

This PR significantly expands the Wave standard library by introducing several new system-level modules and a wide array of utility functions. Additionally, it performs a codebase-wide modernization of the library by transitioning from the legacy var keyword to the current let mut syntax for mutable variable declarations.

Key Changes

1. New Standard Library Modules

Added the following modules to the std manifest and established their foundational APIs:

  • std::io: Core input/output primitives.
  • std::fs: High-level file system operations.
  • std::bytes: Byte buffer and slice manipulation.
  • std::process: Process management and environment interaction.

2. Advanced Memory Management (std::mem)

  • Alignment & Paging: Added mem_is_aligned, mem_alloc_aligned, and mem_free_aligned. Introduced page-level allocation support with mem_page_size, mem_alloc_pages, and mem_free_pages.
  • Safety: Added bounds-checked memory operations: mem_copy_checked, mem_move_checked, and mem_set_checked.
  • Error Handling: Defined new memory-related error constants (MEM_ERR_INVALID, MEM_ERR_NO_SPACE) for more granular failure reporting.

3. 64-bit Bitwise & Math Utilities (std::math::bits)

  • Added a full suite of 64-bit bitwise operations: is_pow2_i64, align_down_i64, align_up_i64, popcount64, ctz64, and integer logarithm functions (ilog2_floor64, ilog2_ceil64).
  • Implemented byte-swapping functions (bswap32, bswap64) for endianness conversion.

4. System & Networking Extensions (std::sys, std::net)

  • POSIX Constants: Populated std::sys (Linux/macOS) with extensive file system constants (e.g., O_RDONLY, SEEK_SET) and polling constants (POLLIN, POLLOUT).
  • System Calls: Added wrappers for dup, dup2, pipe, fsync, fcntl, poll, and getsockopt.
  • Non-blocking I/O: Introduced non-blocking socket utilities to the std::net module, including tcp_stream_set_nonblock and udp_set_nonblock.

5. Syntax Modernization

  • Updated all standard library source files to use the latest Wave syntax. Specifically, replaced all instances of the legacy var keyword with let mut for mutable bindings. This ensures the standard library remains the gold standard for idiomatic Wave code.

Rationale

These additions provide the necessary building blocks for developing complex, high-performance systems applications in Wave. By providing native support for aligned memory, non-blocking networking, and process management, we reduce the need for developers to write manual extern(c) wrappers for common POSIX tasks.

…` APIs

This commit expands the Wave standard library by adding missing system modules (`io`, `fs`, `bytes`, `process`) to the `std` manifest and introduces multiple low-level utility functions across the library. It also updates variable declarations from `var` to `let mut` for consistency with recent language changes.

[Details]
- **`std::manifest.json` & `README.md`**: Added `io`, `fs`, `bytes`, and `process` modules.
- **`std::mem`**:
  - Replaced `var` with `let mut` across memory allocation and operation functions.
  - Added new memory alignment utilities (`mem_is_aligned`, `mem_alloc_aligned`, `mem_free_aligned`).
  - Added page size management functions (`mem_page_size`, `mem_alloc_pages`, `mem_free_pages`).
  - Added bounds-checked memory operations (`mem_copy_checked`, `mem_move_checked`, `mem_set_checked`).
  - Introduced new memory error constants (`MEM_ERR_INVALID`, `MEM_ERR_NO_SPACE`).
- **`std::math::bits`**: Added 64-bit bitwise operations: `is_pow2_i64`, `align_down_i64`, `align_up_i64`, `popcount64`, `ctz64`, `ilog2_floor64`, `ilog2_ceil64`, and byte-swapping functions (`bswap32`, `bswap64`).
- **`std::sys` (Linux & macOS)**:
  - Added extensive file system syscall constants (e.g., `FS_O_RDONLY`, `FS_SEEK_SET`) and functions (`dup`, `dup2`, `pipe`, `fsync`, `fcntl`).
  - Added socket options and poll constants (`SO_REUSEPORT`, `POLLIN`, `POLLOUT`), along with `getsockopt` and `poll` syscalls.
- **`std::net`**: Added non-blocking socket utilities (`tcp_stream_set_nonblock`, `udp_set_nonblock`, etc.).
- **`std::buffer`, `std::env`, `std::path`, `std::string`, `std::time`**: Refactored `var` to `let mut` to align with the latest Wave syntax.

Signed-off-by: LunaStev <luna@lunastev.org>
@LunaStev LunaStev merged commit 9a09319 into wavefnd:master Apr 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant