Skip to content

Commit

Permalink
Removed unused tokio_* cfgs
Browse files Browse the repository at this point in the history
 - tokio_no_const_thread_local
 - tokio_no_target_has_atomic
 - tokio_no_as_fd

Signed-off-by: Jiahao XU <[email protected]>
  • Loading branch information
NobodyXu committed Jul 28, 2023
1 parent c445e46 commit 0db351b
Show file tree
Hide file tree
Showing 19 changed files with 5 additions and 101 deletions.
4 changes: 1 addition & 3 deletions tokio/src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ impl std::os::unix::io::AsRawFd for File {
}
}

#[cfg(all(unix, not(tokio_no_as_fd)))]
#[cfg(unix)]
impl std::os::unix::io::AsFd for File {
fn as_fd(&self) -> std::os::unix::io::BorrowedFd<'_> {
unsafe {
Expand All @@ -776,7 +776,6 @@ impl std::os::unix::io::FromRawFd for File {

cfg_windows! {
use crate::os::windows::io::{AsRawHandle, FromRawHandle, RawHandle};
#[cfg(not(tokio_no_as_fd))]
use crate::os::windows::io::{AsHandle, BorrowedHandle};

impl AsRawHandle for File {
Expand All @@ -785,7 +784,6 @@ cfg_windows! {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsHandle for File {
fn as_handle(&self) -> BorrowedHandle<'_> {
unsafe {
Expand Down
1 change: 0 additions & 1 deletion tokio/src/io/async_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ impl<T: AsRawFd> AsRawFd for AsyncFd<T> {
}
}

#[cfg(not(tokio_no_as_fd))]
impl<T: AsRawFd> std::os::unix::io::AsFd for AsyncFd<T> {
fn as_fd(&self) -> std::os::unix::io::BorrowedFd<'_> {
unsafe { std::os::unix::io::BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand Down
4 changes: 0 additions & 4 deletions tokio/src/io/stderr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ cfg_io_std! {

#[cfg(unix)]
mod sys {
#[cfg(not(tokio_no_as_fd))]
use std::os::unix::io::{AsFd, BorrowedFd};
use std::os::unix::io::{AsRawFd, RawFd};

Expand All @@ -87,7 +86,6 @@ mod sys {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for Stderr {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand All @@ -96,7 +94,6 @@ mod sys {
}

cfg_windows! {
#[cfg(not(tokio_no_as_fd))]
use crate::os::windows::io::{AsHandle, BorrowedHandle};
use crate::os::windows::io::{AsRawHandle, RawHandle};

Expand All @@ -106,7 +103,6 @@ cfg_windows! {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsHandle for Stderr {
fn as_handle(&self) -> BorrowedHandle<'_> {
unsafe { BorrowedHandle::borrow_raw(self.as_raw_handle()) }
Expand Down
4 changes: 0 additions & 4 deletions tokio/src/io/stdin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ cfg_io_std! {

#[cfg(unix)]
mod sys {
#[cfg(not(tokio_no_as_fd))]
use std::os::unix::io::{AsFd, BorrowedFd};
use std::os::unix::io::{AsRawFd, RawFd};

Expand All @@ -62,7 +61,6 @@ mod sys {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for Stdin {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand All @@ -71,7 +69,6 @@ mod sys {
}

cfg_windows! {
#[cfg(not(tokio_no_as_fd))]
use crate::os::windows::io::{AsHandle, BorrowedHandle};
use crate::os::windows::io::{AsRawHandle, RawHandle};

Expand All @@ -81,7 +78,6 @@ cfg_windows! {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsHandle for Stdin {
fn as_handle(&self) -> BorrowedHandle<'_> {
unsafe { BorrowedHandle::borrow_raw(self.as_raw_handle()) }
Expand Down
4 changes: 0 additions & 4 deletions tokio/src/io/stdout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ cfg_io_std! {

#[cfg(unix)]
mod sys {
#[cfg(not(tokio_no_as_fd))]
use std::os::unix::io::{AsFd, BorrowedFd};
use std::os::unix::io::{AsRawFd, RawFd};

Expand All @@ -86,7 +85,6 @@ mod sys {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for Stdout {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand All @@ -95,7 +93,6 @@ mod sys {
}

cfg_windows! {
#[cfg(not(tokio_no_as_fd))]
use crate::os::windows::io::{AsHandle, BorrowedHandle};
use crate::os::windows::io::{AsRawHandle, RawHandle};

Expand All @@ -105,7 +102,6 @@ cfg_windows! {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsHandle for Stdout {
fn as_handle(&self) -> BorrowedHandle<'_> {
unsafe { BorrowedHandle::borrow_raw(self.as_raw_handle()) }
Expand Down
18 changes: 2 additions & 16 deletions tokio/src/macros/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,7 @@ macro_rules! cfg_not_coop {
macro_rules! cfg_has_atomic_u64 {
($($item:item)*) => {
$(
#[cfg_attr(
not(tokio_no_target_has_atomic),
cfg(all(target_has_atomic = "64", not(tokio_no_atomic_u64))
))]
#[cfg_attr(
tokio_no_target_has_atomic,
cfg(not(tokio_no_atomic_u64))
)]
#[cfg(all(target_has_atomic = "64", not(tokio_no_atomic_u64)))]
$item
)*
}
Expand All @@ -539,14 +532,7 @@ macro_rules! cfg_has_atomic_u64 {
macro_rules! cfg_not_has_atomic_u64 {
($($item:item)*) => {
$(
#[cfg_attr(
not(tokio_no_target_has_atomic),
cfg(any(not(target_has_atomic = "64"), tokio_no_atomic_u64)
))]
#[cfg_attr(
tokio_no_target_has_atomic,
cfg(tokio_no_atomic_u64)
)]
#[cfg(any(not(target_has_atomic = "64"), tokio_no_atomic_u64))]
$item
)*
}
Expand Down
14 changes: 0 additions & 14 deletions tokio/src/macros/thread_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,9 @@ macro_rules! tokio_thread_local {
($($tts:tt)+) => { loom::thread_local!{ $($tts)+ } }
}

#[cfg(not(tokio_no_const_thread_local))]
#[cfg(not(all(loom, test)))]
macro_rules! tokio_thread_local {
($($tts:tt)+) => {
::std::thread_local!{ $($tts)+ }
}
}

#[cfg(tokio_no_const_thread_local)]
#[cfg(not(all(loom, test)))]
macro_rules! tokio_thread_local {
($(#[$attrs:meta])* $vis:vis static $name:ident: $ty:ty = const { $expr:expr } $(;)?) => {
::std::thread_local! {
$(#[$attrs])*
$vis static $name: $ty = $expr;
}
};

($($tts:tt)+) => { ::std::thread_local!{ $($tts)+ } }
}
4 changes: 0 additions & 4 deletions tokio/src/net/tcp/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ mod sys {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for TcpListener {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand All @@ -427,7 +426,6 @@ cfg_unstable! {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for TcpListener {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand All @@ -438,7 +436,6 @@ cfg_unstable! {

cfg_windows! {
use crate::os::windows::io::{AsRawSocket, RawSocket};
#[cfg(not(tokio_no_as_fd))]
use crate::os::windows::io::{AsSocket, BorrowedSocket};

impl AsRawSocket for TcpListener {
Expand All @@ -447,7 +444,6 @@ cfg_windows! {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsSocket for TcpListener {
fn as_socket(&self) -> BorrowedSocket<'_> {
unsafe { BorrowedSocket::borrow_raw(self.as_raw_socket()) }
Expand Down
6 changes: 2 additions & 4 deletions tokio/src/net/tcp/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ use std::fmt;
use std::io;
use std::net::SocketAddr;

#[cfg(all(unix, not(tokio_no_as_fd)))]
#[cfg(unix)]
use std::os::unix::io::{AsFd, BorrowedFd};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::time::Duration;

cfg_windows! {
use crate::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};
#[cfg(not(tokio_no_as_fd))]
use crate::os::windows::io::{AsSocket, BorrowedSocket};
}

Expand Down Expand Up @@ -788,7 +787,7 @@ impl AsRawFd for TcpSocket {
}
}

#[cfg(all(unix, not(tokio_no_as_fd)))]
#[cfg(unix)]
impl AsFd for TcpSocket {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand Down Expand Up @@ -829,7 +828,6 @@ cfg_windows! {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsSocket for TcpSocket {
fn as_socket(&self) -> BorrowedSocket<'_> {
unsafe { BorrowedSocket::borrow_raw(self.as_raw_socket()) }
Expand Down
4 changes: 0 additions & 4 deletions tokio/src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,6 @@ mod sys {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for TcpStream {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand All @@ -1388,7 +1387,6 @@ mod sys {

cfg_windows! {
use crate::os::windows::io::{AsRawSocket, RawSocket};
#[cfg(not(tokio_no_as_fd))]
use crate::os::windows::io::{AsSocket, BorrowedSocket};

impl AsRawSocket for TcpStream {
Expand All @@ -1397,7 +1395,6 @@ cfg_windows! {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsSocket for TcpStream {
fn as_socket(&self) -> BorrowedSocket<'_> {
unsafe { BorrowedSocket::borrow_raw(self.as_raw_socket()) }
Expand All @@ -1416,7 +1413,6 @@ mod sys {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for TcpStream {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand Down
3 changes: 0 additions & 3 deletions tokio/src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,6 @@ mod sys {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for UdpSocket {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand All @@ -2031,7 +2030,6 @@ mod sys {

cfg_windows! {
use crate::os::windows::io::{AsRawSocket, RawSocket};
#[cfg(not(tokio_no_as_fd))]
use crate::os::windows::io::{AsSocket, BorrowedSocket};

impl AsRawSocket for UdpSocket {
Expand All @@ -2040,7 +2038,6 @@ cfg_windows! {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsSocket for UdpSocket {
fn as_socket(&self) -> BorrowedSocket<'_> {
unsafe { BorrowedSocket::borrow_raw(self.as_raw_socket()) }
Expand Down
2 changes: 0 additions & 2 deletions tokio/src/net/unix/datagram/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::net::unix::SocketAddr;
use std::fmt;
use std::io;
use std::net::Shutdown;
#[cfg(not(tokio_no_as_fd))]
use std::os::unix::io::{AsFd, BorrowedFd};
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::os::unix::net;
Expand Down Expand Up @@ -1578,7 +1577,6 @@ impl AsRawFd for UnixDatagram {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for UnixDatagram {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand Down
2 changes: 0 additions & 2 deletions tokio/src/net/unix/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::net::unix::{SocketAddr, UnixStream};

use std::fmt;
use std::io;
#[cfg(not(tokio_no_as_fd))]
use std::os::unix::io::{AsFd, BorrowedFd};
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::os::unix::net;
Expand Down Expand Up @@ -211,7 +210,6 @@ impl AsRawFd for UnixListener {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for UnixListener {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand Down
3 changes: 0 additions & 3 deletions tokio/src/net/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use mio::unix::pipe as mio_pipe;
use std::fs::File;
use std::io::{self, Read, Write};
use std::os::unix::fs::{FileTypeExt, OpenOptionsExt};
#[cfg(not(tokio_no_as_fd))]
use std::os::unix::io::{AsFd, BorrowedFd};
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::path::Path;
Expand Down Expand Up @@ -664,7 +663,6 @@ impl AsRawFd for Sender {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for Sender {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand Down Expand Up @@ -1170,7 +1168,6 @@ impl AsRawFd for Receiver {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for Receiver {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand Down
2 changes: 0 additions & 2 deletions tokio/src/net/unix/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::net::unix::SocketAddr;
use std::fmt;
use std::io::{self, Read, Write};
use std::net::Shutdown;
#[cfg(not(tokio_no_as_fd))]
use std::os::unix::io::{AsFd, BorrowedFd};
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::os::unix::net;
Expand Down Expand Up @@ -1039,7 +1038,6 @@ impl AsRawFd for UnixStream {
}
}

#[cfg(not(tokio_no_as_fd))]
impl AsFd for UnixStream {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
Expand Down
Loading

0 comments on commit 0db351b

Please sign in to comment.