Skip to content

Commit d59d235

Browse files
authored
Eliminate the lazy_static dev dependency (#2107)
It's no longer needed, because for several versions now AtomicBool::new and parking_lot::Mutex::new are const functions. Fixes #1791
1 parent 56e1277 commit d59d235

File tree

6 files changed

+20
-35
lines changed

6 files changed

+20
-35
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ zerocopy = ["fs", "uio"]
7171

7272
[dev-dependencies]
7373
assert-impl = "0.1"
74-
lazy_static = "1.4"
7574
parking_lot = "0.12"
7675
rand = "0.8"
7776
tempfile = "3.7.1"

src/sys/aio.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,14 +1142,11 @@ pub fn aio_suspend(
11421142
/// # use std::sync::atomic::{AtomicBool, Ordering};
11431143
/// # use std::thread;
11441144
/// # use std::time;
1145-
/// # use lazy_static::lazy_static;
11461145
/// # use nix::errno::Errno;
11471146
/// # use nix::sys::aio::*;
11481147
/// # use nix::sys::signal::*;
11491148
/// # use tempfile::tempfile;
1150-
/// lazy_static! {
1151-
/// pub static ref SIGNALED: AtomicBool = AtomicBool::new(false);
1152-
/// }
1149+
/// pub static SIGNALED: AtomicBool = AtomicBool::new(false);
11531150
///
11541151
/// extern fn sigfunc(_: c_int) {
11551152
/// SIGNALED.store(true, Ordering::Relaxed);

src/sys/signal.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,13 +841,10 @@ pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result<SigActi
841841
/// Use a signal handler to set a flag variable:
842842
///
843843
/// ```no_run
844-
/// # #[macro_use] extern crate lazy_static;
845844
/// # use std::convert::TryFrom;
846845
/// # use std::sync::atomic::{AtomicBool, Ordering};
847846
/// # use nix::sys::signal::{self, Signal, SigHandler};
848-
/// lazy_static! {
849-
/// static ref SIGNALED: AtomicBool = AtomicBool::new(false);
850-
/// }
847+
/// static SIGNALED: AtomicBool = AtomicBool::new(false);
851848
///
852849
/// extern fn handle_sigint(signal: libc::c_int) {
853850
/// let signal = Signal::try_from(signal).unwrap();

test/sys/test_aio.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ use nix::{
2121
};
2222
use tempfile::tempfile;
2323

24-
lazy_static! {
25-
pub static ref SIGNALED: AtomicBool = AtomicBool::new(false);
26-
}
24+
pub static SIGNALED: AtomicBool = AtomicBool::new(false);
2725

2826
extern "C" fn sigfunc(_: c_int) {
2927
SIGNALED.store(true, Ordering::Relaxed);

test/sys/test_signal.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ fn test_sigprocmask() {
7878
.expect("expect to be able to block signals");
7979
}
8080

81-
lazy_static! {
82-
static ref SIGNALED: AtomicBool = AtomicBool::new(false);
83-
}
81+
static SIGNALED: AtomicBool = AtomicBool::new(false);
8482

8583
extern "C" fn test_sigaction_handler(signal: libc::c_int) {
8684
let signal = Signal::try_from(signal).unwrap();

test/test.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
extern crate cfg_if;
33
#[cfg_attr(not(any(target_os = "redox", target_os = "haiku")), macro_use)]
44
extern crate nix;
5-
#[macro_use]
6-
extern crate lazy_static;
75

86
mod common;
97
mod sys;
@@ -79,24 +77,22 @@ fn read_exact<Fd: AsFd>(f: Fd, buf: &mut [u8]) {
7977
}
8078
}
8179

82-
lazy_static! {
83-
/// Any test that changes the process's current working directory must grab
84-
/// the RwLock exclusively. Any process that cares about the current
85-
/// working directory must grab it shared.
86-
pub static ref CWD_LOCK: RwLock<()> = RwLock::new(());
87-
/// Any test that creates child processes must grab this mutex, regardless
88-
/// of what it does with those children.
89-
pub static ref FORK_MTX: Mutex<()> = Mutex::new(());
90-
/// Any test that changes the process's supplementary groups must grab this
91-
/// mutex
92-
pub static ref GROUPS_MTX: Mutex<()> = Mutex::new(());
93-
/// Any tests that loads or unloads kernel modules must grab this mutex
94-
pub static ref KMOD_MTX: Mutex<()> = Mutex::new(());
95-
/// Any test that calls ptsname(3) must grab this mutex.
96-
pub static ref PTSNAME_MTX: Mutex<()> = Mutex::new(());
97-
/// Any test that alters signal handling must grab this mutex.
98-
pub static ref SIGNAL_MTX: Mutex<()> = Mutex::new(());
99-
}
80+
/// Any test that creates child processes must grab this mutex, regardless
81+
/// of what it does with those children.
82+
pub static FORK_MTX: std::sync::Mutex<()> = std::sync::Mutex::new(());
83+
/// Any test that changes the process's current working directory must grab
84+
/// the RwLock exclusively. Any process that cares about the current
85+
/// working directory must grab it shared.
86+
pub static CWD_LOCK: RwLock<()> = RwLock::new(());
87+
/// Any test that changes the process's supplementary groups must grab this
88+
/// mutex
89+
pub static GROUPS_MTX: Mutex<()> = Mutex::new(());
90+
/// Any tests that loads or unloads kernel modules must grab this mutex
91+
pub static KMOD_MTX: Mutex<()> = Mutex::new(());
92+
/// Any test that calls ptsname(3) must grab this mutex.
93+
pub static PTSNAME_MTX: Mutex<()> = Mutex::new(());
94+
/// Any test that alters signal handling must grab this mutex.
95+
pub static SIGNAL_MTX: Mutex<()> = Mutex::new(());
10096

10197
/// RAII object that restores a test's original directory on drop
10298
struct DirRestore<'a> {

0 commit comments

Comments
 (0)