Merge pull request #238 from vadorovsky/fix-doc-set-global

bpf: Improve documentation of set_global method
pull/239/head
Alessandro Decina 3 years ago committed by GitHub
commit 5269ab5b1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -222,9 +222,18 @@ impl<'a> BpfLoader<'a> {
/// Sets the value of a global variable /// Sets the value of a global variable
/// ///
/// From Rust eBPF, a global variable would be constructed as follows: /// From Rust eBPF, a global variable would be constructed as follows:
/// ```no run /// ```no_run
/// #[no_mangle] /// #[no_mangle]
/// const VERSION = 0; /// static VERSION: i32 = 0;
/// ```
/// Then it would be accessed with `core::ptr::read_volatile` inside
/// functions:
/// ```no_run
/// # #[no_mangle]
/// # static VERSION: i32 = 0;
/// # unsafe fn try_test() {
/// let version = core::ptr::read_volatile(&VERSION);
/// # }
/// ``` /// ```
/// If using a struct, ensure that it is `#[repr(C)]` to ensure the size will /// If using a struct, ensure that it is `#[repr(C)]` to ensure the size will
/// match that of the corresponding ELF symbol. /// match that of the corresponding ELF symbol.

Loading…
Cancel
Save