Move raw FFI bindings generation to separate crates. This makes it possible to reuse bindgen declarations for a header file in its dependencies (this was not the case before this change), while keeping multiple -sys crates to avoid rebuilding all the code whenever something changes. Because the -sys crates are generated in dependency order, this also enforces that the crates are organized in something that resembles the dependencies between C headers. The meson.build for rust-safe crates becomes simpler, and it should be possible in the future to let Meson's cargo support handle most of it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> [General cleanup and Python script. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
34 lines
852 B
Rust
34 lines
852 B
Rust
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
use util_sys::{bql_block_unlock, bql_locked, rust_bql_mock_lock};
|
|
|
|
mod cell;
|
|
pub use cell::*;
|
|
|
|
// preserve one-item-per-"use" syntax, it is clearer
|
|
// for prelude-like modules
|
|
#[rustfmt::skip]
|
|
pub mod prelude;
|
|
|
|
/// An internal function that is used by doctests.
|
|
pub fn start_test() {
|
|
// SAFETY: integration tests are run with --test-threads=1, while
|
|
// unit tests and doctests are not multithreaded and do not have
|
|
// any BQL-protected data. Just set bql_locked to true.
|
|
unsafe {
|
|
rust_bql_mock_lock();
|
|
}
|
|
}
|
|
|
|
pub fn is_locked() -> bool {
|
|
// SAFETY: the function does nothing but return a thread-local bool
|
|
unsafe { bql_locked() }
|
|
}
|
|
|
|
pub fn block_unlock(increase: bool) {
|
|
// SAFETY: this only adjusts a counter
|
|
unsafe {
|
|
bql_block_unlock(increase);
|
|
}
|
|
}
|