Skip to content

[0.2] Backports #4465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
May 29, 2025
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 .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: test on Solaris
uses: vmactions/solaris-vm@v1
uses: vmactions/solaris-vm@v1.1.3
with:
release: "11.4-gcc"
usesh: true
Expand Down
17 changes: 6 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
[package]
name = "libc"
version = "0.2.172"
authors = ["The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
edition = "2021"
repository = "https://github.com/rust-lang/libc"
homepage = "https://github.com/rust-lang/libc"
documentation = "https://docs.rs/libc/"
keywords = ["libc", "ffi", "bindings", "operating", "system"]
categories = ["external-ffi-bindings", "no-std", "os"]
build = "build.rs"
exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml"]
description = "Raw FFI bindings to platform libraries like libc."
publish = false # On the main branch, we don't want to publish anything
authors = ["The Rust Project Developers"]
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/libc"
rust-version = "1.63"
description = """
Raw FFI bindings to platform libraries like libc.
"""

[package.metadata.docs.rs]
features = ["extra_traits"]
Expand Down
8 changes: 7 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,13 @@ fn which_freebsd() -> Option<i32> {
}

fn emcc_version_code() -> Option<u64> {
let output = Command::new("emcc").arg("-dumpversion").output().ok()?;
let emcc = if cfg!(target_os = "windows") {
"emcc.bat"
} else {
"emcc"
};

let output = Command::new(emcc).arg("-dumpversion").output().ok()?;
if !output.status.success() {
return None;
}
Expand Down
12 changes: 4 additions & 8 deletions libc-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
[package]
name = "libc-test"
version = "0.2.155"
edition = "2021"
version = "0.1.0"
description = "A test crate for the libc crate."
publish = false
authors = ["The Rust Project Developers"]
edition = "2021"
license = "MIT OR Apache-2.0"
build = "build.rs"
publish = false
repository = "https://github.com/rust-lang/libc"
homepage = "https://github.com/rust-lang/libc"
description = """
A test crate for the libc crate.
"""

[dependencies]
cfg-if = "1.0.0"
Expand Down
40 changes: 39 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4123,6 +4123,10 @@ fn test_linux(target: &str) {
// Might differ between kernel versions
"open_how" => true,

// Linux >= 6.13 (pidfd_info.exit_code: Linux >= 6.15)
// Might differ between kernel versions
"pidfd_info" => true,

"sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo"
| "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true,

Expand Down Expand Up @@ -4229,6 +4233,7 @@ fn test_linux(target: &str) {
|| name.starts_with("OPEN_TREE_")
|| name.starts_with("P_")
|| name.starts_with("PF_")
|| name.starts_with("PIDFD_")
|| name.starts_with("RLIMIT_")
|| name.starts_with("RTEXT_FILTER_")
|| name.starts_with("SOL_")
Expand Down Expand Up @@ -4297,6 +4302,10 @@ fn test_linux(target: &str) {
if loongarch64 && (name == "MFD_NOEXEC_SEAL" || name == "MFD_EXEC") {
return true;
}
// FIXME: Requires >= 6.3 (6.6) kernel headers
if name == "PR_GET_MDWE" || name == "PR_MDWE_NO_INHERIT" || name == "PR_MDWE_REFUSE_EXEC_GAIN" || name == "PR_SET_MDWE" {
return true;
}
// FIXME(musl): Requires musl >= 1.2
if name == "SO_PREFER_BUSY_POLL"
|| name == "SO_BUSY_POLL_BUDGET"
Expand Down Expand Up @@ -4432,6 +4441,30 @@ fn test_linux(target: &str) {

// headers conflicts with linux/pidfd.h
"PIDFD_NONBLOCK" => true,
// Linux >= 6.9
"PIDFD_THREAD"
| "PIDFD_SIGNAL_THREAD"
| "PIDFD_SIGNAL_THREAD_GROUP"
| "PIDFD_SIGNAL_PROCESS_GROUP" => true,
// Linux >= 6.11
"PIDFD_GET_CGROUP_NAMESPACE"
| "PIDFD_GET_IPC_NAMESPACE"
| "PIDFD_GET_MNT_NAMESPACE"
| "PIDFD_GET_NET_NAMESPACE"
| "PIDFD_GET_PID_NAMESPACE"
| "PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE"
| "PIDFD_GET_TIME_NAMESPACE"
| "PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE"
| "PIDFD_GET_USER_NAMESPACE"
| "PIDFD_GET_UTS_NAMESPACE" => true,
// Linux >= 6.13
"PIDFD_GET_INFO"
| "PIDFD_INFO_PID"
| "PIDFD_INFO_CREDS"
| "PIDFD_INFO_CGROUPID"
| "PIDFD_INFO_SIZE_VER0" => true,
// Linux >= 6.15
"PIDFD_INFO_EXIT" | "PIDFD_SELF" | "PIDFD_SELF_PROCESS" => true,

// is a private value for kernel usage normally
"FUSE_SUPER_MAGIC" => true,
Expand Down Expand Up @@ -4554,6 +4587,9 @@ fn test_linux(target: &str) {
true
}

// FIXME(linux): Requires >= 6.6 kernel headers.
"PR_MDWE_NO_INHERIT" => true,

// FIXME(linux): Requires >= 6.8 kernel headers.
"XDP_UMEM_TX_SW_CSUM"
| "XDP_TXMD_FLAGS_TIMESTAMP"
Expand Down Expand Up @@ -4851,7 +4887,9 @@ fn test_linux(target: &str) {
(struct_ == "statvfs" && field == "__f_spare") ||
(struct_ == "statvfs64" && field == "__f_spare") ||
// the `xsk_tx_metadata_union` field is an anonymous union
(struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union")
(struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") ||
// FIXME(musl): After musl 1.2.0, the type becomes `int` instead of `long`.
(struct_ == "utmpx" && field == "ut_session")
});

cfg.skip_roundtrip(move |s| match s {
Expand Down
1 change: 0 additions & 1 deletion libc-test/semver/linux-musl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ OLD_TIME
PF_IB
PF_MPLS
PF_XDP
PIDFD_NONBLOCK
PR_SET_VMA
PR_SET_VMA_ANON_NAME
RUN_LVL
Expand Down
33 changes: 33 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,7 @@ PACKET_FANOUT_QM
PACKET_FANOUT_RND
PACKET_FANOUT_ROLLOVER
PACKET_HOST
PACKET_IGNORE_OUTGOING
PACKET_KERNEL
PACKET_LOOPBACK
PACKET_LOSS
Expand Down Expand Up @@ -2171,6 +2172,32 @@ PF_WANPIPE
PF_WQ_WORKER
PF_X
PF_X25
PIDFD_GET_CGROUP_NAMESPACE
PIDFD_GET_INFO
PIDFD_GET_IPC_NAMESPACE
PIDFD_GET_MNT_NAMESPACE
PIDFD_GET_NET_NAMESPACE
PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE
PIDFD_GET_PID_NAMESPACE
PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE
PIDFD_GET_TIME_NAMESPACE
PIDFD_GET_USER_NAMESPACE
PIDFD_GET_UTS_NAMESPACE
PIDFD_INFO_CGROUPID
PIDFD_INFO_CREDS
PIDFD_INFO_EXIT
PIDFD_INFO_PID
PIDFD_INFO_SIZE_VER0
PIDFD_NONBLOCK
PIDFD_SIGNAL_PROCESS_GROUP
PIDFD_SIGNAL_THREAD
PIDFD_SIGNAL_THREAD_GROUP
PIDFD_THREAD
PIDTYPE_MAX
PIDTYPE_PGID
PIDTYPE_PID
PIDTYPE_SID
PIDTYPE_TGID
PIPE_BUF
PM_STR
POLLRDBAND
Expand Down Expand Up @@ -2229,6 +2256,7 @@ PR_GET_FPEMU
PR_GET_FPEXC
PR_GET_FP_MODE
PR_GET_KEEPCAPS
PR_GET_MDWE
PR_GET_NAME
PR_GET_NO_NEW_PRIVS
PR_GET_PDEATHSIG
Expand All @@ -2247,6 +2275,8 @@ PR_MCE_KILL_EARLY
PR_MCE_KILL_GET
PR_MCE_KILL_LATE
PR_MCE_KILL_SET
PR_MDWE_NO_INHERIT
PR_MDWE_REFUSE_EXEC_GAIN
PR_MPX_DISABLE_MANAGEMENT
PR_MPX_ENABLE_MANAGEMENT
PR_SCHED_CORE
Expand All @@ -2265,6 +2295,7 @@ PR_SET_FPEMU
PR_SET_FPEXC
PR_SET_FP_MODE
PR_SET_KEEPCAPS
PR_SET_MDWE
PR_SET_MM
PR_SET_MM_ARG_END
PR_SET_MM_ARG_START
Expand Down Expand Up @@ -4038,6 +4069,8 @@ packet_mreq
pause
personality
pgn_t
pid_type
pidfd_info
pipe2
popen
posix_fadvise
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/redox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ O_SHLOCK
O_SYMLINK
PTHREAD_STACK_MIN
SA_RESTORER
SCM_RIGHTS
SIGIO
SIGPWR
SIGSTKFLT
Expand Down
8 changes: 8 additions & 0 deletions libc-test/semver/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,15 @@ c_void
calloc
chdir
chmod
clock
clock_t
close
commit
connect
creat
ctime
dev_t
difftime
dup
dup2
errno_t
Expand Down Expand Up @@ -214,7 +217,11 @@ fsetpos
fstat
ftell
fwrite
get_daylight
get_dstbias
get_osfhandle
get_timezone
get_tzname
getchar
getcwd
getenv
Expand Down Expand Up @@ -326,6 +333,7 @@ tm
tmpfile
tolower
toupper
tzset
uint16_t
uint32_t
uint64_t
Expand Down
62 changes: 28 additions & 34 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,9 +1452,9 @@ pub const GRPQUOTA: c_int = 1;

pub const SIGIOT: c_int = 6;

pub const S_ISUID: crate::mode_t = 0o4000;
pub const S_ISGID: crate::mode_t = 0o2000;
pub const S_ISVTX: crate::mode_t = 0o1000;
pub const S_ISUID: mode_t = 0o4000;
pub const S_ISGID: mode_t = 0o2000;
pub const S_ISVTX: mode_t = 0o1000;

pub const IF_NAMESIZE: size_t = 16;
pub const IFNAMSIZ: size_t = IF_NAMESIZE;
Expand Down Expand Up @@ -1585,26 +1585,26 @@ pub const O_RDONLY: c_int = 0;
pub const O_WRONLY: c_int = 1;
pub const O_RDWR: c_int = 2;

pub const S_IFIFO: crate::mode_t = 0o1_0000;
pub const S_IFCHR: crate::mode_t = 0o2_0000;
pub const S_IFBLK: crate::mode_t = 0o6_0000;
pub const S_IFDIR: crate::mode_t = 0o4_0000;
pub const S_IFREG: crate::mode_t = 0o10_0000;
pub const S_IFLNK: crate::mode_t = 0o12_0000;
pub const S_IFSOCK: crate::mode_t = 0o14_0000;
pub const S_IFMT: crate::mode_t = 0o17_0000;
pub const S_IRWXU: crate::mode_t = 0o0700;
pub const S_IXUSR: crate::mode_t = 0o0100;
pub const S_IWUSR: crate::mode_t = 0o0200;
pub const S_IRUSR: crate::mode_t = 0o0400;
pub const S_IRWXG: crate::mode_t = 0o0070;
pub const S_IXGRP: crate::mode_t = 0o0010;
pub const S_IWGRP: crate::mode_t = 0o0020;
pub const S_IRGRP: crate::mode_t = 0o0040;
pub const S_IRWXO: crate::mode_t = 0o0007;
pub const S_IXOTH: crate::mode_t = 0o0001;
pub const S_IWOTH: crate::mode_t = 0o0002;
pub const S_IROTH: crate::mode_t = 0o0004;
pub const S_IFIFO: mode_t = 0o1_0000;
pub const S_IFCHR: mode_t = 0o2_0000;
pub const S_IFBLK: mode_t = 0o6_0000;
pub const S_IFDIR: mode_t = 0o4_0000;
pub const S_IFREG: mode_t = 0o10_0000;
pub const S_IFLNK: mode_t = 0o12_0000;
pub const S_IFSOCK: mode_t = 0o14_0000;
pub const S_IFMT: mode_t = 0o17_0000;
pub const S_IRWXU: mode_t = 0o0700;
pub const S_IXUSR: mode_t = 0o0100;
pub const S_IWUSR: mode_t = 0o0200;
pub const S_IRUSR: mode_t = 0o0400;
pub const S_IRWXG: mode_t = 0o0070;
pub const S_IXGRP: mode_t = 0o0010;
pub const S_IWGRP: mode_t = 0o0020;
pub const S_IRGRP: mode_t = 0o0040;
pub const S_IRWXO: mode_t = 0o0007;
pub const S_IXOTH: mode_t = 0o0001;
pub const S_IWOTH: mode_t = 0o0002;
pub const S_IROTH: mode_t = 0o0004;
pub const F_OK: c_int = 0;
pub const R_OK: c_int = 4;
pub const W_OK: c_int = 2;
Expand Down Expand Up @@ -3726,12 +3726,7 @@ extern "C" {
pub fn rewinddir(dirp: *mut crate::DIR);

pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int;
pub fn fchmodat(
dirfd: c_int,
pathname: *const c_char,
mode: crate::mode_t,
flags: c_int,
) -> c_int;
pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int;
pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int;
pub fn fchownat(
dirfd: c_int,
Expand All @@ -3748,7 +3743,7 @@ extern "C" {
newpath: *const c_char,
flags: c_int,
) -> c_int;
pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
pub fn readlinkat(
dirfd: c_int,
pathname: *const c_char,
Expand Down Expand Up @@ -3966,7 +3961,7 @@ extern "C" {
pub fn gmtime(time_p: *const time_t) -> *mut tm;
pub fn localtime(time_p: *const time_t) -> *mut tm;

pub fn mknod(pathname: *const c_char, mode: crate::mode_t, dev: crate::dev_t) -> c_int;
pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int;
pub fn uname(buf: *mut crate::utsname) -> c_int;
pub fn gethostname(name: *mut c_char, len: size_t) -> c_int;
pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent;
Expand Down Expand Up @@ -4086,8 +4081,7 @@ extern "C" {

pub fn fdopendir(fd: c_int) -> *mut crate::DIR;

pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
-> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
pub fn pthread_condattr_getclock(
attr: *const pthread_condattr_t,
clock_id: *mut clockid_t,
Expand Down Expand Up @@ -4214,7 +4208,7 @@ extern "C" {
pub fn setfsuid(uid: crate::uid_t) -> c_int;

// Not available now on Android
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
pub fn if_nameindex() -> *mut if_nameindex;
pub fn if_freenameindex(ptr: *mut if_nameindex);
pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int;
Expand Down
Loading
Loading