Skip to content

Commit

Permalink
Generate bindings for user_ring_buffer_*
Browse files Browse the repository at this point in the history
Generate bindings for the user_ring_buffer_* API functions. These enable
user space produced ring buffers.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b66ccae01f1ddce47fe2c7f393a3a5c5ab3d7f06

Signed-off-by: Jose Fernandez <josef@netflix.com>
  • Loading branch information
jfernandez authored and alexforster committed May 4, 2024
1 parent dc97350 commit a88f889
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fn generate_bindings(src_dir: path::PathBuf) {
.allowlist_function("libbpf_.+")
.allowlist_function("perf_.+")
.allowlist_function("ring_buffer_.+")
.allowlist_function("user_ring_buffer_.+")
.allowlist_function("vdprintf")
.allowlist_type("bpf_.+")
.allowlist_type("btf_.+")
Expand Down
43 changes: 42 additions & 1 deletion src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5486,8 +5486,8 @@ extern "C" {
opts: *mut bpf_token_create_opts,
) -> ::std::os::raw::c_int;
}
pub type __gnuc_va_list = __builtin_va_list;
pub type va_list = __builtin_va_list;
pub type __gnuc_va_list = __builtin_va_list;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct btf_header {
Expand Down Expand Up @@ -7045,6 +7045,11 @@ pub struct ring_buffer {
pub struct ring {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct user_ring_buffer {
_unused: [u8; 0],
}
pub type ring_buffer_sample_fn = ::std::option::Option<
unsafe extern "C" fn(
ctx: *mut ::std::os::raw::c_void,
Expand Down Expand Up @@ -7092,6 +7097,42 @@ extern "C" {
pub fn ring_buffer__ring(rb: *mut ring_buffer, idx: ::std::os::raw::c_uint) -> *mut ring;
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct user_ring_buffer_opts {
pub sz: size_t,
}
extern "C" {
pub fn user_ring_buffer__new(
map_fd: ::std::os::raw::c_int,
opts: *const user_ring_buffer_opts,
) -> *mut user_ring_buffer;
}
extern "C" {
pub fn user_ring_buffer__reserve(
rb: *mut user_ring_buffer,
size: __u32,
) -> *mut ::std::os::raw::c_void;
}
extern "C" {
pub fn user_ring_buffer__reserve_blocking(
rb: *mut user_ring_buffer,
size: __u32,
timeout_ms: ::std::os::raw::c_int,
) -> *mut ::std::os::raw::c_void;
}
extern "C" {
pub fn user_ring_buffer__submit(rb: *mut user_ring_buffer, sample: *mut ::std::os::raw::c_void);
}
extern "C" {
pub fn user_ring_buffer__discard(
rb: *mut user_ring_buffer,
sample: *mut ::std::os::raw::c_void,
);
}
extern "C" {
pub fn user_ring_buffer__free(rb: *mut user_ring_buffer);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct perf_buffer {
_unused: [u8; 0],
Expand Down

0 comments on commit a88f889

Please sign in to comment.