1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
use core::mem;

#[inline(always)]
pub unsafe fn map_lookup_elem(map: *mut cty::c_void, key: *const cty::c_void) -> *mut cty::c_void {
    let f: unsafe extern "C" fn(*mut cty::c_void, *const cty::c_void) -> *mut cty::c_void =
        mem::transmute(1usize);

    f(map, key)
}

#[inline(always)]
pub unsafe fn map_update_elem(
    map: *mut cty::c_void,
    key: *const cty::c_void,
    value: *const cty::c_void,
    flags: cty::uint64_t,
) -> cty::c_long {
    let f: unsafe extern "C" fn(
        *mut cty::c_void,
        *const cty::c_void,
        *const cty::c_void,
        cty::uint64_t,
    ) -> cty::c_long = mem::transmute(2usize);

    f(map, key, value, flags)
}

#[inline(always)]
pub unsafe fn map_delete_elem(map: *mut cty::c_void, key: *const cty::c_void) -> cty::c_long {
    let f: unsafe extern "C" fn(*mut cty::c_void, *const cty::c_void) -> cty::c_long =
        mem::transmute(3usize);

    f(map, key)
}

#[inline(always)]
pub unsafe fn get_current_pid_tgid() -> cty::uint64_t {
    let f: unsafe extern "C" fn() -> cty::uint64_t = mem::transmute(14usize);

    f()
}

#[inline(always)]
pub unsafe fn get_current_comm(buf: *mut cty::c_void, size_of_buf: cty::uint32_t) -> cty::c_long {
    let f: unsafe extern "C" fn(
        *mut cty::c_void,
        cty::uint32_t,
    ) -> cty::c_long = mem::transmute(16usize);

    f(buf, size_of_buf)
}

#[inline(always)]
pub unsafe fn probe_read_kernel(
    dst: *mut cty::c_void,
    size: cty::uint32_t,
    unsafe_ptr: *const cty::c_void,
) -> cty::c_long {
    let f: unsafe extern "C" fn(
        *mut cty::c_void,
        cty::uint32_t,
        *const cty::c_void,
    ) -> cty::c_long = mem::transmute(113usize);

    f(dst, size, unsafe_ptr)
}

#[inline(always)]
pub unsafe fn ringbuf_output(
    ringbuf: *mut cty::c_void,
    data: *mut cty::c_void,
    size: cty::uint64_t,
    flags: cty::uint64_t,
) -> cty::c_long {
    let f: unsafe extern "C" fn(
        *mut cty::c_void,
        *mut cty::c_void,
        cty::uint64_t,
        cty::uint64_t,
    ) -> cty::c_long = mem::transmute(130usize);

    f(ringbuf, data, size, flags)
}

#[inline(always)]
pub unsafe fn ringbuf_reserve(
    ringbuf: *mut cty::c_void,
    size: cty::uint64_t,
    flags: cty::uint64_t,
) -> *mut cty::c_void {
    let f: unsafe extern "C" fn(
        *mut cty::c_void,
        cty::uint64_t,
        cty::uint64_t,
    ) -> *mut cty::c_void = mem::transmute(131usize);

    f(ringbuf, size, flags)
}

#[inline(always)]
pub unsafe fn ringbuf_submit(data: *mut cty::c_void, flags: cty::uint64_t) {
    let f: unsafe extern "C" fn(*mut cty::c_void, cty::uint64_t) = mem::transmute(132usize);

    f(data, flags)
}

#[inline(always)]
pub unsafe fn ringbuf_discard(data: *mut cty::c_void, flags: cty::uint64_t) {
    let f: unsafe extern "C" fn(*mut cty::c_void, cty::uint64_t) = mem::transmute(133usize);

    f(data, flags)
}