Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
23f1767
allow taking address to union field
Kivooeo Aug 31, 2025
e1258e7
autodiff: Add basic TypeTree with NoTT flag
KMJ-007 Aug 23, 2025
375e14e
Add TypeTree metadata attachment for autodiff
KMJ-007 Aug 23, 2025
beba6b9
Update TypeTree tests to verify metadata attachment
KMJ-007 Aug 23, 2025
5d3ebc3
Add TypeTree tests for scalar types
KMJ-007 Aug 23, 2025
664e83b
added typetree support for memcpy
KMJ-007 Aug 23, 2025
b8bb2e8
typo: allow EnzymeTypeTreeShiftIndiciesEq
KMJ-007 Aug 27, 2025
d89ee85
enzyme submodule updated
KMJ-007 Aug 27, 2025
54f9376
autodiff: f128 support added for typetree
KMJ-007 Aug 27, 2025
31541fe
autodiff: add TypeTree support for arrays
KMJ-007 Sep 1, 2025
be3617b
autodiff: slice support in typetree
KMJ-007 Sep 1, 2025
7c5fbfb
autodiff: tuple support in typetree
KMJ-007 Sep 1, 2025
574f0b9
autodiff: struct support in typetree
KMJ-007 Sep 1, 2025
4f3f0f4
autodiff: fixed test to be more precise for type tree checking
KMJ-007 Sep 4, 2025
4520926
autodiff: recurion added for typetree
KMJ-007 Sep 11, 2025
3ba5f19
autodiff: typetree recursive depth query from enzyme with fallback
KMJ-007 Sep 12, 2025
97b2292
Allow shared access to `Exclusive<T>` when `T: Sync`
Jules-Bertholet Sep 17, 2025
f1d6e00
Bless UI tests
Jules-Bertholet Sep 21, 2025
c0de794
std::net: update tcp deferaccept delay type to Duration.
devnexen Apr 29, 2025
19d0e72
fix build for android
devnexen Sep 27, 2025
c1259aa
Add LSX accelerated implementation for source file analysis
heiher Aug 28, 2025
5e9cab3
modify ensure_version_or_cargo_install to check existing binary
Shunpoco Sep 28, 2025
322dca8
Rollup merge of #140482 - devnexen:tcp_deferaccept_toduration, r=joboet
matthiaskrgr Sep 28, 2025
6059195
Rollup merge of #141469 - Kivooeo:remove-usnsafegate, r=compiler-errors
matthiaskrgr Sep 28, 2025
c29fb2e
Rollup merge of #144197 - KMJ-007:type-tree, r=ZuseZ4
matthiaskrgr Sep 28, 2025
750e902
Rollup merge of #146675 - Jules-Bertholet:sync-nonexclusive, r=Mark-S…
matthiaskrgr Sep 28, 2025
aa6bd55
Rollup merge of #147113 - heiher:src-analysis-lsx, r=lqd
matthiaskrgr Sep 28, 2025
4eb6b8f
Rollup merge of #147120 - Shunpoco:issue-147105, r=Kobzol
matthiaskrgr Sep 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions library/std/src/os/net/linux_ext/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use crate::sealed::Sealed;
use crate::sys_common::AsInner;
#[cfg(target_os = "linux")]
use crate::time::Duration;
use crate::{io, net};

