janitorial

This commit is contained in:
Pragyansh Chaturvedi
2025-09-09 00:26:06 +05:30
parent 7c15bff6c0
commit 5adc6d75e9
5 changed files with 11 additions and 4 deletions

View File

@ -1,9 +1,11 @@
import ast import ast
from llvmlite import ir from llvmlite import ir
def bpf_ktime_get_ns_emitter(call, module, builder, func): def bpf_ktime_get_ns_emitter(call, module, builder, func):
pass pass
def bpf_printk_emitter(call, module, builder, func): def bpf_printk_emitter(call, module, builder, func):
if not hasattr(func, "_fmt_counter"): if not hasattr(func, "_fmt_counter"):
func._fmt_counter = 0 func._fmt_counter = 0

View File

@ -1,6 +1,7 @@
from llvmlite import ir from llvmlite import ir
import ast import ast
def emit_license(module: ir.Module, license_str: str): def emit_license(module: ir.Module, license_str: str):
license_bytes = license_str.encode("utf8") + b"\x00" license_bytes = license_str.encode("utf8") + b"\x00"
elems = [ir.Constant(ir.IntType(8), b) for b in license_bytes] elems = [ir.Constant(ir.IntType(8), b) for b in license_bytes]
@ -17,13 +18,15 @@ def emit_license(module: ir.Module, license_str: str):
return gvar return gvar
def license_processing(tree, module): def license_processing(tree, module):
"""Process the LICENSE function decorated with @bpf and @bpfglobal and return the section name""" """Process the LICENSE function decorated with @bpf and @bpfglobal and return the section name"""
count = 0 count = 0
for node in tree.body: for node in tree.body:
if isinstance(node, ast.FunctionDef) and node.name == "LICENSE": if isinstance(node, ast.FunctionDef) and node.name == "LICENSE":
# check decorators # check decorators
decorators = [dec.id for dec in node.decorator_list if isinstance(dec, ast.Name)] decorators = [
dec.id for dec in node.decorator_list if isinstance(dec, ast.Name)]
if "bpf" in decorators and "bpfglobal" in decorators: if "bpf" in decorators and "bpfglobal" in decorators:
if count == 0: if count == 0:
count += 1 count += 1

View File

@ -1,6 +1,8 @@
from llvmlite import ir from llvmlite import ir
#TODO: THIS IS NOT SUPPOSED TO MATCH STRINGS :skull: # TODO: THIS IS NOT SUPPOSED TO MATCH STRINGS :skull:
def ctypes_to_ir(ctype: str): def ctypes_to_ir(ctype: str):
mapping = { mapping = {
"c_int8": ir.IntType(8), "c_int8": ir.IntType(8),