mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Add ringbuf type hinting.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
from .maps import HashMap, PerfEventArray
|
||||
from .maps import HashMap, PerfEventArray, RingBuf
|
||||
from .maps_pass import maps_proc
|
||||
|
||||
__all__ = ["HashMap", "PerfEventArray", "maps_proc"]
|
||||
__all__ = ["HashMap", "PerfEventArray", "maps_proc", "RingBuf"]
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# This file provides type and function hints only and does not actually give any functionality.
|
||||
class HashMap:
|
||||
def __init__(self, key, value, max_entries):
|
||||
self.key = key
|
||||
@ -33,3 +34,18 @@ class PerfEventArray:
|
||||
|
||||
def output(self, data):
|
||||
pass # Placeholder for output method
|
||||
|
||||
|
||||
class RingBuf:
|
||||
def __init__(self, max_entries):
|
||||
self.max_entries = max_entries
|
||||
|
||||
def reserve(self, size: int, flags=0):
|
||||
if size > self.max_entries:
|
||||
raise ValueError("size cannot be greater than set maximum entries")
|
||||
return 0
|
||||
|
||||
def submit(self, data, flags=0):
|
||||
pass
|
||||
|
||||
# add discard, output and also give names to flags and stuff
|
||||
|
||||
@ -51,7 +51,7 @@ def create_bpf_map(module, map_name, map_params):
|
||||
|
||||
|
||||
def create_map_debug_info(module, map_global, map_name, map_params):
|
||||
"""Generate debug information metadata for BPF map"""
|
||||
"""Generate debug information metadata for BPF maps HASH and PERF_EVENT_ARRAY"""
|
||||
generator = DebugInfoGenerator(module)
|
||||
|
||||
uint_type = generator.get_uint32_type()
|
||||
|
||||
Reference in New Issue
Block a user