From 15e5c572c0fff96a32809702ccee030c246faa4b Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 27 Aug 2023 14:19:01 -0600 Subject: [PATCH] Eliminate the lazy_static dev dependency It's no longer needed, because for several versions now AtomicBool::new and parking_lot::Mutex::new are const functions. Fixes #1791 --- Cargo.toml | 1 - src/sys/aio.rs | 5 +---- src/sys/signal.rs | 5 +---- test/sys/test_aio.rs | 4 +--- test/sys/test_signal.rs | 4 +--- test/test.rs | 36 ++++++++++++++++-------------------- 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 010c9f895b..f15a932f61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,7 +71,6 @@ zerocopy = ["fs", "uio"] [dev-dependencies] assert-impl = "0.1" -lazy_static = "1.4" parking_lot = "0.12" rand = "0.8" tempfile = "3.7.1" diff --git a/src/sys/aio.rs b/src/sys/aio.rs index bd4c122916..5471177e3e 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -1142,14 +1142,11 @@ pub fn aio_suspend( /// # use std::sync::atomic::{AtomicBool, Ordering}; /// # use std::thread; /// # use std::time; -/// # use lazy_static::lazy_static; /// # use nix::errno::Errno; /// # use nix::sys::aio::*; /// # use nix::sys::signal::*; /// # use tempfile::tempfile; -/// lazy_static! { -/// pub static ref SIGNALED: AtomicBool = AtomicBool::new(false); -/// } +/// pub static SIGNALED: AtomicBool = AtomicBool::new(false); /// /// extern fn sigfunc(_: c_int) { /// SIGNALED.store(true, Ordering::Relaxed); diff --git a/src/sys/signal.rs b/src/sys/signal.rs index 34f60e2c82..c946e4a0b1 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -841,13 +841,10 @@ pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result(f: Fd, buf: &mut [u8]) { } } -lazy_static! { - /// Any test that changes the process's current working directory must grab - /// the RwLock exclusively. Any process that cares about the current - /// working directory must grab it shared. - pub static ref CWD_LOCK: RwLock<()> = RwLock::new(()); - /// Any test that creates child processes must grab this mutex, regardless - /// of what it does with those children. - pub static ref FORK_MTX: Mutex<()> = Mutex::new(()); - /// Any test that changes the process's supplementary groups must grab this - /// mutex - pub static ref GROUPS_MTX: Mutex<()> = Mutex::new(()); - /// Any tests that loads or unloads kernel modules must grab this mutex - pub static ref KMOD_MTX: Mutex<()> = Mutex::new(()); - /// Any test that calls ptsname(3) must grab this mutex. - pub static ref PTSNAME_MTX: Mutex<()> = Mutex::new(()); - /// Any test that alters signal handling must grab this mutex. - pub static ref SIGNAL_MTX: Mutex<()> = Mutex::new(()); -} +/// Any test that creates child processes must grab this mutex, regardless +/// of what it does with those children. +pub static FORK_MTX: std::sync::Mutex<()> = std::sync::Mutex::new(()); +/// Any test that changes the process's current working directory must grab +/// the RwLock exclusively. Any process that cares about the current +/// working directory must grab it shared. +pub static CWD_LOCK: RwLock<()> = RwLock::new(()); +/// Any test that changes the process's supplementary groups must grab this +/// mutex +pub static GROUPS_MTX: Mutex<()> = Mutex::new(()); +/// Any tests that loads or unloads kernel modules must grab this mutex +pub static KMOD_MTX: Mutex<()> = Mutex::new(()); +/// Any test that calls ptsname(3) must grab this mutex. +pub static PTSNAME_MTX: Mutex<()> = Mutex::new(()); +/// Any test that alters signal handling must grab this mutex. +pub static SIGNAL_MTX: Mutex<()> = Mutex::new(()); /// RAII object that restores a test's original directory on drop struct DirRestore<'a> {