nx_uleb.nx
buildroot/runtime/nx_uleb.nx
about
nx_uleb.nx -- LEB128 (unsigned + signed) encoders + decoders.
LEB128 (Little Endian Base 128) is a variable-length integer
encoding used by DWARF, WebAssembly, Android dex, the MQTT
protocol, and many others. Each byte carries 7 bits of payload
plus a continuation bit (high bit) indicating "more bytes follow".
Encoding rules:
uleb128:
- Take the low 7 bits, OR with 0x80 if more bits remain.
- Shift right by 7, repeat until value is 0.
sleb128:
- Same, but stop when the remaining value is 0 AND the sign
bit of the last 7-bit chunk is 0 (or value is -1 and the
sign bit is 1).
Today nx_dwarf_line.nx, nx_dwarf_loc.nx, and nx_dwarf_aranges.nx
each have their own copies of these. This module is the single
source of truth. As the off-C runtime grows new LEB128 consumers
(WebAssembly support, dex parsing, BPF), they import here.
dependencies 2 imports · 0 importers
imports: syscalls.nxnx_loop.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 33 | func nx_uleb_enc_u(dst: *u8, off: i64, cap: i64, v: i64) -> i64 |
| 55 | func nx_uleb_enc_s(dst: *u8, off: i64, cap: i64, v: i64) -> i64 |
| 88 | func nx_uleb_dec_u(src: *u8, off: i64, cap: i64, out_val: *i64) -> i64 |
| 111 | func nx_uleb_dec_s(src: *u8, off: i64, cap: i64, out_val: *i64) -> i64 |
| 140 | func main() -> i64 |