master
rs 33 lines 852 Bytes
Raw
1 // SPDX-License-Identifier: GPL-2.0-or-later
2
3 use util_sys::{bql_block_unlock, bql_locked, rust_bql_mock_lock};
4
5 mod cell;
6 pub use cell::*;
7
8 // preserve one-item-per-"use" syntax, it is clearer
9 // for prelude-like modules
10 #[rustfmt::skip]
11 pub mod prelude;
12
13 /// An internal function that is used by doctests.
14 pub fn start_test() {
15 // SAFETY: integration tests are run with --test-threads=1, while
16 // unit tests and doctests are not multithreaded and do not have
17 // any BQL-protected data. Just set bql_locked to true.
18 unsafe {
19 rust_bql_mock_lock();
20 }
21 }
22
23 pub fn is_locked() -> bool {
24 // SAFETY: the function does nothing but return a thread-local bool
25 unsafe { bql_locked() }
26 }
27
28 pub fn block_unlock(increase: bool) {
29 // SAFETY: this only adjusts a counter
30 unsafe {
31 bql_block_unlock(increase);
32 }
33 }