AK24 (Application Kernel 24) is a C library that provides data structures, memory management primitives, and utilities for building applications. The kernel (K) is the foundation, offering containers, lambda abstractions, context management, and optional Boehm GC integration. All components are tested at compile-time. The library can be embedded as a base layer in larger systems.
The AK24 kernel currently targets nix (Unix-like) systems. Windows support is planned and actively targeted; several compatibility hurdles are in progress. The final major hurdle is the modules subsystem, which is POSIX-only right now. This work is backburnered until the broader system stabilizes.
The kernel core already routes all thread functions correctly. Once the kernel supports Windows, AK24 applications will be able to run on Windows without changes.
The kernel is the core of AK24. It provides memory management abstractions, garbage collection integration, initialization/shutdown, and thread creation utilities. Supports both GC and non-GC builds with optional memory tracking for debugging.
| Module | Description |
|---|---|
| arbuff | Lock-free atomic ring buffer for concurrent MPMC queue operations |
| atoms | Thread-safe N-dimensional data structures with atomic value updates |
| buffer | Dynamic byte array with automatic growth and file I/O |
| context | Hierarchical scoped key-value store with parent-child relationships |
| forms | Structural type system for compiler construction |
| lambda | Closure-like structure for function pointers with captured context |
| list | Generic dynamic array with type-safe macros |
| log | Thread-safe logging system with multiple outputs and severity levels |
| map | Generic hash table with type-safe macros and multiple key types |
| scanner | Lexical scanner for parsing basic types from buffers |
Build the library:
makeInstall the library:
make installRun tests:
./ak24.sh testRun complete CI test suite (all configurations):
./ak24.sh ciBuild with GC disabled:
AK24_GC=OFF makeAfter installation, link against AK24 using one of these methods:
Using pkg-config:
gcc myprogram.c $(pkg-config --cflags --libs ak24) -o myprogramUsing ak24-config:
gcc myprogram.c $(ak24-config --cflags --libs) -o myprogramManual linking:
gcc myprogram.c -I$AK24_HOME/include/ak24 -L$AK24_HOME/lib -lak24_kernel -lpthread -lssl -lcrypto -o myprogramThe static library bundles TCC and Boehm GC internally, so you only need to link system libraries (pthread, OpenSSL). For shared library builds, all dependencies are embedded.
Generate API documentation with Doxygen:
make docsView the generated documentation at docs/api/html/index.html. The Doxygen documentation is the source of truth and will be the most up to date reference for the API.
Thread-safe lock-free MPMC circular buffer for void* pointers. Uses sequence-based algorithm with C11 atomics for safe concurrent access. Capacity is automatically rounded to next power of 2. Returns errors when full rather than overwriting data.
Documentation: kernel/arbuff/docs/arbuff.md
Thread-safe atomically mutable building blocks for N-dimensional data structures. Atoms store typed primitive values and can bond with multiple neighbors to form 1D chains, 2D grids, 3D cubes, or N-D lattices. Uses C11 atomics for lock-free concurrent value updates.
Documentation: kernel/atoms/docs/atoms.md
Dynamic byte array for storing uint8_t data. Automatically resizes when capacity is exceeded (doubles capacity). Minimum capacity of 16 bytes. Supports rotation, trimming, splitting, sub-buffer operations, and file loading.
Documentation: kernel/buffer/docs/buffer.md
Hierarchical scoped key-value store with parent-child relationships. Supports variable shadowing where child values override parent values. Can hoist values to parent scope on pop. Uses map for storage and list for hoist queue.
Documentation: kernel/context/docs/context.md
Structural type system infrastructure for compiler construction. Provides structural types (data layout without nominal identity), affordances (operations available on types), affects (method definitions with composition), and pattern matching for structural compatibility checking.
Documentation: kernel/forms/docs/forms.md
Closure-like structure for storing function pointers with captured context. Supports optional context cleanup function and cloning (shallow copy). Context can be replaced or retrieved at runtime.
Documentation: kernel/lambda/docs/lambda.md
Generic dynamic array with type-safe macros. Automatically resizes when capacity is exceeded (doubles capacity). Initial capacity of 8 items. Supports push, pop, insert, remove, rotation, and iterator pattern. Items are heap-allocated copies.
Documentation: kernel/list/docs/list.md
Thread-safe logging system with six severity levels (TRACE to FATAL). Supports multiple simultaneous output targets, custom callbacks, file output, and optional color output for terminals. Thread safety requires user-provided lock function. Based on rxi's log.c library.
Documentation: See kernel/log/include/log.h
Generic hash table with type-safe macros. Supports multiple key types (string, int, float, etc) with custom hash and comparison functions. Automatic resizing doubles buckets when load factor exceeds 1.0. Uses chaining for collision resolution.
Documentation: kernel/map/docs/map.md
Lexical scanner for parsing integers, reals, and symbols from byte buffers. State-machine-based with configurable stop symbols and whitespace handling. Supports delimited group extraction with escape sequences. Non-owning buffer references for zero-copy parsing with position tracking.
Documentation: See kernel/scanner/include/scanner.h
For developers looking to contribute to or extend AK24, please refer to the following documentation:
- docs/kernel.md - Kernel initialization, memory management, threading abstractions, and application framework
- docs/platform.md - Platform abstraction layer architecture showing how AK24 maps to POSIX/Windows implementations
- docs/testing.md - Testing strategy for GC, ASAN, and manual memory configurations