Warning
This post was published 62 days ago. The information described in this article may have changed.
I have a mutable stativ variable that comes from a C library.
#[link(name = "imaevm")]
extern "C" {
static mut imaevm_params: libimaevm_params;
}
libimaevm
fills this struct with values taken from options and arguments of the CLI application. This is safe since the CLI is single-threaded. But how do I ensure that calling something like this from multiple threads is safe?
fn do_stuff(some_field: *const i8) {
unsafe {
imaevm_params = libimaevm_params {
some_field,
..imaevm_params
};
}
use_imaevm_params();
}
3 posts - 2 participants
🏷️ rust_feed