Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Mutex for extern `static mut`
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