Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ targets = [
]

[dependencies]
libc = { version = "=0.2.175", features = ["extra_traits"] }
libc = { version = "=0.2.180", features = ["extra_traits"] }
Copy link
Copy Markdown
Contributor

@tisonkun tisonkun Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we use version = "0.2.180" but pin to an exact one?

If libc follows semver, this should be fine. But libc may remove variables even if the version doesn't increase a breaking one?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we use version = "0.2.180" but pin to an exact one?

See #2737 (comment)

This will be unpinned by #2744

bitflags = "2.3.3"
cfg-if = "1.0"
pin-utils = { version = "0.1.0", optional = true }
Expand Down
1 change: 1 addition & 0 deletions changelog/2724.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bumped libc to [0.2.180](https://github.com/rust-lang/libc/releases/tag/0.2.180)
1 change: 1 addition & 0 deletions changelog/2724.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed `IFF_NOTRAILERS` by NetBSD, as it has been removed upstream and from libc
4 changes: 4 additions & 0 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,16 +1175,20 @@ libc_bitflags! {
/// Request that pages be moved instead of copied.
///
/// Not applicable to `vmsplice`.
#[cfg(not(target_env = "uclibc"))]
SPLICE_F_MOVE;
/// Do not block on I/O.
#[cfg(not(target_env = "uclibc"))]
SPLICE_F_NONBLOCK;
/// Hint that more data will be coming in a subsequent splice.
///
/// Not applicable to `vmsplice`.
#[cfg(not(target_env = "uclibc"))]
SPLICE_F_MORE;
/// Gift the user pages to the kernel.
///
/// Not applicable to `splice`.
#[cfg(not(target_env = "uclibc"))]
SPLICE_F_GIFT;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/net/if_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ libc_bitflags!(
solarish,
apple_targets,
target_os = "fuchsia",
target_os = "netbsd",
target_os = "cygwin"))]
IFF_NOTRAILERS as IflagsType;
/// Interface manages own routes.
Expand Down
9 changes: 2 additions & 7 deletions src/sys/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ impl Kqueue {
}
}

#[cfg(any(freebsdlike, apple_targets, target_os = "openbsd"))]
type type_of_udata = *mut libc::c_void;
#[cfg(target_os = "netbsd")]
type type_of_udata = intptr_t;

