# Path: src/python/bcc/libbcc.py
# _RAW_CB_TYPE = ct.CFUNCTYPE(None, ct.py_object, ct.c_void_p, ct.c_int)
# _LOST_CB_TYPE = ct.CFUNCTYPE(None, ct.py_object, ct.c_ulonglong)
# _RINGBUF_CB_TYPE = ct.CFUNCTYPE(ct.c_int, ct.c_void_p, ct.c_void_p, ct.c_int)
# _SYM_CB_TYPE = ct.CFUNCTYPE(ct.c_int, ct.c_char_p, ct.c_ulonglong)
#     NONE = 0x0
#     CONSTANT = 0x1
#     DEREF_OFFSET = 0x2
#     DEREF_IDENT = 0x4
#     BASE_REGISTER_NAME = 0x8
#     INDEX_REGISTER_NAME = 0x10
#     SCALE = 0x20
# _USDT_CB = ct.CFUNCTYPE(None, ct.POINTER(bcc_usdt))
# _USDT_PROBE_CB = ct.CFUNCTYPE(None, ct.c_char_p, ct.c_char_p,
#                               ct.c_ulonglong, ct.c_int)
# class bcc_perf_buffer_opts(ct.Structure):
# class bcc_symbol(ct.Structure):
# class bcc_ip_offset_union(ct.Union):
# class bcc_stacktrace_build_id(ct.Structure):
# class bcc_symbol_option(ct.Structure):
# class bcc_usdt(ct.Structure):
# class bcc_usdt_location(ct.Structure):
# class BCC_USDT_ARGUMENT_FLAGS(object):
# class bcc_usdt_argument(ct.Structure):


    from collections.abc import MutableMapping
    from collections import MutableMapping
from time import strftime
from functools import reduce
from .libbcc import lib, _RAW_CB_TYPE, _LOST_CB_TYPE, _RINGBUF_CB_TYPE, bcc_perf_buffer_opts
from .utils import get_online_cpus
from .utils import get_possible_cpus
import ctypes as ct
import os
import errno
import re
import sys
        """
        if self._event_class == None:
            self._event_class = _get_event_class(self)
        return ct.cast(data, ct.POINTER(self._event_class)).contents

    def open_ring_buffer(self, callback, ctx=None):
        """open_ring_buffer(callback)

        Opens a ring buffer to receive custom event data from the bpf program.
        The callback will be invoked for each event submitted from the kernel,
        up to millions per second.
        """

        def ringbuf_cb_(ctx, data, size):
            try:
                ret = callback(ctx, data, size)
                # Callback for ringbufs should _always_ return an integer.
                # If the function the user registers does not,
                # simply fall back to returning 0.
                try:
                    ret = int(ret)
                except:
                    ret = 0
            except IOError as e:
                if e.errno == errno.EPIPE:
                    exit()
                else:
                    raise e
            return ret


# Path: src/python/bcc/libbcc.py
# _RAW_CB_TYPE = ct.CFUNCTYPE(None, ct.py_object, ct.c_void_p, ct.c_int)
# _LOST_CB_TYPE = ct.CFUNCTYPE(None, ct.py_object, ct.c_ulonglong)
# _RINGBUF_CB_TYPE = ct.CFUNCTYPE(ct.c_int, ct.c_void_p, ct.c_void_p, ct.c_int)
# _SYM_CB_TYPE = ct.CFUNCTYPE(ct.c_int, ct.c_char_p, ct.c_ulonglong)
#     NONE = 0x0
#     CONSTANT = 0x1
#     DEREF_OFFSET = 0x2
#     DEREF_IDENT = 0x4
#     BASE_REGISTER_NAME = 0x8
#     INDEX_REGISTER_NAME = 0x10
#     SCALE = 0x20
# _USDT_CB = ct.CFUNCTYPE(None, ct.POINTER(bcc_usdt))
# _USDT_PROBE_CB = ct.CFUNCTYPE(None, ct.c_char_p, ct.c_char_p,
#                               ct.c_ulonglong, ct.c_int)
# class bcc_perf_buffer_opts(ct.Structure):
# class bcc_symbol(ct.Structure):
# class bcc_ip_offset_union(ct.Union):
# class bcc_stacktrace_build_id(ct.Structure):
# class bcc_symbol_option(ct.Structure):
# class bcc_usdt(ct.Structure):
# class bcc_usdt_location(ct.Structure):
# class BCC_USDT_ARGUMENT_FLAGS(object):
# class bcc_usdt_argument(ct.Structure):


# Path: src/python/bcc/table.py
    from collections.abc import MutableMapping
    from collections import MutableMapping
from time import strftime
from functools import reduce
from .libbcc import lib, _RAW_CB_TYPE, _LOST_CB_TYPE, _RINGBUF_CB_TYPE, bcc_perf_buffer_opts
from .utils import get_online_cpus
from .utils import get_possible_cpus
import ctypes as ct
import os
import errno
import re
import sys

        """
        if self._event_class == None:
            self._event_class = _get_event_class(self)
        return ct.cast(data, ct.POINTER(self._event_class)).contents

    def open_ring_buffer(self, callback, ctx=None):
        """open_ring_buffer(callback)

        Opens a ring buffer to receive custom event data from the bpf program.
        The callback will be invoked for each event submitted from the kernel,
        up to millions per second.
        """

        def ringbuf_cb_(ctx, data, size):
            try:
                ret = callback(ctx, data, size)
                # Callback for ringbufs should _always_ return an integer.
                # If the function the user registers does not,
                # simply fall back to returning 0.
                try:
                    ret = int(ret)
                except:
                    ret = 0
            except IOError as e:
                if e.errno == errno.EPIPE:
                    exit()
                else:
                    raise e
            return ret


        fn = _RINGBUF_CB_TYPE(ringbuf_cb_)