Crate std 1.0.0-beta-7
The SafeC standard library
Modules
- alloc
- allocator — SafeC Standard Library — allocation traits shared by every allocator.
- bump — SafeC Standard Library — Bump Allocator O(1) alloc, O(1) reset. No individual free — reset reclaims all. Conforms to ArenaAllocator (allocator.h), and to Allocator with a no-op dealloc: typed allocation is alloc_t / alloc_array_t there.
- pool — SafeC Standard Library — Pool Allocator Variable-size first-fit allocator with coalescing on free. Each allocation is preceded by a PoolBlock header. Conforms to Allocator and ArenaAllocator (allocator.h): typed allocation is alloc_t / alloc_array_t / dealloc_t there.
- slab — SafeC Standard Library — Slab Allocator Fixed-size object pool. O(1) alloc/free via embedded free-list. Conforms to Allocator and ArenaAllocator (allocator.h): typed allocation is alloc_t / dealloc_t there.
- tlsf — SafeC Standard Library — TLSF (Two-Level Segregated Fit) Allocator O(1) real-time allocator with bounded fragmentation. Uses a two-level bitmap index for fast size-class lookup. Conforms to Allocator and ArenaAllocator (allocator.h): typed allocation is alloc_t / alloc_array_t / dealloc_t there.
- assert — SafeC Standard Library — Runtime assertions (C89–C23)
SafeC has compile-time
static_assertas a built-in keyword. This module provides runtime assertion with file/line diagnostics. - async
- async — SafeC Standard Library — async: everything that runs on any target
- channel — SafeC Standard Library — async: channels (oneshot, bounded MPMC)
- combinator — SafeC Standard Library — async: combinators (join, select, timeout, map, and_then)
- coro — SafeC Standard Library — async: stackless coroutines with goto
- executor — SafeC Standard Library — async: tasks, JoinHandle, the local executor
- future — SafeC Standard Library — async: futures, Poll, Waker, Context
- host — SafeC Standard Library — async: hosted parking and block_on
- net — SafeC Standard Library — async: I/O driver, Runtime, async TCP
- pool — SafeC Standard Library — async: ThreadPool, the multi-threaded executor
- sync — SafeC Standard Library — async: Mutex, Semaphore, Notify, cancellation
- timer — SafeC Standard Library — async: timers (Sleep, Interval, a timer queue)
- atomic — SafeC Standard Library — Atomics (C11 <stdatomic.h>) Lock-free operations on shared integers and pointers. All functions require unsafe{} at the call site only when storing results in raw pointers; the operations themselves are memory-safe.
- audio
- audio — SafeC Standard Library — real-time audio I/O (in the spirit of RtAudio).
- audio_backend — SafeC Standard Library — audio: the interface between audio.sc and the per-API backends (audio_<api>[_<os>].sc). std-private.
- audio_convert — SafeC Standard Library — audio sample-format and layout conversion.
- audio_error — SafeC Standard Library — audio & MIDI: the error value both APIs return.
- audio_sys — SafeC Standard Library — audio & MIDI: the OS services the backends share.
- jack_lib — SafeC Standard Library — audio & MIDI: libjack, loaded at run time.
- midi — SafeC Standard Library — real-time MIDI I/O (in the spirit of RtMidi).
- midi_backend — SafeC Standard Library — MIDI: the interface between midi.sc and the per-API backends (midi_<api>[_<os>].sc). std-private.
- s24 — SafeC Standard Library — S24: one packed 24-bit audio sample.
- bit — SafeC Standard Library — Bit manipulation (C23 <stdbit.h> + compiler builtins) All functions are const-eligible (pure, no side effects).
- cmp — SafeC Standard Library — compile-time orderings
- collections
- bst — SafeC Standard Library — BST<K,V> (unbalanced binary search tree)
- btree — SafeC Standard Library — BTree<V>: B-tree ordered map, unsigned long keys
- list — SafeC Standard Library — List<T> (doubly linked list)
- map — SafeC Standard Library — HashMap<K,V> / StrMap<V> (open addressing, linear probing)
- node_pool — SafeC Standard Library — NodePool<N>: per-container node allocator
- queue — SafeC Standard Library — Queue<T> (FIFO, circular buffer)
- ringbuffer — SafeC Standard Library — Lock-Free Ring Buffer (real-time audio / DSP safe) Single-producer / single-consumer; power-of-two capacity; no dynamic allocation. Uses atomic load/store for head and tail to guarantee correct ordering. Freestanding-safe.
- slice — SafeC Standard Library — Slice<T>: a bounds-checked view of T elements
- stack — SafeC Standard Library — Stack<T> (LIFO)
- static_vec — SafeC Standard Library — StaticVec<T> / StaticMap<V>: zero-heap collections
- string — SafeC Standard Library — String (mutable, heap-allocated) A growable UTF-8 byte string with rich manipulation methods.
- traits — SafeC Standard Library — container capabilities as traits.
- vec — SafeC Standard Library — Vec<T> (dynamic array)
- complex — SafeC Standard Library — Complex Numbers (C99 <complex.h>) Represented as two-element float/double arrays: [real, imag]. All functions use the naming convention: cXXX_f (float), cXXX_d (double).
- convert — SafeC Standard Library — Type conversions (C11/C17 string ↔ number) All parse functions set *ok = 1 on success, 0 on failure (NULL ok is safe).
- crypto
- aes — SafeC Standard Library — AES Block Cipher AES-128 and AES-256 in ECB, CBC and GCM modes. Pure software; no SIMD. Freestanding-safe.
- asn1 — SafeC Standard Library — a minimal DER (ASN.1) reader for std's crypto.
- bignum — SafeC Standard Library — fixed-width modular arithmetic (Montgomery form).
- buf — SafeC Standard Library — std/crypto's slice-to-reference helpers. Internal: included by std/crypto's headers (std-private; not API).
- chacha20 — SafeC Standard Library — ChaCha20, Poly1305 and the ChaCha20-Poly1305 AEAD (RFC 8439).
- crypto — SafeC Standard Library — Cryptography Master Header
- ct — SafeC Standard Library — constant-time helpers for cryptographic code.
- digest — SafeC Standard Library — hash algorithms chosen at run time.
- ec — SafeC Standard Library — elliptic curves P-256 and P-384 (FIPS 186-4): ECDH key agreement and ECDSA signatures.
- hash — SafeC Standard Library — hash function traits.
- hkdf — SafeC Standard Library — HKDF (RFC 5869) over any hash.
- hmac — SafeC Standard Library — HMAC (RFC 2104) over any hash.
- rng — SafeC Standard Library — Cryptographic RNG A ChaCha20 keystream generator, seeded from the OS's random source (BCryptGenRandom on Windows, getentropy on macOS, getrandom on Linux), else rdrand (x86-64) or /dev/urandom, or from a caller-supplied 32-byte seed. Freestanding-safe with RngCtx::init_seed() or rdrand. Usage: struct RngCtx rng; rng.init(); rng.fill(buf, n);
- rsa — SafeC Standard Library — RSA signatures (RFC 8017).
- secure_alloc — SafeC Standard Library — Secure Allocator Zeroes memory on free to prevent heap inspection / data remanence. Uses a slab allocator so object sizes are fixed — no fragmentation metadata can leak size information. Conforms to Allocator (std/alloc/allocator.h): typed allocation is alloc_t / dealloc_t there, and the zeroing on dealloc applies to them too.
- sha1 — SafeC Standard Library — SHA-1 Hash (FIPS 180-4) Freestanding-safe. No dynamic allocation.
- sha256 — SafeC Standard Library — SHA-256 / SHA-224 Hash Freestanding-safe. No dynamic allocation. Sha256Ctx conforms to hash.h's Hasher and BlockHash (generic hashing, Hmac).
- sha512 — SafeC Standard Library — SHA-512 / SHA-384 Hash (FIPS 180-4) Freestanding-safe. No dynamic allocation. Sha512Ctx conforms to hash.h's Hasher and BlockHash (generic hashing, Hmac).
- tls — SafeC Standard Library — TLS 1.3 Record Layer Implements the TLS 1.3 record protocol (RFC 8446 §5). Crypto operations are delegated to std/crypto/aes.h and std/crypto/sha256.h. This module handles record framing, the inner content type and alerts. There is no handshake here: keys come from install_keys(). For complete TLS connections (handshake, certificates, every TLS 1.3 cipher suite, the OS's TLS library when there is one) use std/tls/tls.h.
- x25519 — SafeC Standard Library — X25519 Diffie-Hellman (RFC 7748).
- x509 — SafeC Standard Library — X.509 Certificate Parsing (DER format, read-only) Parses the minimum fields needed for TLS: subject, issuer, validity, public key, SAN. Freestanding-safe; no dynamic allocation.
- ctype — SafeC Standard Library — Character classification and conversion (C89–C23) Functions are locale-aware (delegate to the current C locale). SafeC idiomatic names: char_is_(c) and char_to_(c).
- debug
- coverage — SafeC Standard Library — Basic Code Coverage Tracker Instruments execution counts for up to COV_MAX_SITES sites. Designed for test/fuzz integration; not a compiler plugin. Freestanding-safe.
- debug — SafeC Debug & Profiling — Master Header Include this file to pull in all debug module declarations.
- jtag — SafeC Standard Library — Hardware Debug Helpers (JTAG / SWD / Semihosting) Provides software breakpoint, semihosting output, and OpenOCD-compatible trace via ITM (Cortex-M) or T-trace stubs. Freestanding-safe.
- perf — SafeC Standard Library — Performance Counters Hardware performance counter access (x86-64 RDTSC, AArch64 PMCCNTR, RISC-V cycle). Freestanding-safe.
- dir — SafeC Standard Library — Directories and file system entries (hosted)
- dma — SafeC Standard Library — DMA-Safe Memory Abstractions Provides cache-coherent buffer management for DMA transfers. Freestanding-safe; works with any allocator or static storage.
- dsp
- audio_buffer — SafeC Standard Library — Lock-Free Audio Ring Buffer Stereo (or multi-channel) interleaved Q8.24 samples; SPSC safe. Specialized version of RingBuffer for DSP use — operates in frames. Freestanding-safe.
- biquad — SafeC Standard Library — Biquad (2nd-order IIR section) + design tools
- comb — SafeC Standard Library — Comb filters + Karplus-Strong string synthesis
- complex_dsp — SafeC Standard Library — DSP Complex Numbers
- conv_core — SafeC Standard Library — convolution core, written once for both precisions.
- convolution — SafeC Standard Library — Convolution
- cqt — SafeC Standard Library — Constant-Q Transform
- cwt — SafeC Standard Library — Continuous Wavelet Transform (Morlet wavelet)
- dct — SafeC Standard Library — Discrete Cosine Transform (DCT-II / DCT-III)
- dft — SafeC Standard Library — Discrete Fourier Transform (direct, O(n^2))
- dsp — SafeC Standard Library — DSP array primitives (Q8.24 fixed-point)
- dsp_all — SafeC DSP & Real-Time Utilities — Master Header Include this file to pull in all DSP module declarations.
- fft — SafeC Standard Library — Fast Fourier Transform (radix-2 Cooley-Tukey)
- fft_core — SafeC Standard Library — FFT core, written once for both precisions.
- fft_cuda — SafeC Standard Library — FFT on NVIDIA GPUs (cuFFT).
- fft_rocm — SafeC Standard Library — FFT on AMD GPUs (hipFFT / rocFFT).
- filter — SafeC Standard Library — General FIR / IIR Filters
- fixed — SafeC Standard Library — DSP / Fixed-Point Arithmetic (Q8.24) Q8.24: 8 integer bits, 24 fractional bits, stored as a 32-bit signed int. Matches 24-bit audio sample depth for sub-sample precision.
- imaging — SafeC Standard Library — 2D DSP (imaging)
- imaging_core — SafeC Standard Library — imaging core, written once for both precisions.
- minphase — SafeC Standard Library — Minimum-phase reconstruction (real cepstrum method)
- resample — SafeC Standard Library — Resampling (upsampling / downsampling)
- resample_core — SafeC Standard Library — resampling core, written once for both sample types.
- sample_filter — SafeC Standard Library — streaming DSP as composable traits.
- stft — SafeC Standard Library — Short-Time Fourier Transform + Multi-Resolution STFT loss
- timer_wheel — SafeC Standard Library — Timer Wheel Scheduler Efficient O(1) timer management using a hashed timing wheel.
- window — SafeC Standard Library — Window Functions
- ztransform — SafeC Standard Library — General N-th order Laplace-to-Z (bilinear) transform + Z-domain frequency response evaluator
- encoding
- ascii — SafeC Standard Library — ASCII validation and case conversion
- base64 — SafeC Standard Library — Base64 (RFC 4648, standard alphabet + '=' padding)
- deflate — SafeC Standard Library — DEFLATE compression (RFC 1951) with the zlib (RFC 1950) and gzip (RFC 1952) containers, plus the CRC-32 and Adler-32 checksums they use.
- encoding — SafeC Standard Library — Encoding Master Header ASCII validation/case conversion, UTF-8 encode/decode, URLs (percent encoding, form encoding, the Url type), Base64, and DEFLATE/zlib/gzip. Include std/encoding/*.sc for implementations (each header pairs 1:1 with a same-named .sc, same convention as the rest of std/ — see std/serial/json.h's top comment).
- url — SafeC Standard Library — URLs: percent-encoding (RFC 3986), the application/x-www-form-urlencoded format (query strings and HTML form bodies, as the WHATWG URL standard's URLSearchParams defines it), and a structured URL type with parsing, serialization and relative-reference resolution (RFC 3986 §5).
- utf8 — SafeC Standard Library — UTF-8 encode/decode
- erased — SafeC Standard Library — Erased: the referent of a type-erased reference.
- errno — SafeC Standard Library — errno (C11 <errno.h>) Access the thread-local errno value and error descriptions.
- errno_compat — SafeC Standard Library — internal errno-accessor compatibility shim.
- fenv — SafeC Standard Library — Floating-point environment (C99 <fenv.h>) Read and set floating-point exception flags and rounding mode.
- float — SafeC Standard Library — Floating-point limit constants (C89/C99/C11/C17/C23) All values assume IEEE 754 binary32 (float) and binary64 (double).
- fmt — SafeC Standard Library — String formatting Safe snprintf-based builders that write into caller-supplied buffers.
- fs
- block — SafeC Standard Library — Block Device Abstraction Freestanding-safe virtual block device interface.
- ext — SafeC Standard Library — ext2 Read-Only Filesystem Driver Implements read-only access to ext2 (and compatible ext3/ext4) volumes. Freestanding-safe.
- fat — SafeC Standard Library — FAT32 Read-Only Driver Freestanding-safe. Uses a BlockDevice for sector reads.
- fs — SafeC Standard Library — Filesystem Master Header Freestanding-safe filesystem stack: BlockDevice, MBR partitions, VFS, FAT32, tmpfs.
- partition — SafeC Standard Library — MBR Partition Table Parser Freestanding-safe.
- tmpfs — SafeC Standard Library — tmpfs (in-memory filesystem) Fixed inode table; no dynamic allocation (backed by static arrays). Freestanding-safe.
- vfs — SafeC Standard Library — Virtual Filesystem (VFS) Layer Minimal inode-based VFS with driver registration. Freestanding-safe.
- gui
- gui — SafeC Standard Library — GUI: cross-platform windows + software framebuffer.
- gui_app — SafeC Standard Library — GUI: the application object.
- gui_backend — SafeC Standard Library — GUI: the windowing-backend interface.
- gui_canvas — SafeC Standard Library — GUI: the anti-aliased 2D vector canvas.
- gui_draw — SafeC Standard Library — GUI: software rasterizer.
- gui_fb — SafeC Standard Library — GUI: bare-metal framebuffer backend (gui_fb.sc).
- gui_font — SafeC Standard Library — GUI: loadable/serializable bitmap fonts.
- gui_gpu — SafeC Standard Library — GUI: GPU-accelerated presentation.
- gui_headless — SafeC Standard Library — GUI: the headless backend.
- gui_path — SafeC Standard Library — GUI: 2D geometry for the vector canvas.
- gui_png — SafeC Standard Library — GUI: PNG image loading.
- gui_svg — SafeC Standard Library — GUI: minimal SVG rendering.
- gui_text — SafeC Standard Library — GUI: TrueType/OpenType fonts and text layout.
- gui_utf8 — SafeC Standard Library — GUI: UTF-8 helpers shared by the window layer, the text engine and the widgets (and usable on their own).
- gui_wayland — SafeC Standard Library — GUI: the Wayland backend (Linux).
- gui_web — SafeC Standard Library — GUI: the WebAssembly <canvas> backend.
- gui_widget — SafeC Standard Library — GUI: the retained-mode widget toolkit.
- gui_widget_internal — SafeC Standard Library — GUI: the widget toolkit's internal interface between its implementation files (gui_widget*.sc). Not API: include gui_widget.h instead. Declared in a header (rather than per file) so the files agree on one set of signatures; every function here is defined in one of the widget sources, which gui_widget.h links.
- hal
- aarch64 — SafeC Standard Library — AArch64 HAL (GIC, Generic Timer, System Registers) Freestanding-safe. Targets ARMv8-A (Cortex-A53/A57/A72/A55/A76).
- cortex_m — SafeC Standard Library — Cortex-M HAL (NVIC, SysTick, SCB) Freestanding-safe. Register addresses follow the ARM-v7M/v8-M memory map.
- gpio — SafeC Standard Library — GPIO HAL Memory-mapped GPIO pin abstraction. Freestanding-safe.
- i2c — SafeC Standard Library — I2C HAL Polling-based I2C master driver. Freestanding-safe.
- reg
- riscv — SafeC Standard Library — RISC-V HAL (CLINT, PLIC, CSRs) Freestanding-safe. Addresses follow the SiFive FE310 / standard RISC-V MMIO map.
- spi — SafeC Standard Library — SPI HAL Polling-based SPI master driver. Freestanding-safe.
- timer — SafeC Standard Library — Timer HAL Hardware timer control. Freestanding-safe.
- uart — SafeC Standard Library — UART HAL Polling-based UART serial driver. Freestanding-safe.
- watchdog — SafeC Standard Library — Watchdog Timer HAL Hardware watchdog feed/enable. Freestanding-safe.
- heap — SafeC Standard Library — Global Freestanding Heap Unified heap interface backed by:
- http
- cookie — SafeC Standard Library — HTTP cookies (RFC 6265).
- cors — SafeC Standard Library — CORS (Cross-Origin Resource Sharing) helpers.
- date — SafeC Standard Library — HTTP dates (RFC 9110 §5.6.7).
- headers — SafeC Standard Library — HttpHeaders: a structured, ordered, case-insensitive HTTP header map.
- http — SafeC Standard Library — HTTP/1.1 client and server (hosted, POSIX sockets), built on std::tcp_connect_nb/tcp_listen_nb/tcp_accept_nb (see std/sched/io_nb.h) for the portable BSD/Linux/Windows socket setup, then flipped back to blocking mode here for simple synchronous request/ response semantics — this is not the same non-blocking-reactor model std/sched/reactor.h pairs those functions with.
- jwt — SafeC Standard Library — JWT (JSON Web Tokens), HS256.
- multipart — SafeC Standard Library — multipart/form-data (RFC 7578): parsing an HTML form upload on the server, building one for a client request.
- oauth2 — SafeC Standard Library — OAuth2 client (authorization-code + refresh grants, RFC 6749).
- route — SafeC Standard Library — URL path patterns (the matching half of std/http/router.h, usable on its own: no sockets, so a wasm32 client can route on location.pathname with the same patterns the server uses).
- router — SafeC Standard Library — HTTP routing and middleware.
- sse — SafeC Standard Library — Server-Sent Events (the WHATWG text/event-stream format, what the browser's EventSource reads).
- static_files — SafeC Standard Library — static file serving for std/http servers.
- websocket — SafeC Standard Library — WebSocket (RFC 6455), client + server.
- interrupt
- bitfield — SafeC Standard Library — Bitfield Helpers Pure functions for register bit manipulation. Freestanding-safe.
- clock — SafeC Standard Library — System Clock Configuration PLL and clock source management. Freestanding-safe.
- isr — SafeC Standard Library — ISR Vector Table Interrupt service routine registration and dispatch. Freestanding-safe.
- mmio — SafeC Standard Library — MMIO Helpers Memory-mapped I/O read/write primitives. Freestanding-safe.
- vector_table — SafeC Standard Library — Vector Table Management Provides a software-managed vector table for Cortex-M, RISC-V, and AArch64. Link section placement is controlled by the linker script; this header provides the C/SafeC interface to populate and activate the table. Freestanding-safe.
- inttypes — SafeC Standard Library — Fixed-width integer format specifiers (C99/C11/C17/C23) Use these macros with printf/scanf and the io_printf/io_scan family.
- io — SafeC Standard Library — I/O declarations (C11/C17/C23 stdio coverage)
- io_buf — SafeC Standard Library — buffered streams over any Reader / Writer.
- io_file — SafeC Standard Library — File I/O (C11 <stdio.h> wrappers) Handles are '&File' references to an opaque type (the C FILE underneath is never exposed); File::open returns '?&File', null on failure. Operations are methods on the handle: f.read(buf), f.write(buf) (byte slices), f.seek(off, whence), f.close(), ... File conforms to io_traits.h's SeekableStream (Reader, Writer, Seekable) and Flusher, so read_exact, write_all, copy_stream, stream_size and io_buf.h's BufReader / BufWriter work on it.
- io_traits — SafeC Standard Library — byte-stream traits.
- ipc
- kernel
- frame — SafeC Standard Library — Physical Frame Allocator Bitmap-based physical memory frame allocator. Freestanding-safe.
- ipc — SafeC Standard Library — IPC Mailbox Mailbox-based message passing between processes. Freestanding-safe.
- mmu — SafeC Standard Library — MMU Context (real hardware page tables) Virtual-to-physical address translation for freestanding targets. Freestanding-safe; TLB/activate operations use inline asm inside unsafe{}.
- paging — SafeC Standard Library — Page Table Management Virtual memory page table entries and mapping. Freestanding-safe.
- process — SafeC Standard Library — Process Control Block Minimal PCB for kernel-level process management. Freestanding-safe.
- scheduler — SafeC Standard Library — Priority Round-Robin Scheduler Manages an array of PCBs and selects the next process to run. Freestanding-safe.
- syscall — SafeC Standard Library — Syscall Table Syscall registration and dispatch. Freestanding-safe.
- limits — SafeC Standard Library — Integer limit constants (C89/C99/C11/C17/C23) Implementation assumes LP64 (64-bit POSIX) or LLP64 (Windows 64-bit).
- locale — SafeC Standard Library — Locale (C11 <locale.h>)
- log — SafeC Standard Library — Configurable Logging Zero-overhead when LOG_LEVEL = 0.
- math — SafeC Standard Library — Math declarations Naming convention:
- mem — SafeC Standard Library — Memory declarations
- ml
- activations — SafeC Standard Library — Activation functions on Tensor.
- attention — SafeC Standard Library — Attention (scaled dot-product + multi-head).
- attention_advanced — SafeC Standard Library — Advanced attention: Multi-head Latent Attention (MLA/EG-MLA), Shifted-Window (Swin) attention, and Gated DeltaNet.
- autoencoder — SafeC Standard Library — autoencoders: plain, denoising, sparse, variational (VAE, beta-VAE, conditional VAE) and vector-quantized (VQ-VAE). MLP encoders and decoders over flattened rows, trained with Autograd::get -- or convolutional ones (ConvAutoencoder, ConvVae) built from convnet.h's ConvNet.
- cnn — SafeC Standard Library — CNN: 2D convolution + pooling over flat CHW feature maps.
- convnet — SafeC Standard Library — trainable convolutional networks on std::ml's Autograd::get core.
- cuda_ffi — Internal: included by the CUDA backend sources (gpu_cuda.sc, gpu_cuda_attention.sc, gpu_cudnn.sc, device_cuda.sc, dsp/fft_cuda.sc), not a public header. The CUDA driver API, NVRTC and cuBLAS / cuBLASLt declarations they share, and the opaque handle types of those libraries and cuDNN for their 'extern' declarations: each C handle (CUcontext, CUevent, cublasHandle_t, ...) is a pointer to its own marker struct here, so one kind of handle can't be passed where another is expected. None is ever constructed or read; only the libraries they come from look behind them.
- datasets — SafeC Standard Library — datasets and mini-batch loading for std::ml.
- device — SafeC Standard Library — devices: where a tensor's values live.
- device_kernels — Generated by gen_device_kernels.sh from device_kernels.cu -- do not edit.
- device_kernels_spirv — Generated by gen_device_kernels.sh from device_kernels.cu (slangc 2026.20) -- do not edit. Every kernel as a SPIR-V module, validated by spirv-val, per build: 0 plain, 1 DK_TAGGED, 2 DK_ATTN64, 3 DK_TAGGED and DK_ATTN64.
- device_kernels_wgsl — Generated by gen_device_kernels_wgsl.sh from device_kernels.wgsl -- do not edit.
- device_webgpu — SafeC Standard Library — the WebGPU device backend's interface (device_webgpu.sc): the static backend interface device.h describes, plus the few calls gpu_webgpu.h's host-array API makes on the same device, queue and kernels. Programs reach the backend through device.h (the webgpu feature, DEVICE_WEBGPU); this header is for gpu_webgpu.sc.
- diffusion — SafeC Standard Library — Diffusion: noise schedules (EDM/Karras, DDPM linear) and samplers (DDPM ancestral, DDIM, DPM-Solver, DPM-Solver++).
- element — SafeC Standard Library — tensor element types.
- float16
- gan — SafeC Standard Library — generative adversarial networks.
- gpu_cuda
- gpu_cuda_attention — SafeC Standard Library — attention on NVIDIA GPUs (CUDA): flash attention and linear attention as this library's own CUDA kernels.
- gpu_cudnn — SafeC Standard Library — cuDNN convolution, pooling and U-Net on CUDA.
- gpu_miopen — SafeC Standard Library — MIOpen convolution, pooling and U-Net on ROCm.
- gpu_mps
- gpu_mps_metallib — Generated by gen_mps_metallib.sh from gpu_mps_kernels.metal — do not edit directly. Regenerate after changing the kernel source.
- gpu_rocm
- gpu_spirv
- gpu_webgpu
- llm — SafeC Standard Library — LLM orchestration (LangChain/LangGraph/ LangSmith-inspired).
- lora — SafeC Standard Library — parameter-efficient fine-tuning: LoRA and QLoRA.
- module — SafeC Standard Library — models as composable traits.
- mps_ffi — Internal: included by the Metal backend sources (gpu_mps.sc, device_mps.sc), not a public header. The opaque types of the Objective-C runtime and libdispatch they call Metal through besides gpu_mps.h's MtlObject (Objective-C's 'id': every MTLDevice, MTLBuffer, encoder, NSString, ...): a selector, an autorelease pool token. None is ever constructed or read; only the runtime looks behind them. Each objc_msgSend call site casts objc_msgSend to the typed signature of the message it sends.
- nn — SafeC Standard Library — trainable networks on std::ml's Autograd::get core.
- norm — SafeC Standard Library — trainable normalization: LayerNorm and AdaLN.
- rl — SafeC Standard Library — reinforcement learning.
- rnn — SafeC Standard Library — Recurrent cells: RNN, GRU, LSTM, xLSTM.
- rocm_ffi — Internal: included by the ROCm backend sources (gpu_rocm.sc, device_rocm.sc, gpu_miopen.sc, dsp/fft_rocm.sc), not a public header. The HIP runtime, hiprtc and rocBLAS declarations they share, and the opaque handle types of those libraries and MIOpen / hipFFT for their 'extern' declarations: each C handle (hipModule_t, rocblas_handle, ...) is a pointer to its own marker struct here, so one kind of handle can't be passed where another is expected. None is ever constructed or read; only the libraries they come from look behind them.
- sparse — SafeC Standard Library — sparse tensors (CSR) with autograd and devices.
- ssm — SafeC Standard Library — state space models (Mamba's selective SSM).
- tensor — SafeC Standard Library — Tensor: CPU tensors with reverse-mode Autograd::get.
- tensor_auto — SafeC Standard Library — size-based automatic backend selection for Tensor ops on the CPU (mixing SIMD/vDSP/BLAS, chosen FOR the caller instead of BY the caller; GPU placement is device.h's job).
- tensor_blas — SafeC Standard Library — BLAS-accelerated Tensor matmul.
- tensor_half — SafeC Standard Library — fp16 / bf16 tensors and mixed-precision ops.
- tensor_nn — SafeC Standard Library — neural-net building blocks on top of std::ml's Tensor/Autograd::get core (tensor.h/tensor.sc): activation functions, the Adam optimizer, and 1D pooling. Separate file from tensor.sc for the same reason the GPU backends are separate — an independently useful slice of functionality, not a change to the core type or its existing ops.
- tensor_spirv — SafeC Standard Library — GPU-backed Tensor ops (Vulkan/SPIR-V (cross-vendor)).
- tensor_vdsp — SafeC Standard Library — vDSP-accelerated elementwise Tensor ops (see tensor_vdsp.sc). Same Autograd::get math/backward wiring as tensor.h's plain tensor_add/sub/mul/sum (reuses __add_backward/__sub_backward/ __mul_backward/__sum_backward directly — only the forward computation changes), just vectorized via Accelerate's vDSP instead of a scalar loop. Link with '-framework Accelerate', same as tensor_blas.sc.
- trainer — SafeC Standard Library — the training loop.
- transformer — SafeC Standard Library — Transformer image-generation backbones: DiT (Diffusion Transformer, Peebles & Xie 2023) and JiT ("Just-image- Transformer" — a plain, unconditioned-per-layer transformer backbone, as opposed to DiT's per-layer adaptive conditioning).
- unet — SafeC Standard Library — U-Net: a small encoder/decoder CNN with skip connections (Ronneberger et al. 2015), the convolutional backbone classic DDPM-style diffusion models denoise with.
- webgpu_api — SafeC Standard Library — the part of the WebGPU C API (webgpu.h, as wgpu-native and Dawn ship it) that device_webgpu.sc and gpu_webgpu.sc call, declared for SafeC. Layouts follow webgpu.h's current revision (the one with WGPUStringView labels, callback-info structs and WGPUFuture returns: wgpu-native v24 on, Dawn from 2024 on); tests/stdlib/webgpu checks them against the real header with a C compiler (layout_check.c).
- net
- arp — SafeC Standard Library — ARP (Address Resolution Protocol) Freestanding-safe; uses a fixed-size table.
- dhcp — SafeC Standard Library — DHCP Client (Discover/Offer/Request/Ack) Freestanding-safe; implements the 4-step DORA handshake.
- dns — SafeC Standard Library — DNS (minimal stub resolver) Builds a DNS A-record query packet; parses the first A-record from the reply. Freestanding-safe.
- ethernet — SafeC Standard Library — Ethernet Layer Parse and build Ethernet II frames. Freestanding-safe.
- ipv4 — SafeC Standard Library — IPv4 Layer Parse, build, and checksum IPv4 headers. Freestanding-safe.
- ipv6 — SafeC Standard Library — IPv6 Layer Parse and build IPv6 headers. Freestanding-safe.
- net — SafeC Standard Library — Networking Master Header Freestanding-safe network stack: Ethernet, ARP, IPv4, UDP, TCP, DNS, DHCP.
- net_core — SafeC Standard Library — Network Core Packet buffer and network interface abstraction. Freestanding-safe.
- tcp — SafeC Standard Library — TCP Layer (minimal state machine) Freestanding-safe. No dynamic allocation — caller supplies fixed buffers.
- udp — SafeC Standard Library — UDP Layer Freestanding-safe.
- ownership — SafeC Standard Library — ownership helpers
- panic — SafeC Standard Library — Optional Panic System Opt-in; does nothing unless panic_set_handler is called. In freestanding mode defaults to infinite loop; hosted mode calls abort().
- path — SafeC Standard Library — Path strings
- prelude — SafeC Standard Library — Prelude Include this single file to pull in all standard module declarations.
- reactive
- signal — SafeC Standard Library — Signal<T>: fine-grained reactive state.
- result — SafeC Standard Library — Result<T,E>: a value or an error, stored inline
- rpc
- sched
- scx
- scx — SafeC Standard Library — scx runtime support
- serial
- csv — SafeC Standard Library — CSV serialization (RFC 4180), built on std/serial/value.h the same way json.h/xml.h/html.h are.
- html — SafeC Standard Library — HTML serialization (built on std/serial/value.h)
- json — SafeC Standard Library — JSON serialization (built on std/serial/value.h)
- markdown — SafeC Standard Library — Markdown.
- protobuf — SafeC Standard Library — Protocol Buffers wire format (proto3 binary encoding, https://protobuf.dev/programming-guides/encoding/).
- serial — SafeC Standard Library — Serialization Master Header A format-agnostic Value tree (value.h) plus JSON/XML/HTML backends built on it — see value.h's top comment for how to make a struct serializable.
- value — SafeC Standard Library — Serializer core: a generic, format-agnostic value tree (Null/Bool/Int/Float/String/Array/Object).
- xml — SafeC Standard Library — XML serialization (built on std/serial/value.h)
- yaml — SafeC Standard Library — YAML serialization (block style subset), built on std/serial/value.h the same way json.h/csv.h/xml.h/html.h are.
- signal — SafeC Standard Library — Signal (C11 <signal.h>) Install signal handlers and send signals.
- simd
- aarch64 — SafeC Standard Library — std::simd, AArch64 convenience layer
- cortex_m — SafeC Standard Library — std::simd, ARM Cortex-M convenience layer
- cpu — SafeC Standard Library — which SIMD instruction sets the CPU runs.
- cuda — SafeC Standard Library — std::simd, CUDA (NVPTX) convenience layer
- gemm — SafeC Standard Library — single-precision matrix multiply on the CPU.
- riscv — SafeC Standard Library — std::simd, RISC-V convenience layer
- rocm — SafeC Standard Library — std::simd, ROCm (AMDGPU/GCN) convenience layer
- simd — SafeC Standard Library — std::simd (portable core)
- spirv — SafeC Standard Library — std::simd, SPIR-V convenience layer
- vmath
- wasm — SafeC Standard Library — std::simd, WebAssembly convenience layer
- x86_64 — SafeC Standard Library — std::simd, x86_64 convenience layer
- stdbool — SafeC Standard Library — Boolean type (C99/C11/C17) Defines bool, true, and false. SafeC uses int-sized booleans.
- stdckdint — SafeC Standard Library — Checked integer arithmetic (C23 <stdckdint.h>) Each function performs op(a, b), stores the wrapped result in *result, and returns 1 if the mathematical result overflowed, 0 otherwise. This is the SafeC equivalent of C23's type-generic ckd_add/ckd_sub/ckd_mul.
- stddef — SafeC Standard Library — Standard type definitions (C99/C11/C17/C23) Fundamental types, NULL, offsetof, max_align_t.
- stderr_compat — SafeC Standard Library — internal stderr-handle compatibility shim.
- stdint — SafeC Standard Library — Fixed-width integer types (C99/C11/C17/C23) Provides exact-width, minimum-width, and fastest integer type aliases.
- str — SafeC Standard Library — String and memory declarations (C11/C17/C23 coverage)
- sync
- channel — SafeC Standard Library — Chan<T>: typed channel over the channel built-ins
- lockfree — SafeC Standard Library — LFQueue<T>: lock-free SPSC ring buffer queue
- mpsc — SafeC Standard Library — MPSC (Multi-Producer / Single-Consumer) Ring Buffer
- parallel — SafeC Standard Library — data-parallel loops on a persistent thread pool.
- spinlock — SafeC Standard Library — Spinlock Atomic test-and-set spinlock with platform-specific pause hints.
- task — SafeC Standard Library — Cooperative Task Scheduler Stackless cooperative multitasking. Tasks yield voluntarily via resume_point.
- thread_bare — SafeC Standard Library — Freestanding Cooperative Threads Priority-aware wrapper over TaskScheduler. Freestanding-safe.
- sys — SafeC Standard Library — System declarations (C11/C17/C23 stdlib coverage)
- test
- bench — SafeC Standard Library — Benchmark Framework Measures wall-clock time (via clock()) for repeated function calls. Freestanding note: clock() requires hosted libc; in freestanding mode timing is skipped and only iteration counts are reported.
- fuzz — SafeC Standard Library — Fuzz Harness Lightweight structure-aware in-process fuzzer. Mutates a seed corpus and feeds inputs to a target function. Not coverage-guided; use with libFuzzer for production fuzzing.
- test — SafeC Standard Library — Unit Testing Framework Freestanding-safe (uses only io.h for output).
- thread — SafeC Standard Library — Thread Cross-platform: POSIX pthreads (Linux/macOS) or Win32 (Windows). Backend is selected automatically from '_WIN32', which safec auto-defines for a Windows host/target (see main.cpp's platform-detection block) — same convention as std/stderr_compat.h.
- time — SafeC Standard Library — Time (comprehensive C11 <time.h>) Complements sys.h (which covers high-resolution clocks).
- tls
- tls — SafeC Standard Library — TLS: encrypted, authenticated streams over a connected socket (client and server), on the operating system's TLS implementation when there is one and SafeC's own otherwise.
- tls_backend — SafeC Standard Library — TLS: the interface between tls.sc and its backends (std-internal).
- tls_safec — SafeC Standard Library — TLS: SafeC's own TLS 1.3 implementation (std-internal: the engine behind TLS_IMPL_SAFEC, and the certificate path validation it shares with nothing else).
- traits — SafeC Standard Library — capability traits shared across modules.
- wasm