/// Os-specific extensions for [`TcpStream`]
Expand Down Expand Up @@ -59,11 +61,13 @@ pub trait TcpStreamExt: Sealed {

/// A socket listener will be awakened solely when data arrives.
///
/// The `accept` argument set the delay in seconds until the
/// The `accept` argument set the maximum delay until the
/// data is available to read, reducing the number of short lived
/// connections without data to process.
/// Contrary to other platforms `SO_ACCEPTFILTER` feature equivalent, there is
/// no necessity to set it after the `listen` call.
/// Note that the delay is expressed as Duration from user's perspective
/// the call rounds it down to the nearest second expressible as a `c_int`.
///
/// See [`man 7 tcp`](https://man7.org/linux/man-pages/man7/tcp.7.html)
///
Expand All @@ -73,16 +77,17 @@ pub trait TcpStreamExt: Sealed {
/// #![feature(tcp_deferaccept)]
/// use std::net::TcpStream;
/// use std::os::linux::net::TcpStreamExt;
/// use std::time::Duration;
///
/// let stream = TcpStream::connect("127.0.0.1:8080")
/// .expect("Couldn't connect to the server...");
/// stream.set_deferaccept(1).expect("set_deferaccept call failed");
/// stream.set_deferaccept(Duration::from_secs(1u64)).expect("set_deferaccept call failed");
/// ```
#[unstable(feature = "tcp_deferaccept", issue = "119639")]
#[cfg(target_os = "linux")]
fn set_deferaccept(&self, accept: u32) -> io::Result<()>;
fn set_deferaccept(&self, accept: Duration) -> io::Result<()>;

/// Gets the accept delay value (in seconds) of the `TCP_DEFER_ACCEPT` option.
/// Gets the accept delay value of the `TCP_DEFER_ACCEPT` option.
///
/// For more information about this option, see [`TcpStreamExt::set_deferaccept`].
///
Expand All @@ -92,15 +97,16 @@ pub trait TcpStreamExt: Sealed {
/// #![feature(tcp_deferaccept)]
/// use std::net::TcpStream;
/// use std::os::linux::net::TcpStreamExt;
/// use std::time::Duration;
///
/// let stream = TcpStream::connect("127.0.0.1:8080")
/// .expect("Couldn't connect to the server...");
/// stream.set_deferaccept(1).expect("set_deferaccept call failed");
/// assert_eq!(stream.deferaccept().unwrap_or(0), 1);
/// stream.set_deferaccept(Duration::from_secs(1u64)).expect("set_deferaccept call failed");
/// assert_eq!(stream.deferaccept().unwrap(), Duration::from_secs(1u64));
/// ```
#[unstable(feature = "tcp_deferaccept", issue = "119639")]
#[cfg(target_os = "linux")]
fn deferaccept(&self) -> io::Result<u32>;
fn deferaccept(&self) -> io::Result<Duration>;
}

#[stable(feature = "tcp_quickack", since = "1.89.0")]
Expand All @@ -117,12 +123,12 @@ impl TcpStreamExt for net::TcpStream {
}

#[cfg(target_os = "linux")]
fn set_deferaccept(&self, accept: u32) -> io::Result<()> {
fn set_deferaccept(&self, accept: Duration) -> io::Result<()> {
self.as_inner().as_inner().set_deferaccept(accept)
}

#[cfg(target_os = "linux")]
fn deferaccept(&self) -> io::Result<u32> {
fn deferaccept(&self) -> io::Result<Duration> {
self.as_inner().as_inner().deferaccept()
}
}
11 changes: 7 additions & 4 deletions library/std/src/os/net/linux_ext/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fn deferaccept() {
use crate::net::test::next_test_ip4;
use crate::net::{TcpListener, TcpStream};
use crate::os::net::linux_ext::tcp::TcpStreamExt;
use crate::time::Duration;

macro_rules! t {
($e:expr) => {
Expand All @@ -43,10 +44,12 @@ fn deferaccept() {
}

let addr = next_test_ip4();
let one = Duration::from_secs(1u64);
let zero = Duration::from_secs(0u64);
let _listener = t!(TcpListener::bind(&addr));
let stream = t!(TcpStream::connect(&("localhost", addr.port())));
stream.set_deferaccept(1).expect("set_deferaccept failed");
assert_eq!(stream.deferaccept().unwrap(), 1);
stream.set_deferaccept(0).expect("set_deferaccept failed");
assert_eq!(stream.deferaccept().unwrap(), 0);
stream.set_deferaccept(one).expect("set_deferaccept failed");
assert_eq!(stream.deferaccept().unwrap(), one);
stream.set_deferaccept(zero).expect("set_deferaccept failed");
assert_eq!(stream.deferaccept().unwrap(), zero);
}
9 changes: 5 additions & 4 deletions library/std/src/sys/net/connection/socket/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,15 @@ impl Socket {

// bionic libc makes no use of this flag
#[cfg(target_os = "linux")]
pub fn set_deferaccept(&self, accept: u32) -> io::Result<()> {
setsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT, accept as c_int)
pub fn set_deferaccept(&self, accept: Duration) -> io::Result<()> {
let val = cmp::min(accept.as_secs(), c_int::MAX as u64) as c_int;
setsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT, val)
}

#[cfg(target_os = "linux")]
pub fn deferaccept(&self) -> io::Result<u32> {
pub fn deferaccept(&self) -> io::Result<Duration> {
let raw: c_int = getsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT)?;
Ok(raw as u32)
Ok(Duration::from_secs(raw as _))
}

#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
Expand Down