mirror of
https://github.com/mborgerson/xemu.git
synced 2026-03-30 07:43:30 +00:00
Unfortunately, an example had to be compile-time disabled, since it relies on higher level crates (qdev, irq etc). The alternative is probably to move that code to an example in qemu-api or elsewere and make a link to it, or include_str. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Link: https://lore.kernel.org/r/20250827104147.717203-12-marcandre.lureau@redhat.com Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
30 lines
750 B
Rust
30 lines
750 B
Rust
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
mod bindings;
|
|
use bindings::{bql_block_unlock, bql_locked, rust_bql_mock_lock};
|
|
|
|
mod cell;
|
|
pub use cell::*;
|
|
|
|
/// 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);
|
|
}
|
|
}
|