1use cfg_if::cfg_if;
2
3fn emulate_freebsd_from_env() -> bool {
4 use once_cell::sync::OnceCell;
5 static CELL: OnceCell<bool> = OnceCell::new();
6 *CELL.get_or_init(|| {
7 let emulate = !matches!(
8 std::env::var("POSSUM_EMULATE_FREEBSD"),
9 Err(std::env::VarError::NotPresent)
10 );
11 if emulate {
12 super::error!("emulating freebsd");
13 }
14 emulate
15 })
16}
17
18pub(crate) fn emulate_freebsd() -> bool {
21 cfg_if! {
22 if #[cfg(target_os = "freebsd")] {
23 true
24 } else {
25 emulate_freebsd_from_env()
26 }
27 }
28}
29
30pub(crate) fn flocking() -> bool {
32 emulate_freebsd()
33}