aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-06-09 08:46:43 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-06-09 08:48:36 +0300
commitf203c8729a8535f6a317df5a35dc01306be2e45c (patch)
treef54accdbbad9e9d5ff35bd4c21c7e46cf78f14b6
parentdbf0dddfcc253f9e2b910590ec3d0bd58ed3aa71 (diff)
downloadniri-f203c8729a8535f6a317df5a35dc01306be2e45c.tar.gz
niri-f203c8729a8535f6a317df5a35dc01306be2e45c.tar.bz2
niri-f203c8729a8535f6a317df5a35dc01306be2e45c.zip
Use generic Atomic for rlim_t
rlim_t is different between platforms.
-rw-r--r--Cargo.lock10
-rw-r--r--Cargo.toml1
-rw-r--r--src/utils/spawning.rs9
3 files changed, 16 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 24ccde7a..72643a4a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -325,6 +325,15 @@ dependencies = [
]
[[package]]
+name = "atomic"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994"
+dependencies = [
+ "bytemuck",
+]
+
+[[package]]
name = "atomic-waker"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2179,6 +2188,7 @@ dependencies = [
"arrayvec",
"async-channel",
"async-io 1.13.0",
+ "atomic",
"bitflags 2.5.0",
"bytemuck",
"calloop 0.13.0",
diff --git a/Cargo.toml b/Cargo.toml
index f1652eb3..88bfca15 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -45,6 +45,7 @@ anyhow.workspace = true
arrayvec = "0.7.4"
async-channel = "2.3.1"
async-io = { version = "1.13.0", optional = true }
+atomic = "0.6.0"
bitflags.workspace = true
bytemuck = { version = "1.16.0", features = ["derive"] }
calloop = { version = "0.13.0", features = ["executor", "futures-io"] }
diff --git a/src/utils/spawning.rs b/src/utils/spawning.rs
index 9a274ff3..871f05db 100644
--- a/src/utils/spawning.rs
+++ b/src/utils/spawning.rs
@@ -2,11 +2,12 @@ use std::ffi::OsStr;
use std::os::unix::process::CommandExt;
use std::path::Path;
use std::process::{Child, Command, Stdio};
-use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
+use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::RwLock;
use std::{io, thread};
-use libc::{getrlimit, rlimit, setrlimit, RLIMIT_NOFILE};
+use atomic::Atomic;
+use libc::{getrlimit, rlim_t, rlimit, setrlimit, RLIMIT_NOFILE};
use niri_config::Environment;
use crate::utils::expand_home;
@@ -15,8 +16,8 @@ pub static REMOVE_ENV_RUST_BACKTRACE: AtomicBool = AtomicBool::new(false);
pub static REMOVE_ENV_RUST_LIB_BACKTRACE: AtomicBool = AtomicBool::new(false);
pub static CHILD_ENV: RwLock<Environment> = RwLock::new(Environment(Vec::new()));
-static ORIGINAL_NOFILE_RLIMIT_CUR: AtomicU64 = AtomicU64::new(0);
-static ORIGINAL_NOFILE_RLIMIT_MAX: AtomicU64 = AtomicU64::new(0);
+static ORIGINAL_NOFILE_RLIMIT_CUR: Atomic<rlim_t> = Atomic::new(0);
+static ORIGINAL_NOFILE_RLIMIT_MAX: Atomic<rlim_t> = Atomic::new(0);
/// Increases the nofile rlimit to the maximum and stores the original value.
pub fn store_and_increase_nofile_rlimit() {