Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/nornir

crates/mimir-ingest/src/boundary/gen/gen_x86_64.py

# Generate the x86_64 syscall table (Rust) from the kernel's syscall_64.tbl plus the
# UAPI unistd_64.h for numbers past the tbl. Usage: gen_x86_64.py TBL UNISTD > out.rs
import re, sys
tbl, uapi = sys.argv[1], sys.argv[2]
rows = {}
for line in open(tbl):
    line = line.split('#', 1)[0].strip()
    if not line:
        continue
    f = line.split()
    nr, abi, name = int(f[0]), f[1], f[2]
    entry = f[3] if len(f) > 3 else ''
    if abi == 'x32':
        continue
    rows[nr] = (name, entry, 'tbl')
for line in open(uapi):
    m = re.match(r'#define __NR_(\w+) (\d+)', line)
    if not m:
        continue
    name, nr = m.group(1), int(m.group(2))
    if nr in rows:
        assert rows[nr][0] == name, (nr, rows[nr], name)
    else:
        rows[nr] = (name, 'sys_' + name, 'uapi')
print('// @generated by scripts/gen_x86_64.py — do not edit by hand.')
print('// Numbers 0..=462 and their entry points: linux-6.12.104 arch/x86/entry/syscalls/syscall_64.tbl')
print('// (common + 64 ABI; SPDX GPL-2.0 WITH Linux-syscall-note). Numbers past it: the UAPI')
print('// <asm/unistd_64.h> of linux-libc-dev 7.0.0-38, entry point `sys_<name>` (marked `uapi`).')
print('use super::Syscall;')
print('')
print('pub const X86_64: &[Syscall] = &[')
for nr in sorted(rows):
    name, entry, src = rows[nr]
    print(f'    Syscall {{ nr: {nr}, name: "{name}", entry: "{entry}", from_uapi: {"true" if src == "uapi" else "false"} }},')
print('];')