#[cfg(target_os = "netbsd")]
type type_of_event_filter = u32;
#[cfg(not(target_os = "netbsd"))]
Expand Down Expand Up @@ -364,7 +359,7 @@ impl KEvent {
fflags: fflags.bits(),
// data can be either i64 or intptr_t, depending on platform
data: data as _,
udata: udata as type_of_udata,
udata: udata as *mut libc::c_void,
..unsafe { mem::zeroed() }
},
}
Expand Down Expand Up @@ -456,5 +451,5 @@ pub fn ev_set(
ev.kevent.flags = flags.bits();
ev.kevent.fflags = fflags.bits();
ev.kevent.data = 0;
ev.kevent.udata = udata as type_of_udata;
ev.kevent.udata = udata as *mut libc::c_void;
}
20 changes: 10 additions & 10 deletions src/sys/memfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,34 @@ libc_bitflags!(
/// See also the hugetlb filesystem in [`memfd_create(2)`].
///
/// [`memfd_create(2)`]: https://man7.org/linux/man-pages/man2/memfd_create.2.html
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
MFD_HUGE_1MB;
/// hugetlb size of 2MB.
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
MFD_HUGE_2MB;
/// hugetlb size of 8MB.
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
MFD_HUGE_8MB;
/// hugetlb size of 16MB.
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
MFD_HUGE_16MB;
/// hugetlb size of 32MB.
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
MFD_HUGE_32MB;
/// hugetlb size of 256MB.
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
MFD_HUGE_256MB;
/// hugetlb size of 512MB.
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
MFD_HUGE_512MB;
/// hugetlb size of 1GB.
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
MFD_HUGE_1GB;
/// hugetlb size of 2GB.
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
MFD_HUGE_2GB;
/// hugetlb size of 16GB.
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
MFD_HUGE_16GB;
}
);
Expand Down
5 changes: 4 additions & 1 deletion src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,10 @@ impl ControlMessageOwned {
let (err, addr) = unsafe { Self::recv_err_helper::<sockaddr_in6>(p, len) };
ControlMessageOwned::Ipv6RecvErr(err, addr)
},
#[cfg(any(linux_android, target_os = "freebsd"))]
#[cfg(any(
all(linux_android, not(target_env = "uclibc")),
target_os = "freebsd"
))]
#[cfg(feature = "net")]
(libc::IPPROTO_IPV6, libc::IPV6_ORIGDSTADDR) => {
let dl = unsafe { ptr::read_unaligned(p as *const libc::sockaddr_in6) };
Expand Down
11 changes: 9 additions & 2 deletions src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ sockopt_impl!(
);
#[cfg(linux_android)]
#[cfg(feature = "net")]
#[cfg(not(target_env = "uclibc"))]
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
/// If enabled, the kernel will not reserve an ephemeral port when binding
Expand Down Expand Up @@ -1243,7 +1244,10 @@ sockopt_impl!(
libc::IPV6_RECVHOPLIMIT,
bool
);
#[cfg(any(linux_android, target_os = "freebsd"))]
#[cfg(any(
all(linux_android, not(target_env = "uclibc")),
target_os = "freebsd"
))]
#[cfg(feature = "net")]
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
Expand All @@ -1264,7 +1268,10 @@ sockopt_impl!(
libc::IP_DONTFRAG,
bool
);
#[cfg(any(linux_android, apple_targets))]
#[cfg(any(
all(linux_android, not(target_env = "uclibc")),
apple_targets
))]
sockopt_impl!(
/// Set "don't fragment packet" flag on the IPv6 packet.
Ipv6DontFrag,
Expand Down
8 changes: 8 additions & 0 deletions src/sys/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ impl TimeVal {
})
}

#[cfg_attr(
any(target_env = "musl", target_env = "ohos"),
allow(deprecated)
)] // https://github.com/rust-lang/libc/issues/1848
fn micros_mod_sec(&self) -> suseconds_t {
if self.tv_sec() < 0 && self.tv_usec() > 0 {
self.tv_usec() - MICROS_PER_SEC as suseconds_t
Expand All @@ -640,6 +644,10 @@ impl TimeVal {
self.0.tv_sec
}

#[cfg_attr(
any(target_env = "musl", target_env = "ohos"),
allow(deprecated)
)] // https://github.com/rust-lang/libc/issues/1848
pub const fn tv_usec(&self) -> suseconds_t {
self.0.tv_usec
}
Expand Down
5 changes: 4 additions & 1 deletion test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2108,7 +2108,10 @@ pub fn test_recvif_ipv4() {
}
}

#[cfg(any(linux_android, target_os = "freebsd"))]
#[cfg(any(
all(linux_android, not(target_env = "uclibc")),
target_os = "freebsd"
))]
#[cfg_attr(qemu, ignore)]
#[test]
pub fn test_recvif_ipv6() {
Expand Down
4 changes: 2 additions & 2 deletions test/sys/test_sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ fn test_dontfrag_opts() {
}

#[test]
#[cfg(any(linux_android, apple_targets))]
#[cfg(any(all(linux_android, not(target_env = "uclibc")), apple_targets))]
// Disable the test under emulation because it fails in Cirrus-CI. Lack
// of QEMU support is suspected.
#[cfg_attr(qemu, ignore)]
Expand Down Expand Up @@ -696,7 +696,7 @@ fn test_ts_clock_monotonic() {
}

#[test]
#[cfg(linux_android)]
#[cfg(all(linux_android, not(target_env = "uclibc")))]
// Disable the test under emulation because it fails with ENOPROTOOPT in CI
// on cross target. Lack of QEMU support is suspected.
#[cfg_attr(qemu, ignore)]
Expand Down