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_aarch64.py

# Generate the aarch64 syscall table (Rust) from the kernel's generic scripts/syscall.tbl
# (the ABIs arm64 builds: common, 64 and arch/arm64/kernel/Makefile.syscalls'
# `syscall_abis_64`) plus the UAPI asm-generic/unistd.h for numbers past the tbl.
# Usage: gen_aarch64.py TBL UNISTD > aarch64.rs
import re, sys
tbl, uapi = sys.argv[1], sys.argv[2]
ABIS = {'common', '64', 'renameat', 'rlimit', 'memfd_secret'}
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 not in ABIS:
        continue
    assert nr not in rows, (nr, rows[nr], name)
    rows[nr] = (name, entry, 'tbl')
last = max(rows)
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 <= last or name == "syscalls":
        continue
    rows[nr] = (name, 'sys_' + name, 'uapi')
print('// @generated by scripts/gen_aarch64.py — do not edit by hand.')
print(f'// Numbers 0..={last} and their entry points: linux-6.12.104 scripts/syscall.tbl, the ABIs arm64')
print('// builds (common, 64, renameat, rlimit, memfd_secret: arch/arm64/kernel/Makefile.syscalls;')
print('// SPDX GPL-2.0 WITH Linux-syscall-note). Numbers past it: the UAPI <asm-generic/unistd.h>')
print('// of linux-libc-dev 7.0.0-38, entry point `sys_<name>` (marked `uapi`).')
print('use super::Syscall;')
print('')
print('pub const AARCH64: &[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('];')