1 // SPDX-License-Identifier: GPL-2.0-or-later 2 3 mod bindings; 4 use bindings::{bql_block_unlock, bql_locked, rust_bql_mock_lock}; 5 6 mod cell; 7 pub use cell::*; 8 9 /// An internal function that is used by doctests. 10 pub fn start_test() { 11 // SAFETY: integration tests are run with --test-threads=1, while 12 // unit tests and doctests are not multithreaded and do not have 13 // any BQL-protected data. Just set bql_locked to true. 14 unsafe { 15 rust_bql_mock_lock(); 16 } 17 } 18 19 pub fn is_locked() -> bool { 20 // SAFETY: the function does nothing but return a thread-local bool 21 unsafe { bql_locked() } 22 } 23 24 pub fn block_unlock(increase: bool) { 25 // SAFETY: this only adjusts a counter 26 unsafe { 27 bql_block_unlock(increase); 28 } 29 } 30