Extract typedef for AtomicU64

This commit is contained in:
Johannes Altmanninger
2026-01-11 16:51:41 +01:00
parent a194a557c5
commit de2ac37c92
8 changed files with 15 additions and 28 deletions

View File

@@ -23,10 +23,7 @@
use std::ops::{Deref, DerefMut};
use std::sync::LazyLock;
#[cfg(not(target_has_atomic = "64"))]
use portable_atomic::AtomicU64;
#[cfg(target_has_atomic = "64")]
use std::sync::atomic::AtomicU64;
use crate::portable_atomic::AtomicU64;
use std::sync::{Arc, Mutex, MutexGuard, atomic::Ordering};
/// Getter for universal variables.

View File

@@ -1,10 +1,7 @@
use crate::portable_atomic::AtomicU64;
use cfg_if::cfg_if;
#[cfg(not(target_has_atomic = "64"))]
use portable_atomic::AtomicU64;
use std::collections::HashMap;
use std::os::unix::prelude::*;
#[cfg(target_has_atomic = "64")]
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use std::sync::{Arc, Mutex};
use std::time::Duration;
@@ -472,13 +469,10 @@ fn drop(&mut self) {
#[cfg(test)]
mod tests {
#[cfg(not(target_has_atomic = "64"))]
use portable_atomic::AtomicU64;
use crate::portable_atomic::AtomicU64;
use std::fs::File;
use std::io::Write;
use std::os::fd::{AsRawFd, OwnedFd};
#[cfg(target_has_atomic = "64")]
use std::sync::atomic::AtomicU64;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Barrier, Mutex};
use std::thread;

View File

@@ -53,6 +53,7 @@
pub mod parser;
pub mod parser_keywords;
pub mod path;
pub mod portable_atomic;
pub mod prelude;
pub mod print_help;
pub mod proc;

View File

@@ -28,6 +28,7 @@
use crate::parse_execution::{EndExecutionReason, ExecutionContext};
use crate::parse_tree::NodeRef;
use crate::parse_tree::{LineCounter, ParsedSourceRef, parse_source};
use crate::portable_atomic::AtomicU64;
use crate::prelude::*;
use crate::proc::{JobGroupRef, JobList, JobRef, Pid, ProcStatus, job_reap};
use crate::signal::{Signal, signal_check_cancel, signal_clear_cancel};
@@ -37,8 +38,6 @@
use crate::{flog, flogf, function};
use fish_wchar::WExt;
use libc::c_int;
#[cfg(not(target_has_atomic = "64"))]
use portable_atomic::AtomicU64;
use std::cell::{Ref, RefCell, RefMut};
use std::ffi::OsStr;
use std::fs::File;
@@ -47,8 +46,6 @@
use std::os::fd::OwnedFd;
use std::rc::Rc;
use std::sync::Arc;
#[cfg(target_has_atomic = "64")]
use std::sync::atomic::AtomicU64;
use std::time::Duration;
pub enum BlockData {

7
src/portable_atomic.rs Normal file
View File

@@ -0,0 +1,7 @@
cfg_if::cfg_if! {
if #[cfg(target_has_atomic = "64")] {
pub use std::sync::atomic::AtomicU64;
} else {
pub use portable_atomic::AtomicU64;
}
}

View File

@@ -14,6 +14,7 @@
use crate::job_group::{JobGroup, MaybeJobId};
use crate::parse_tree::NodeRef;
use crate::parser::{Block, Parser};
use crate::portable_atomic::AtomicU64;
use crate::prelude::*;
use crate::reader::{fish_is_unwinding_for_exit, reader_schedule_prompt_repaint};
use crate::redirection::RedirectionSpecList;
@@ -28,16 +29,12 @@
SIGINT, SIGKILL, SIGPIPE, SIGQUIT, SIGSEGV, SIGSYS, SIGTTOU, STDOUT_FILENO, WCONTINUED,
WEXITSTATUS, WIFCONTINUED, WIFEXITED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WTERMSIG, WUNTRACED,
};
#[cfg(not(target_has_atomic = "64"))]
use portable_atomic::AtomicU64;
use std::cell::{Cell, Ref, RefCell, RefMut};
use std::fs;
use std::io::{Read, Write};
use std::num::NonZeroU32;
use std::os::fd::RawFd;
use std::rc::Rc;
#[cfg(target_has_atomic = "64")]
use std::sync::atomic::AtomicU64;
use std::sync::atomic::{AtomicU8, Ordering};
use std::sync::{Arc, LazyLock, Mutex, OnceLock};

View File

@@ -17,6 +17,7 @@
//! control-C from generating SIGINT, so failing to disable these would prevent cancellation of wildcard
//! expansion, etc.
use crate::portable_atomic::AtomicU64;
use libc::{
_POSIX_VDISABLE, ECHO, EINTR, EIO, EISDIR, ENOTTY, EPERM, ESRCH, ICANON, ICRNL, IEXTEN, INLCR,
IXOFF, IXON, O_NONBLOCK, O_RDONLY, ONLCR, OPOST, SIGINT, SIGTTIN, STDERR_FILENO, STDIN_FILENO,
@@ -24,8 +25,6 @@
};
use nix::fcntl::OFlag;
use nix::sys::stat::Mode;
#[cfg(not(target_has_atomic = "64"))]
use portable_atomic::AtomicU64;
use std::borrow::Cow;
use std::cell::UnsafeCell;
use std::cmp;
@@ -39,8 +38,6 @@
use std::os::fd::OwnedFd;
use std::os::fd::{AsRawFd, RawFd};
use std::pin::Pin;
#[cfg(target_has_atomic = "64")]
use std::sync::atomic::AtomicU64;
use std::sync::atomic::{AtomicI32, AtomicU8, AtomicU32, Ordering};
use std::sync::{Arc, LazyLock, Mutex, MutexGuard, OnceLock};
use std::time::{Duration, Instant};

View File

@@ -605,11 +605,8 @@ pub fn topic_monitor_principal() -> &'static TopicMonitor {
#[cfg(test)]
mod tests {
use super::{GenerationsList, Topic, TopicMonitor};
use crate::portable_atomic::AtomicU64;
use crate::tests::prelude::*;
#[cfg(not(target_has_atomic = "64"))]
use portable_atomic::AtomicU64;
#[cfg(target_has_atomic = "64")]
use std::sync::atomic::AtomicU64;
use std::sync::{
Arc,
atomic::{AtomicU32, Ordering},