diff --git a/pythonbpf/bpf_helper_handler.py b/pythonbpf/bpf_helper_handler.py index 0efe5b6..7850891 100644 --- a/pythonbpf/bpf_helper_handler.py +++ b/pythonbpf/bpf_helper_handler.py @@ -1,9 +1,11 @@ import ast from llvmlite import ir + def bpf_ktime_get_ns_emitter(call, module, builder, func): pass + def bpf_printk_emitter(call, module, builder, func): if not hasattr(func, "_fmt_counter"): func._fmt_counter = 0 diff --git a/pythonbpf/globals_pass.py b/pythonbpf/globals_pass.py index 6275196..1228809 100644 --- a/pythonbpf/globals_pass.py +++ b/pythonbpf/globals_pass.py @@ -42,7 +42,7 @@ def globals_processing(tree, module: ir.Module): elif isinstance(dec, ast.Name) and dec.id == "bpfglobal": collected.append(node.name) - + elif isinstance(dec, ast.Name) and dec.id == "map": collected.append(node.name) diff --git a/pythonbpf/license_pass.py b/pythonbpf/license_pass.py index ddab38c..b7fbb11 100644 --- a/pythonbpf/license_pass.py +++ b/pythonbpf/license_pass.py @@ -1,6 +1,7 @@ from llvmlite import ir import ast + def emit_license(module: ir.Module, license_str: str): license_bytes = license_str.encode("utf8") + b"\x00" 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 + def license_processing(tree, module): """Process the LICENSE function decorated with @bpf and @bpfglobal and return the section name""" count = 0 for node in tree.body: if isinstance(node, ast.FunctionDef) and node.name == "LICENSE": # 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 count == 0: count += 1 diff --git a/pythonbpf/maps.py b/pythonbpf/maps.py index 9926826..ff7c84e 100644 --- a/pythonbpf/maps.py +++ b/pythonbpf/maps.py @@ -4,7 +4,7 @@ class HashMap: self.value_type = value_type self.max_entries = max_entries self.entries = {} - + def lookup(self, key): if key in self.entries: return self.entries[key] diff --git a/pythonbpf/type_deducer.py b/pythonbpf/type_deducer.py index 49dd224..2c30a9c 100644 --- a/pythonbpf/type_deducer.py +++ b/pythonbpf/type_deducer.py @@ -1,6 +1,8 @@ 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): mapping = { "c_int8": ir.IntType(8),