repo
stringclasses 1
value | pull_number
int64 237
4.09k
| instance_id
stringlengths 19
20
| issue_numbers
sequencelengths 1
2
| base_commit
stringlengths 40
40
| patch
stringlengths 290
47.4k
| test_patch
stringlengths 196
263k
| problem_statement
stringlengths 18
8.89k
| hints_text
stringlengths 0
6.05k
| created_at
stringlengths 20
20
| version
stringclasses 2
values | environment_setup_commit
stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
rust-lang/libc
| 4,091
|
rust-lang__libc-4091
|
[
"3689"
] |
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs
index c4c7e6544b21b..ce274f2261279 100644
--- a/src/fuchsia/mod.rs
+++ b/src/fuchsia/mod.rs
@@ -382,7 +382,7 @@ s! {
}
pub struct fd_set {
- fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
+ fds_bits: [::c_ulong; FD_SETSIZE as usize / ULONG_SIZE],
}
pub struct tm {
diff --git a/src/lib.rs b/src/lib.rs
index 4f4cedb62f925..8af17cb0cb582 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -46,6 +46,8 @@ cfg_if! {
#[allow(unused_imports)]
use core::clone::Clone;
#[allow(unused_imports)]
+use core::ffi;
+#[allow(unused_imports)]
use core::fmt;
#[allow(unused_imports)]
use core::hash;
diff --git a/src/macros.rs b/src/macros.rs
index ff8afee32281a..2661e0fb13827 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -98,7 +98,7 @@ macro_rules! s_paren {
($(
$(#[$attr:meta])*
pub struct $i:ident ( $($field:tt)* );
- )* ) => ($(
+ )*) => ($(
__item! {
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
#[derive(Copy, Clone)]
diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs
index d404c3e8b52a1..a7ef2a073b7c1 100644
--- a/src/unix/aix/mod.rs
+++ b/src/unix/aix/mod.rs
@@ -60,6 +60,7 @@ pub type posix_spawn_file_actions_t = *mut ::c_char;
pub type iconv_t = *mut ::c_void;
e! {
+ #[repr(u32)]
pub enum uio_rw {
UIO_READ = 0,
UIO_WRITE,
@@ -573,7 +574,7 @@ cfg_if! {
}
impl Eq for __sigaction_sa_union {}
impl ::fmt::Debug for __sigaction_sa_union {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("__sigaction_sa_union")
.field("__su_handler", unsafe { &self.__su_handler })
.field("__su_sigaction", unsafe { &self.__su_sigaction })
@@ -598,7 +599,7 @@ cfg_if! {
}
impl Eq for sigaction {}
impl ::fmt::Debug for sigaction {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("sigaction")
.field("sa_union", &self.sa_union)
.field("sa_mask", &self.sa_mask)
@@ -625,7 +626,7 @@ cfg_if! {
}
impl Eq for __poll_ctl_ext_u {}
impl ::fmt::Debug for __poll_ctl_ext_u {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("__poll_ctl_ext_u")
.field("addr", unsafe { &self.addr })
.field("data32", unsafe { &self.data32 })
@@ -655,7 +656,7 @@ cfg_if! {
}
impl Eq for poll_ctl_ext {}
impl ::fmt::Debug for poll_ctl_ext {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("poll_ctl_ext")
.field("version", &self.version)
.field("command", &self.command)
diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs
index e7f1b670823f8..f8ec9811be617 100644
--- a/src/unix/aix/powerpc64.rs
+++ b/src/unix/aix/powerpc64.rs
@@ -307,7 +307,7 @@ cfg_if! {
}
impl Eq for siginfo_t {}
impl ::fmt::Debug for siginfo_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("siginfo_t")
.field("si_signo", &self.si_signo)
.field("si_errno", &self.si_errno)
@@ -347,7 +347,7 @@ cfg_if! {
}
impl Eq for _kernel_simple_lock {}
impl ::fmt::Debug for _kernel_simple_lock {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("_kernel_simple_lock")
.field("_slock", unsafe { &self._slock })
.field("_slockp", unsafe { &self._slockp })
@@ -410,12 +410,12 @@ cfg_if! {
&& self.f_fnamep == other.f_fnamep
&& self.f_fdata == other.f_fdata
&& self.f_lock == other.f_lock
- && self.f_offset_lock == other.f_offset_lock;
+ && self.f_offset_lock == other.f_offset_lock
}
}
impl Eq for file {}
impl ::fmt::Debug for file {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("file")
.field("f_flag", &self.f_flag)
.field("f_count", &self.f_count)
@@ -466,7 +466,7 @@ cfg_if! {
}
impl Eq for __ld_info_file {}
impl ::fmt::Debug for __ld_info_file {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("__ld_info_file")
.field("_ldinfo_fd", unsafe { &self._ldinfo_fd })
.field("_ldinfo_fp", unsafe { &self._ldinfo_fp })
@@ -498,7 +498,7 @@ cfg_if! {
}
impl Eq for ld_info {}
impl ::fmt::Debug for ld_info {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("ld_info")
.field("ldinfo_next", &self.ldinfo_next)
.field("ldinfo_flags", &self.ldinfo_flags)
@@ -535,7 +535,7 @@ cfg_if! {
}
impl Eq for __pollfd_ext_u {}
impl ::fmt::Debug for __pollfd_ext_u {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("__pollfd_ext_u")
.field("addr", unsafe { &self.addr })
.field("data32", unsafe { &self.data32 })
@@ -563,7 +563,7 @@ cfg_if! {
}
impl Eq for pollfd_ext {}
impl ::fmt::Debug for pollfd_ext {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
f.debug_struct("pollfd_ext")
.field("fd", &self.fd)
.field("events", &self.events)
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 74eb9b45d5d2e..1bf743e1cd7ad 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -1595,7 +1595,7 @@ s_no_extra_traits! {
_os_unfair_lock_opaque: u32,
}
- #[repr(packed(1))]
+ #[repr(packed(1))]
pub struct sockaddr_vm {
pub svm_len: ::c_uchar,
pub svm_family: ::sa_family_t,
@@ -1722,8 +1722,7 @@ cfg_if! {
}
impl Eq for semun {}
impl ::fmt::Debug for semun {
- fn fmt(&self, f: &mut ::fmt::Formatter)
- -> ::fmt::Result {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("semun")
.field("val", unsafe { &self.val })
.finish()
@@ -1775,7 +1774,6 @@ cfg_if! {
&& self.udata == other.udata
}
}
-
impl Eq for kevent {}
impl ::fmt::Debug for kevent {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index b49a83862f292..7e8d4d001c710 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -60,10 +60,10 @@ s! {
pub struct fd_set {
#[cfg(all(target_pointer_width = "64",
any(target_os = "freebsd", target_os = "dragonfly")))]
- fds_bits: [i64; FD_SETSIZE / 64],
+ fds_bits: [i64; FD_SETSIZE as usize / 64],
#[cfg(not(all(target_pointer_width = "64",
any(target_os = "freebsd", target_os = "dragonfly"))))]
- fds_bits: [i32; FD_SETSIZE / 32],
+ fds_bits: [i32; FD_SETSIZE as usize / 32],
}
pub struct tm {
@@ -129,7 +129,7 @@ s_no_extra_traits! {
pub struct sockaddr_un {
pub sun_len: u8,
pub sun_family: sa_family_t,
- pub sun_path: [c_char; 104]
+ pub sun_path: [::c_char; 104]
}
pub struct utsname {
diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs
index 5f57779d3037e..e285d0617ce20 100644
--- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs
+++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs
@@ -81,6 +81,7 @@ cfg_if! {
}
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
+
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0;
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1;
pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 2;
diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs
index 1f4f796f2a94a..aa29267f9db50 100644
--- a/src/unix/linux_like/android/b32/mod.rs
+++ b/src/unix/linux_like/android/b32/mod.rs
@@ -9,6 +9,7 @@ pub type sigset_t = ::c_ulong;
pub type socklen_t = i32;
pub type time64_t = i64;
pub type __u64 = ::c_ulonglong;
+pub type __s64 = ::c_longlong;
s! {
pub struct sigaction {
diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs
index 0d6f32ee3989c..9587770e8cb2c 100644
--- a/src/unix/linux_like/android/b64/aarch64/mod.rs
+++ b/src/unix/linux_like/android/b64/aarch64/mod.rs
@@ -1,6 +1,7 @@
pub type c_char = u8;
pub type wchar_t = u32;
pub type __u64 = ::c_ulonglong;
+pub type __s64 = ::c_longlong;
s! {
pub struct stat {
diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs
index 0251804691fd6..82a3aa62f51a5 100644
--- a/src/unix/linux_like/android/b64/riscv64/mod.rs
+++ b/src/unix/linux_like/android/b64/riscv64/mod.rs
@@ -2,6 +2,7 @@ pub type c_char = i8;
pub type wchar_t = u32;
pub type greg_t = i64;
pub type __u64 = ::c_ulonglong;
+pub type __s64 = ::c_longlong;
s! {
pub struct stat {
diff --git a/src/unix/linux_like/android/b64/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs
index f871fb2cd4a61..57a41a224fe2c 100644
--- a/src/unix/linux_like/android/b64/x86_64/mod.rs
+++ b/src/unix/linux_like/android/b64/x86_64/mod.rs
@@ -2,6 +2,7 @@ pub type c_char = i8;
pub type wchar_t = i32;
pub type greg_t = i64;
pub type __u64 = ::c_ulonglong;
+pub type __s64 = ::c_longlong;
s! {
pub struct stat {
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index 75f8a7877b617..3e30ce5bb17cf 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -514,8 +514,40 @@ s! {
pub ifr6_addr: ::in6_addr,
pub ifr6_prefixlen: u32,
pub ifr6_ifindex: ::c_int,
- }
+ }
+
+ pub struct statx {
+ pub stx_mask: ::__u32,
+ pub stx_blksize: ::__u32,
+ pub stx_attributes: ::__u64,
+ pub stx_nlink: ::__u32,
+ pub stx_uid: ::__u32,
+ pub stx_gid: ::__u32,
+ pub stx_mode: ::__u16,
+ __statx_pad1: [::__u16; 1],
+ pub stx_ino: ::__u64,
+ pub stx_size: ::__u64,
+ pub stx_blocks: ::__u64,
+ pub stx_attributes_mask: ::__u64,
+ pub stx_atime: ::statx_timestamp,
+ pub stx_btime: ::statx_timestamp,
+ pub stx_ctime: ::statx_timestamp,
+ pub stx_mtime: ::statx_timestamp,
+ pub stx_rdev_major: ::__u32,
+ pub stx_rdev_minor: ::__u32,
+ pub stx_dev_major: ::__u32,
+ pub stx_dev_minor: ::__u32,
+ pub stx_mnt_id: ::__u64,
+ pub stx_dio_mem_align: ::__u32,
+ pub stx_dio_offset_align: ::__u32,
+ __statx_pad3: [::__u64; 12],
+ }
+ pub struct statx_timestamp {
+ pub tv_sec: ::__s64,
+ pub tv_nsec: ::__u32,
+ pub __reserved: ::__s32,
+ }
}
s_no_extra_traits! {
@@ -4169,6 +4201,22 @@ extern "C" {
pub fn fgets_unlocked(buf: *mut ::c_char, size: ::c_int, stream: *mut ::FILE) -> *mut ::c_char;
pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int;
+
+ pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
+ pub fn renameat2(
+ olddirfd: ::c_int,
+ oldpath: *const ::c_char,
+ newdirfd: ::c_int,
+ newpath: *const ::c_char,
+ flags: ::c_uint,
+ ) -> ::c_int;
+ pub fn statx(
+ dirfd: ::c_int,
+ pathname: *const c_char,
+ flags: ::c_int,
+ mask: ::c_uint,
+ statxbuf: *mut statx,
+ ) -> ::c_int;
}
cfg_if! {
diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs
index bd943b99940f2..fd4c7868a63b9 100644
--- a/src/unix/linux_like/mod.rs
+++ b/src/unix/linux_like/mod.rs
@@ -85,7 +85,7 @@ s! {
}
pub struct fd_set {
- fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
+ fds_bits: [::c_ulong; FD_SETSIZE as usize / ULONG_SIZE],
}
pub struct tm {
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 0a290b734a3d1..ebbf42d8140e2 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -940,6 +940,7 @@ extern "C" {
pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
pub fn pipe(fds: *mut ::c_int) -> ::c_int;
pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int;
+ pub fn aligned_alloc(alignment: ::size_t, size: ::size_t) -> *mut ::c_void;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "read$UNIX2003"
diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs
index 3b02d93fb3dd7..6ecda27e04711 100644
--- a/src/unix/newlib/mod.rs
+++ b/src/unix/newlib/mod.rs
@@ -183,7 +183,7 @@ s! {
}
pub struct fd_set { // Unverified
- fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
+ fds_bits: [::c_ulong; FD_SETSIZE as usize / ULONG_SIZE],
}
pub struct passwd { // Unverified
diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs
index 7c6eba66eea8d..90478d7aaf660 100644
--- a/src/unix/nto/mod.rs
+++ b/src/unix/nto/mod.rs
@@ -154,7 +154,7 @@ s! {
}
pub struct fd_set {
- fds_bits: [::c_uint; 2 * FD_SETSIZE / ULONG_SIZE],
+ fds_bits: [::c_uint; 2 * FD_SETSIZE as usize / ULONG_SIZE],
}
pub struct tm {
diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs
index 262079e042c5b..402857f9098cd 100644
--- a/src/unix/redox/mod.rs
+++ b/src/unix/redox/mod.rs
@@ -116,7 +116,7 @@ s! {
}
pub struct fd_set {
- fds_bits: [::c_ulong; ::FD_SETSIZE / ULONG_SIZE],
+ fds_bits: [::c_ulong; ::FD_SETSIZE as usize / ULONG_SIZE],
}
pub struct in_addr {
diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs
index a5190416836cd..503edf65663fd 100644
--- a/src/unix/solarish/mod.rs
+++ b/src/unix/solarish/mod.rs
@@ -513,9 +513,9 @@ s_no_extra_traits! {
pub struct fd_set {
#[cfg(target_pointer_width = "64")]
- fds_bits: [i64; FD_SETSIZE / 64],
+ fds_bits: [i64; FD_SETSIZE as usize / 64],
#[cfg(target_pointer_width = "32")]
- fds_bits: [i32; FD_SETSIZE / 32],
+ fds_bits: [i32; FD_SETSIZE as usize / 32],
}
pub struct sockaddr_storage {
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index c4b344f41b028..6b3e6abb166c3 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -2075,7 +2075,7 @@ fn test_android(target: &str) {
"__system_property_wait" => true,
// Added in API level 30, but tests use level 28.
- "mlock2" => true,
+ "memfd_create" | "mlock2" | "renameat2" | "statx" | "statx_timestamp" => true,
// Added in glibc 2.25.
"getentropy" => true,
diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt
index 2c49d75c4466f..06a28efaac820 100644
--- a/libc-test/semver/android.txt
+++ b/libc-test/semver/android.txt
@@ -3469,6 +3469,7 @@ memalign
memchr
memcmp
memcpy
+memfd_create
memmem
memmove
memrchr
@@ -3484,6 +3485,7 @@ mknodat
mkstemp
mktime
mlock
+mlock2
mlockall
mmap
mmap64
@@ -3672,6 +3674,7 @@ remove
removexattr
rename
renameat
+renameat2
res_init
rewind
rewinddir
@@ -3797,6 +3800,8 @@ statfs
statfs64
statvfs
statvfs64
+statx
+statx_timestamp
strcasecmp
strcasestr
strcat
diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt
index 6a18038c48ae3..093dde173137c 100644
--- a/libc-test/semver/unix.txt
+++ b/libc-test/semver/unix.txt
@@ -453,6 +453,7 @@ accept
access
addrinfo
alarm
+aligned_alloc
atexit
atof
atoi
|
Missing function: aligned_alloc
This function is part of the [C standard](https://en.cppreference.com/w/c/memory/aligned_alloc). I don't know the full set of targets that support it.
- Linux: [glibc has it](https://www.gnu.org/software/libc/manual/html_node/Aligned-Memory-Blocks.html), and I found it in [musl](https://git.musl-libc.org/cgit/musl/tree/src/malloc/mallocng/aligned_alloc.c?h=v1.2.2), too (but that uses `malloc` + offset -- no idea how they're making sure that you can `free` the resulting pointer)
- FreeBSD also [seems to have it](https://man.freebsd.org/cgi/man.cgi?query=aligned_alloc&apropos=0&sektion=3&manpath=FreeBSD+9-current&format=html)
- macOS: available since 10.15 according to [this](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92143) (but buggy until today... but that's not libc's concern)
- Solaris seems to [have it](https://docs.oracle.com/cd/E88353_01/html/E37843/aligned-alloc-3c.html), and same for [Illumos](https://illumos.org/man/3C/aligned_alloc) (again, [buggy](https://www.illumos.org/issues/16545)...)
- The function is mentioned [here](https://android.googlesource.com/platform/bionic/+/master/docs/status.md) so I assume (recent enough) Android also has it.
|
2024-11-18T09:42:55Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 4,086
|
rust-lang__libc-4086
|
[
"3190",
"3641"
] |
7c64d5d10c86bb1b19edf2c02bd3965bb4c80343
|
diff --git a/build.rs b/build.rs
index c8ffb7bf92ad2..e1c9b23c4617f 100644
--- a/build.rs
+++ b/build.rs
@@ -132,7 +132,7 @@ fn rustc_version_cmd(is_clippy_driver: bool) -> Output {
cmd.arg("--version");
- let output = cmd.output().ok().expect("Failed to get rustc version");
+ let output = cmd.output().expect("Failed to get rustc version");
if !output.status.success() {
panic!(
@@ -187,20 +187,14 @@ fn rustc_minor_nightly() -> (u32, bool) {
}
fn which_freebsd() -> Option<i32> {
- let output = std::process::Command::new("freebsd-version").output().ok();
- if output.is_none() {
- return None;
- }
- let output = output.unwrap();
+ let output = std::process::Command::new("freebsd-version")
+ .output()
+ .ok()?;
if !output.status.success() {
return None;
}
- let stdout = String::from_utf8(output.stdout).ok();
- if stdout.is_none() {
- return None;
- }
- let stdout = stdout.unwrap();
+ let stdout = String::from_utf8(output.stdout).ok()?;
match &stdout {
s if s.starts_with("10") => Some(10),
@@ -217,24 +211,16 @@ fn emcc_version_code() -> Option<u64> {
let output = std::process::Command::new("emcc")
.arg("-dumpversion")
.output()
- .ok();
- if output.is_none() {
- return None;
- }
- let output = output.unwrap();
+ .ok()?;
if !output.status.success() {
return None;
}
- let stdout = String::from_utf8(output.stdout).ok();
- if stdout.is_none() {
- return None;
- }
- let version = stdout.unwrap();
+ let version = String::from_utf8(output.stdout).ok()?;
// Some Emscripten versions come with `-git` attached, so split the
// version string also on the `-` char.
- let mut pieces = version.trim().split(|c| c == '.' || c == '-');
+ let mut pieces = version.trim().split(['.', '-']);
let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
diff --git a/ci/README.md b/ci/README.md
index b810cd4ac59c0..d97b98acfcd08 100644
--- a/ci/README.md
+++ b/ci/README.md
@@ -161,7 +161,7 @@ about above), and then shut down.
poweroff
1. Exit the post install shell: `exit`
- 1. Back in in the installer choose Reboot
+ 1. Back in the installer choose Reboot
1. If all went well the machine should reboot and show a login prompt. If you
switch to the serial console by choosing View > serial0 in the qemu menu,
you should be logged in as root.
diff --git a/ci/style.sh b/ci/style.sh
index 131632ff21dd4..0684caafaad7d 100755
--- a/ci/style.sh
+++ b/ci/style.sh
@@ -11,7 +11,7 @@ rustfmt -V
cargo fmt --all -- --check
if shellcheck --version ; then
- find . -name '*.sh' -exec shellcheck {} ';'
+ find . -name '*.sh' -print0 | xargs -0 shellcheck
else
echo "shellcheck not found"
exit 1
@@ -29,4 +29,12 @@ for file in libc-test/semver/*.txt; do
echo "Unsorted semver file $file"
exit 1
fi
+
+ duplicates=$(uniq -d "$file")
+ if [ -n "$duplicates" ]; then
+ echo "Semver file $file contains duplicates:"
+ echo "$duplicates"
+
+ exit 1
+ fi
done
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index cd8a67a1b9ec2..74eb9b45d5d2e 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -37,6 +37,8 @@ pub type rusage_info_t = *mut ::c_void;
pub type vm_offset_t = ::uintptr_t;
pub type vm_size_t = ::uintptr_t;
pub type vm_address_t = vm_offset_t;
+pub type quad_t = i64;
+pub type u_quad_t = u64;
pub type posix_spawnattr_t = *mut ::c_void;
pub type posix_spawn_file_actions_t = *mut ::c_void;
@@ -1233,6 +1235,78 @@ s! {
pub iffmid_id: u32,
pub iffmid_str: [::c_char; 1],
}
+
+ pub struct in6_addrlifetime {
+ pub ia6t_expire: time_t,
+ pub ia6t_preferred: time_t,
+ pub ia6t_vltime: u32,
+ pub ia6t_pltime: u32,
+ }
+
+ pub struct in6_ifstat {
+ pub ifs6_in_receive: ::u_quad_t,
+ pub ifs6_in_hdrerr: ::u_quad_t,
+ pub ifs6_in_toobig: ::u_quad_t,
+ pub ifs6_in_noroute: ::u_quad_t,
+ pub ifs6_in_addrerr: ::u_quad_t,
+ pub ifs6_in_protounknown: ::u_quad_t,
+ pub ifs6_in_truncated: ::u_quad_t,
+ pub ifs6_in_discard: ::u_quad_t,
+ pub ifs6_in_deliver: ::u_quad_t,
+ pub ifs6_out_forward: ::u_quad_t,
+ pub ifs6_out_request: ::u_quad_t,
+ pub ifs6_out_discard: ::u_quad_t,
+ pub ifs6_out_fragok: ::u_quad_t,
+ pub ifs6_out_fragfail: ::u_quad_t,
+ pub ifs6_out_fragcreat: ::u_quad_t,
+ pub ifs6_reass_reqd: ::u_quad_t,
+ pub ifs6_reass_ok: ::u_quad_t,
+ pub ifs6_atmfrag_rcvd: ::u_quad_t,
+ pub ifs6_reass_fail: ::u_quad_t,
+ pub ifs6_in_mcast: ::u_quad_t,
+ pub ifs6_out_mcast: ::u_quad_t,
+ pub ifs6_cantfoward_icmp6: ::u_quad_t,
+ pub ifs6_addr_expiry_cnt: ::u_quad_t,
+ pub ifs6_pfx_expiry_cnt: ::u_quad_t,
+ pub ifs6_defrtr_expiry_cnt: ::u_quad_t,
+ }
+
+ pub struct icmp6_ifstat {
+ pub ifs6_in_msg: ::u_quad_t,
+ pub ifs6_in_error: ::u_quad_t,
+ pub ifs6_in_dstunreach: ::u_quad_t,
+ pub ifs6_in_adminprohib: ::u_quad_t,
+ pub ifs6_in_timeexceed: ::u_quad_t,
+ pub ifs6_in_paramprob: ::u_quad_t,
+ pub ifs6_in_pkttoobig: ::u_quad_t,
+ pub ifs6_in_echo: ::u_quad_t,
+ pub ifs6_in_echoreply: ::u_quad_t,
+ pub ifs6_in_routersolicit: ::u_quad_t,
+ pub ifs6_in_routeradvert: ::u_quad_t,
+ pub ifs6_in_neighborsolicit: ::u_quad_t,
+ pub ifs6_in_neighboradvert: ::u_quad_t,
+ pub ifs6_in_redirect: ::u_quad_t,
+ pub ifs6_in_mldquery: ::u_quad_t,
+ pub ifs6_in_mldreport: ::u_quad_t,
+ pub ifs6_in_mlddone: ::u_quad_t,
+ pub ifs6_out_msg: ::u_quad_t,
+ pub ifs6_out_error: ::u_quad_t,
+ pub ifs6_out_dstunreach: ::u_quad_t,
+ pub ifs6_out_adminprohib: ::u_quad_t,
+ pub ifs6_out_timeexceed: ::u_quad_t,
+ pub ifs6_out_paramprob: ::u_quad_t,
+ pub ifs6_out_pkttoobig: ::u_quad_t,
+ pub ifs6_out_echo: ::u_quad_t,
+ pub ifs6_out_echoreply: ::u_quad_t,
+ pub ifs6_out_routersolicit: ::u_quad_t,
+ pub ifs6_out_routeradvert: ::u_quad_t,
+ pub ifs6_out_neighborsolicit: ::u_quad_t,
+ pub ifs6_out_neighboradvert: ::u_quad_t,
+ pub ifs6_out_redirect: ::u_quad_t,
+ pub ifs6_out_mldquery: ::u_quad_t,
+ pub ifs6_out_mldreport: ::u_quad_t,
+ pub ifs6_out_mlddone: ::u_quad_t,
+ }
}
s_no_extra_traits! {
@@ -1576,6 +1650,25 @@ s_no_extra_traits! {
pub ifcu_buf: *mut ::c_char,
pub ifcu_req: *mut ifreq,
}
+
+ pub union __c_anonymous_ifr_ifru6 {
+ pub ifru_addr: ::sockaddr_in6,
+ pub ifru_dstaddr: ::sockaddr_in6,
+ pub ifru_flags: ::c_int,
+ pub ifru_flags6: ::c_int,
+ pub ifru_metrics: ::c_int,
+ pub ifru_intval: ::c_int,
+ pub ifru_data: *mut ::c_char,
+ pub ifru_lifetime: in6_addrlifetime,
+ pub ifru_stat: in6_ifstat,
+ pub ifru_icmp6stat: icmp6_ifstat,
+ pub ifru_scope_id: [u32; SCOPE6_ID_MAX],
+ }
+
+ pub struct in6_ifreq {
+ pub ifr_name: [::c_char; ::IFNAMSIZ],
+ pub ifr_ifru: __c_anonymous_ifr_ifru6,
+ }
}
impl siginfo_t {
@@ -3151,6 +3244,74 @@ cfg_if! {
unsafe { self.ifcu_req.hash(state) };
}
}
+
+ impl PartialEq for __c_anonymous_ifr_ifru6 {
+ fn eq(&self, other: &__c_anonymous_ifr_ifru6) -> bool {
+ unsafe {
+ self.ifru_addr == other.ifru_addr
+ && self.ifru_dstaddr == other.ifru_dstaddr
+ && self.ifru_flags == other.ifru_flags
+ && self.ifru_flags6 == other.ifru_flags6
+ && self.ifru_metrics == other.ifru_metrics
+ && self.ifru_intval == other.ifru_intval
+ && self.ifru_data == other.ifru_data
+ && self.ifru_scope_id
+ .iter()
+ .zip(other.ifru_scope_id.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ }
+
+ impl Eq for __c_anonymous_ifr_ifru6 {}
+
+ impl ::fmt::Debug for __c_anonymous_ifr_ifru6 {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("__c_anonymous_ifr_ifru6")
+ .field("ifru_addr", unsafe { &self.ifru_addr })
+ .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr })
+ .field("ifru_flags", unsafe { &self.ifru_flags })
+ .field("ifru_flags6", unsafe { &self.ifru_flags6 })
+ .field("ifru_metrics", unsafe { &self.ifru_metrics })
+ .field("ifru_intval", unsafe { &self.ifru_intval })
+ .field("ifru_data", unsafe { &self.ifru_data })
+ .field("ifru_scope_id", unsafe { &self.ifru_scope_id })
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for __c_anonymous_ifr_ifru6 {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ unsafe {
+ self.ifru_addr.hash(state);
+ self.ifru_dstaddr.hash(state);
+ self.ifru_flags.hash(state);
+ self.ifru_flags6.hash(state);
+ self.ifru_metrics.hash(state);
+ self.ifru_intval.hash(state);
+ self.ifru_data.hash(state);
+ self.ifru_scope_id.hash(state);
+ }
+ }
+ }
+
+ impl PartialEq for in6_ifreq {
+ fn eq(&self, other: &in6_ifreq) -> bool {
+ self.ifr_name == other.ifr_name
+ && self.ifr_ifru == other.ifr_ifru
+ }
+ }
+
+ impl Eq for in6_ifreq {}
+
+ impl ::fmt::Debug for in6_ifreq {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("in6_ifreq")
+ .field("ifr_name", &self.ifr_name)
+ .field("ifr_ifru", &self.ifr_ifru)
+ .finish()
+ }
+ }
}
}
@@ -4340,6 +4501,8 @@ pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
+pub const SCOPE6_ID_MAX: ::size_t = 16;
+
pub const SHUT_RD: ::c_int = 0;
pub const SHUT_WR: ::c_int = 1;
pub const SHUT_RDWR: ::c_int = 2;
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 1cb8ab4c34845..9b69ccbbb74de 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -4902,6 +4902,12 @@ pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 0x02;
pub const CLOSE_RANGE_CLOEXEC: ::c_uint = 1 << 2;
+pub const KCMP_FILE: ::c_int = 100;
+pub const KCMP_FILEOBJ: ::c_int = 101;
+pub const KCMP_FILES: ::c_int = 102;
+pub const KCMP_SIGHAND: ::c_int = 103;
+pub const KCMP_VM: ::c_int = 104;
+
pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int {
a << 24
}
@@ -5625,6 +5631,14 @@ extern "C" {
argv: *const *const ::c_char,
envp: *const *const ::c_char,
) -> ::c_int;
+
+ pub fn kcmp(
+ pid1: ::pid_t,
+ pid2: ::pid_t,
+ type_: ::c_int,
+ idx1: ::c_ulong,
+ idx2: ::c_ulong,
+ ) -> ::c_int;
}
#[link(name = "memstat")]
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index 2829b249dd0b6..75f8a7877b617 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -2349,9 +2349,11 @@ pub const NF_INET_FORWARD: ::c_int = 2;
pub const NF_INET_LOCAL_OUT: ::c_int = 3;
pub const NF_INET_POST_ROUTING: ::c_int = 4;
pub const NF_INET_NUMHOOKS: ::c_int = 5;
+pub const NF_INET_INGRESS: ::c_int = NF_INET_NUMHOOKS;
pub const NF_NETDEV_INGRESS: ::c_int = 0;
-pub const NF_NETDEV_NUMHOOKS: ::c_int = 1;
+pub const NF_NETDEV_EGRESS: ::c_int = 1;
+pub const NF_NETDEV_NUMHOOKS: ::c_int = 2;
pub const NFPROTO_UNSPEC: ::c_int = 0;
pub const NFPROTO_INET: ::c_int = 1;
@@ -2363,6 +2365,31 @@ pub const NFPROTO_IPV6: ::c_int = 10;
pub const NFPROTO_DECNET: ::c_int = 12;
pub const NFPROTO_NUMPROTO: ::c_int = 13;
+// linux/netfilter_arp.h
+pub const NF_ARP: ::c_int = 0;
+pub const NF_ARP_IN: ::c_int = 0;
+pub const NF_ARP_OUT: ::c_int = 1;
+pub const NF_ARP_FORWARD: ::c_int = 2;
+pub const NF_ARP_NUMHOOKS: ::c_int = 3;
+
+// linux/netfilter_bridge.h
+pub const NF_BR_PRE_ROUTING: ::c_int = 0;
+pub const NF_BR_LOCAL_IN: ::c_int = 1;
+pub const NF_BR_FORWARD: ::c_int = 2;
+pub const NF_BR_LOCAL_OUT: ::c_int = 3;
+pub const NF_BR_POST_ROUTING: ::c_int = 4;
+pub const NF_BR_BROUTING: ::c_int = 5;
+pub const NF_BR_NUMHOOKS: ::c_int = 6;
+
+pub const NF_BR_PRI_FIRST: ::c_int = ::INT_MIN;
+pub const NF_BR_PRI_NAT_DST_BRIDGED: ::c_int = -300;
+pub const NF_BR_PRI_FILTER_BRIDGED: ::c_int = -200;
+pub const NF_BR_PRI_BRNF: ::c_int = 0;
+pub const NF_BR_PRI_NAT_DST_OTHER: ::c_int = 100;
+pub const NF_BR_PRI_FILTER_OTHER: ::c_int = 200;
+pub const NF_BR_PRI_NAT_SRC: ::c_int = 300;
+pub const NF_BR_PRI_LAST: ::c_int = ::INT_MAX;
+
// linux/netfilter_ipv4.h
pub const NF_IP_PRE_ROUTING: ::c_int = 0;
pub const NF_IP_LOCAL_IN: ::c_int = 1;
@@ -2372,6 +2399,7 @@ pub const NF_IP_POST_ROUTING: ::c_int = 4;
pub const NF_IP_NUMHOOKS: ::c_int = 5;
pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN;
+pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
pub const NF_IP_PRI_RAW: ::c_int = -300;
pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225;
@@ -2395,6 +2423,7 @@ pub const NF_IP6_POST_ROUTING: ::c_int = 4;
pub const NF_IP6_NUMHOOKS: ::c_int = 5;
pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN;
+pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
pub const NF_IP6_PRI_RAW: ::c_int = -300;
pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225;
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index aa7213f77ee70..9cc2425fc6b6f 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -28,6 +28,8 @@ pub type Elf32_Half = u16;
pub type Elf32_Word = u32;
pub type Elf32_Off = u32;
pub type Elf32_Addr = u32;
+pub type Elf32_Xword = u64;
+pub type Elf32_Sword = i32;
pub type Elf64_Half = u16;
pub type Elf64_Word = u32;
@@ -35,10 +37,23 @@ pub type Elf64_Off = u64;
pub type Elf64_Addr = u64;
pub type Elf64_Xword = u64;
pub type Elf64_Sxword = i64;
+pub type Elf64_Sword = i32;
pub type Elf32_Section = u16;
pub type Elf64_Section = u16;
+pub type Elf32_Relr = Elf32_Word;
+pub type Elf64_Relr = Elf32_Xword;
+pub type Elf32_Rel = __c_anonymous_elf32_rel;
+pub type Elf64_Rel = __c_anonymous_elf64_rel;
+
+cfg_if! {
+ if #[cfg(not(target_arch = "sparc64"))] {
+ pub type Elf32_Rela = __c_anonymous_elf32_rela;
+ pub type Elf64_Rela = __c_anonymous_elf64_rela;
+ }
+}
+
// linux/can.h
pub type canid_t = u32;
@@ -980,6 +995,24 @@ s! {
}
}
+cfg_if! {
+ if #[cfg(not(target_arch = "sparc64"))] {
+ s!{
+ pub struct __c_anonymous_elf32_rela {
+ pub r_offset: Elf32_Addr,
+ pub r_info: Elf32_Word,
+ pub r_addend: Elf32_Sword,
+ }
+
+ pub struct __c_anonymous_elf64_rela {
+ pub r_offset: Elf64_Addr,
+ pub r_info: Elf64_Xword,
+ pub r_addend: Elf64_Sxword,
+ }
+ }
+ }
+}
+
s_no_extra_traits! {
pub struct sockaddr_nl {
pub nl_family: ::sa_family_t,
@@ -3336,20 +3369,47 @@ pub const NF_INET_FORWARD: ::c_int = 2;
pub const NF_INET_LOCAL_OUT: ::c_int = 3;
pub const NF_INET_POST_ROUTING: ::c_int = 4;
pub const NF_INET_NUMHOOKS: ::c_int = 5;
+pub const NF_INET_INGRESS: ::c_int = NF_INET_NUMHOOKS;
+
+pub const NF_NETDEV_INGRESS: ::c_int = 0;
+pub const NF_NETDEV_EGRESS: ::c_int = 1;
+pub const NF_NETDEV_NUMHOOKS: ::c_int = 2;
// Some NFPROTO are not compatible with musl and are defined in submodules.
pub const NFPROTO_UNSPEC: ::c_int = 0;
+pub const NFPROTO_INET: ::c_int = 1;
pub const NFPROTO_IPV4: ::c_int = 2;
pub const NFPROTO_ARP: ::c_int = 3;
+pub const NFPROTO_NETDEV: ::c_int = 5;
pub const NFPROTO_BRIDGE: ::c_int = 7;
pub const NFPROTO_IPV6: ::c_int = 10;
pub const NFPROTO_DECNET: ::c_int = 12;
pub const NFPROTO_NUMPROTO: ::c_int = 13;
-pub const NFPROTO_INET: ::c_int = 1;
-pub const NFPROTO_NETDEV: ::c_int = 5;
-pub const NF_NETDEV_INGRESS: ::c_int = 0;
-pub const NF_NETDEV_NUMHOOKS: ::c_int = 1;
+// linux/netfilter_arp.h
+pub const NF_ARP: ::c_int = 0;
+pub const NF_ARP_IN: ::c_int = 0;
+pub const NF_ARP_OUT: ::c_int = 1;
+pub const NF_ARP_FORWARD: ::c_int = 2;
+pub const NF_ARP_NUMHOOKS: ::c_int = 3;
+
+// linux/netfilter_bridge.h
+pub const NF_BR_PRE_ROUTING: ::c_int = 0;
+pub const NF_BR_LOCAL_IN: ::c_int = 1;
+pub const NF_BR_FORWARD: ::c_int = 2;
+pub const NF_BR_LOCAL_OUT: ::c_int = 3;
+pub const NF_BR_POST_ROUTING: ::c_int = 4;
+pub const NF_BR_BROUTING: ::c_int = 5;
+pub const NF_BR_NUMHOOKS: ::c_int = 6;
+
+pub const NF_BR_PRI_FIRST: ::c_int = ::INT_MIN;
+pub const NF_BR_PRI_NAT_DST_BRIDGED: ::c_int = -300;
+pub const NF_BR_PRI_FILTER_BRIDGED: ::c_int = -200;
+pub const NF_BR_PRI_BRNF: ::c_int = 0;
+pub const NF_BR_PRI_NAT_DST_OTHER: ::c_int = 100;
+pub const NF_BR_PRI_FILTER_OTHER: ::c_int = 200;
+pub const NF_BR_PRI_NAT_SRC: ::c_int = 300;
+pub const NF_BR_PRI_LAST: ::c_int = ::INT_MAX;
// linux/netfilter_ipv4.h
pub const NF_IP_PRE_ROUTING: ::c_int = 0;
@@ -3360,6 +3420,7 @@ pub const NF_IP_POST_ROUTING: ::c_int = 4;
pub const NF_IP_NUMHOOKS: ::c_int = 5;
pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN;
+pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
pub const NF_IP_PRI_RAW: ::c_int = -300;
pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225;
@@ -3383,6 +3444,7 @@ pub const NF_IP6_POST_ROUTING: ::c_int = 4;
pub const NF_IP6_NUMHOOKS: ::c_int = 5;
pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN;
+pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
pub const NF_IP6_PRI_RAW: ::c_int = -300;
pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225;
@@ -5324,6 +5386,30 @@ f! {
pub fn BPF_JUMP(code: ::__u16, k: ::__u32, jt: ::__u8, jf: ::__u8) -> sock_filter {
sock_filter{code: code, jt: jt, jf: jf, k: k}
}
+
+ pub fn ELF32_R_SYM(val: Elf32_Word) -> Elf32_Word {
+ val >> 8
+ }
+
+ pub fn ELF32_R_TYPE(val: Elf32_Word) -> Elf32_Word {
+ val & 0xff
+ }
+
+ pub fn ELF32_R_INFO(sym: Elf32_Word, t: Elf32_Word) -> Elf32_Word {
+ sym << 8 + t & 0xff
+ }
+
+ pub fn ELF64_R_SYM(val: Elf64_Xword) -> Elf64_Xword {
+ val >> 32
+ }
+
+ pub fn ELF64_R_TYPE(val: Elf64_Xword) -> Elf64_Xword {
+ val & 0xffffffff
+ }
+
+ pub fn ELF64_R_INFO(sym: Elf64_Xword, t: Elf64_Xword) -> Elf64_Xword {
+ sym << 32 + t
+ }
}
safe_f! {
diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs
index 978423b0f2a0d..bfdbb0f0bad59 100644
--- a/src/unix/linux_like/linux/musl/mod.rs
+++ b/src/unix/linux_like/linux/musl/mod.rs
@@ -993,6 +993,13 @@ extern "C" {
actions: *mut ::posix_spawn_file_actions_t,
fd: ::c_int,
) -> ::c_int;
+
+ pub fn getutxent() -> *mut utmpx;
+ pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
+ pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
+ pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
+ pub fn setutxent();
+ pub fn endutxent();
}
// Alias <foo> to <foo>64 to mimic glibc's LFS64 support
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index ce2f75eb312aa..511e166d364ce 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -232,6 +232,7 @@ fn test_apple(target: &str) {
"netinet/ip.h",
"netinet/tcp.h",
"netinet/udp.h",
+ "netinet6/in6_var.h",
"os/clock.h",
"os/lock.h",
"os/signpost.h",
@@ -401,6 +402,7 @@ fn test_apple(target: &str) {
("__darwin_arm_neon_state64", "__v") => true,
("ifreq", "ifr_ifru") => true,
+ ("in6_ifreq", "ifr_ifru") => true,
("ifkpi", "ifk_data") => true,
("ifconf", "ifc_ifcu") => true,
// FIXME: this field has been incorporated into a resized `rmx_filler` array.
@@ -1789,6 +1791,8 @@ fn test_android(target: &str) {
"linux/netfilter/nfnetlink_log.h",
"linux/netfilter/nfnetlink_queue.h",
"linux/netfilter/nf_tables.h",
+ "linux/netfilter_arp.h",
+ "linux/netfilter_bridge.h",
"linux/netfilter_ipv4.h",
"linux/netfilter_ipv6.h",
"linux/netfilter_ipv6/ip6_tables.h",
@@ -1858,6 +1862,7 @@ fn test_android(target: &str) {
// These are tested in the `linux_elf.rs` file.
"Elf64_Phdr" | "Elf32_Phdr" => true,
+
// These are intended to be opaque
"posix_spawn_file_actions_t" => true,
"posix_spawnattr_t" => true,
@@ -2463,7 +2468,7 @@ fn test_freebsd(target: &str) {
true
}
- // Added in in FreeBSD 13.0 (r367776 and r367287)
+ // Added in FreeBSD 13.0 (r367776 and r367287)
"SCM_CREDS2" | "LOCAL_CREDS_PERSISTENT" if Some(13) > freebsd_ver => true,
// Added in FreeBSD 14
@@ -2593,6 +2598,13 @@ fn test_freebsd(target: &str) {
true
}
+ // Added in FreeBSD 14.1
+ "KCMP_FILE" | "KCMP_FILEOBJ" | "KCMP_FILES" | "KCMP_SIGHAND" | "KCMP_VM"
+ if Some(14) > freebsd_ver =>
+ {
+ true
+ }
+
// FIXME: Removed in FreeBSD 15:
"LOCAL_CONNWAIT" if freebsd_ver >= Some(15) => true,
@@ -2713,6 +2725,9 @@ fn test_freebsd(target: &str) {
true
}
+ // Those are introduced in FreeBSD 14.1.
+ "kcmp" => true,
+
_ => false,
}
});
@@ -3591,6 +3606,8 @@ fn test_linux(target: &str) {
"linux/netfilter/nfnetlink_log.h",
"linux/netfilter/nfnetlink_queue.h",
"linux/netfilter/nf_tables.h",
+ "linux/netfilter_arp.h",
+ "linux/netfilter_bridge.h",
"linux/netfilter_ipv4.h",
"linux/netfilter_ipv6.h",
"linux/netfilter_ipv6/ip6_tables.h",
@@ -3678,6 +3695,14 @@ fn test_linux(target: &str) {
});
cfg.skip_type(move |ty| {
+ // FIXME: very recent additions to musl, not yet released.
+ // also apparently some glibc versions
+ if ty == "Elf32_Relr" || ty == "Elf64_Relr" {
+ return true;
+ }
+ if sparc64 && (ty == "Elf32_Rela" || ty == "Elf64_Rela") {
+ return true;
+ }
match ty {
// FIXME: `sighandler_t` type is incorrect, see:
// https://github.com/rust-lang/libc/issues/1359
@@ -4112,9 +4137,15 @@ fn test_linux(target: &str) {
| "MINSIGSTKSZ"
if gnu => true,
- // FIXME: Linux >= 5.16 changed its value:
+ // FIXME: Linux >= 5.10:
+ // https://github.com/torvalds/linux/commit/d25e2e9388eda61b6e298585024ee3355f50c493
+ "NF_INET_INGRESS" if musl => true,
+
+ // FIXME: Linux >= 5.16:
// https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96
- "NF_NETDEV_NUMHOOKS" => true,
+ "NF_NETDEV_EGRESS" if musl || sparc64 => true,
+ // value changed
+ "NF_NETDEV_NUMHOOKS" if musl || sparc64 => true,
// FIXME: requires Linux >= 5.6:
| "RESOLVE_BENEATH"
diff --git a/libc-test/semver/TODO-linux.txt b/libc-test/semver/TODO-linux.txt
index 7855498efafcf..8427cf1ea12c8 100644
--- a/libc-test/semver/TODO-linux.txt
+++ b/libc-test/semver/TODO-linux.txt
@@ -1,4 +1,4 @@
-# The following symbols are not not available in some combinations of
+# The following symbols are not available in some combinations of
# musl/gnu/android and/or architecture.
KEYCTL_CAPABILITIES
KEYCTL_CAPS0_BIG_KEY
diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt
index b679acdcf28ed..2c49d75c4466f 100644
--- a/libc-test/semver/android.txt
+++ b/libc-test/semver/android.txt
@@ -1,6 +1,3 @@
-
-
-
ABS_CNT
ABS_MAX
ADDR_COMPAT_LAYOUT
@@ -1692,8 +1689,29 @@ NFULNL_COPY_PACKET
NFULNL_MSG_CONFIG
NFULNL_MSG_PACKET
NF_ACCEPT
+NF_ARP
+NF_ARP_FORWARD
+NF_ARP_IN
+NF_ARP_NUMHOOKS
+NF_ARP_OUT
+NF_BR_BROUTING
+NF_BR_FORWARD
+NF_BR_LOCAL_IN
+NF_BR_LOCAL_OUT
+NF_BR_NUMHOOKS
+NF_BR_POST_ROUTING
+NF_BR_PRE_ROUTING
+NF_BR_PRI_BRNF
+NF_BR_PRI_FILTER_BRIDGED
+NF_BR_PRI_FILTER_OTHER
+NF_BR_PRI_FIRST
+NF_BR_PRI_LAST
+NF_BR_PRI_NAT_DST_BRIDGED
+NF_BR_PRI_NAT_DST_OTHER
+NF_BR_PRI_NAT_SRC
NF_DROP
NF_INET_FORWARD
+NF_INET_INGRESS
NF_INET_LOCAL_IN
NF_INET_LOCAL_OUT
NF_INET_NUMHOOKS
@@ -1715,6 +1733,7 @@ NF_IP6_PRI_MANGLE
NF_IP6_PRI_NAT_DST
NF_IP6_PRI_NAT_SRC
NF_IP6_PRI_RAW
+NF_IP6_PRI_RAW_BEFORE_DEFRAG
NF_IP6_PRI_SECURITY
NF_IP6_PRI_SELINUX_FIRST
NF_IP6_PRI_SELINUX_LAST
@@ -1735,10 +1754,12 @@ NF_IP_PRI_MANGLE
NF_IP_PRI_NAT_DST
NF_IP_PRI_NAT_SRC
NF_IP_PRI_RAW
+NF_IP_PRI_RAW_BEFORE_DEFRAG
NF_IP_PRI_SECURITY
NF_IP_PRI_SELINUX_FIRST
NF_IP_PRI_SELINUX_LAST
NF_MAX_VERDICT
+NF_NETDEV_EGRESS
NF_NETDEV_INGRESS
NF_NETDEV_NUMHOOKS
NF_QUEUE
diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt
index 36faea40179a5..1b278d66a15b5 100644
--- a/libc-test/semver/apple.txt
+++ b/libc-test/semver/apple.txt
@@ -2003,6 +2003,7 @@ globfree
host_cpu_load_info
host_cpu_load_info_data_t
host_cpu_load_info_t
+icmp6_ifstat
iconv
iconv_close
iconv_open
@@ -2018,6 +2019,9 @@ ifconf
ifkpi
ifreq
image_offset
+in6_addrlifetime
+in6_ifreq
+in6_ifstat
in6_pktinfo
in_pktinfo
initgroups
@@ -2338,6 +2342,7 @@ timeval32
timex
truncate
ttyname_r
+u_quad_t
ucontext_t
unmount
useconds_t
diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt
index ba4902ee780a2..853e4c0043ddc 100644
--- a/libc-test/semver/freebsd.txt
+++ b/libc-test/semver/freebsd.txt
@@ -689,6 +689,11 @@ JAIL_SYS_DISABLE
JAIL_SYS_INHERIT
JAIL_SYS_NEW
JAIL_UPDATE
+KCMP_FILE
+KCMP_FILEOBJ
+KCMP_FILES
+KCMP_SIGHAND
+KCMP_VM
KENV_DUMP
KENV_DUMP_LOADER
KENV_DUMP_STATIC
@@ -2007,6 +2012,7 @@ jail_get
jail_remove
jail_set
jrand48
+kcmp
kevent
key_t
killpg
diff --git a/libc-test/semver/linux-aarch64.txt b/libc-test/semver/linux-aarch64.txt
index 7e2566b6f0b1a..9dceaeccb819b 100644
--- a/libc-test/semver/linux-aarch64.txt
+++ b/libc-test/semver/linux-aarch64.txt
@@ -38,6 +38,8 @@ BPF_W
BPF_X
BPF_XOR
CIBAUD
+Elf32_Rela
+Elf64_Rela
FICLONE
FICLONERANGE
MADV_SOFT_OFFLINE
diff --git a/libc-test/semver/linux-i686.txt b/libc-test/semver/linux-i686.txt
index 73d4ca3554321..d914ca7f9285d 100644
--- a/libc-test/semver/linux-i686.txt
+++ b/libc-test/semver/linux-i686.txt
@@ -15,6 +15,8 @@ EFL
EIP
ES
ESI
+Elf32_Rela
+Elf64_Rela
FS
GS
KEYCTL_CAPABILITIES
diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt
index b307f90353ef0..62b188dac8288 100644
--- a/libc-test/semver/linux-musl.txt
+++ b/libc-test/semver/linux-musl.txt
@@ -78,11 +78,15 @@ copy_file_range
ctermid
dirname
eaccess
+endutxent
euidaccess
explicit_bzero
futimes
getauxval
getloadavg
+getutxent
+getutxid
+getutxline
lio_listio
ntptimeval
open_wmemstream
@@ -94,8 +98,10 @@ prlimit
prlimit64
process_vm_readv
process_vm_writev
+pututxline
pwritev2
pwritev64
reallocarray
+setutxent
tcp_info
timex
diff --git a/libc-test/semver/linux-powerpc64.txt b/libc-test/semver/linux-powerpc64.txt
index 99be508e6bd59..77718d9ce47f0 100644
--- a/libc-test/semver/linux-powerpc64.txt
+++ b/libc-test/semver/linux-powerpc64.txt
@@ -2,6 +2,8 @@ B2500000
B3000000
B3500000
B4000000
+Elf32_Rela
+Elf64_Rela
KEYCTL_CAPABILITIES
KEYCTL_CAPS0_BIG_KEY
KEYCTL_CAPS0_CAPABILITIES
diff --git a/libc-test/semver/linux-riscv64gc.txt b/libc-test/semver/linux-riscv64gc.txt
index 28a115b234638..13f5b85196790 100644
--- a/libc-test/semver/linux-riscv64gc.txt
+++ b/libc-test/semver/linux-riscv64gc.txt
@@ -10,6 +10,8 @@ COMPAT_HWCAP_ISA_F
COMPAT_HWCAP_ISA_I
COMPAT_HWCAP_ISA_M
COMPAT_HWCAP_ISA_V
+Elf32_Rela
+Elf64_Rela
KEYCTL_CAPABILITIES
KEYCTL_CAPS0_BIG_KEY
KEYCTL_CAPS0_CAPABILITIES
diff --git a/libc-test/semver/linux-x86_64.txt b/libc-test/semver/linux-x86_64.txt
index a26f63d6d5a6c..f1ed29b8f299d 100644
--- a/libc-test/semver/linux-x86_64.txt
+++ b/libc-test/semver/linux-x86_64.txt
@@ -41,6 +41,8 @@ CIBAUD
CS
DS
ES
+Elf32_Rela
+Elf64_Rela
FS
GS
MADV_SOFT_OFFLINE
diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt
index 5b0fca57b3e11..f549c977a60ba 100644
--- a/libc-test/semver/linux.txt
+++ b/libc-test/semver/linux.txt
@@ -418,6 +418,12 @@ EL2HLT
EL2NSYNC
EL3HLT
EL3RST
+ELF32_R_INFO
+ELF32_R_SYM
+ELF32_R_TYPE
+ELF64_R_INFO
+ELF64_R_SYM
+ELF64_R_TYPE
ELFCLASS32
ELFCLASS64
ELFCLASSNONE
@@ -697,17 +703,24 @@ Elf32_Ehdr
Elf32_Half
Elf32_Off
Elf32_Phdr
+Elf32_Rel
+Elf32_Relr
Elf32_Section
Elf32_Shdr
+Elf32_Sword
Elf32_Sym
Elf32_Word
+Elf32_Xword
Elf64_Addr
Elf64_Ehdr
Elf64_Half
Elf64_Off
Elf64_Phdr
+Elf64_Rel
+Elf64_Relr
Elf64_Section
Elf64_Shdr
+Elf64_Sword
Elf64_Sxword
Elf64_Sym
Elf64_Word
@@ -1852,8 +1865,29 @@ NFULNL_COPY_PACKET
NFULNL_MSG_CONFIG
NFULNL_MSG_PACKET
NF_ACCEPT
+NF_ARP
+NF_ARP_FORWARD
+NF_ARP_IN
+NF_ARP_NUMHOOKS
+NF_ARP_OUT
+NF_BR_BROUTING
+NF_BR_FORWARD
+NF_BR_LOCAL_IN
+NF_BR_LOCAL_OUT
+NF_BR_NUMHOOKS
+NF_BR_POST_ROUTING
+NF_BR_PRE_ROUTING
+NF_BR_PRI_BRNF
+NF_BR_PRI_FILTER_BRIDGED
+NF_BR_PRI_FILTER_OTHER
+NF_BR_PRI_FIRST
+NF_BR_PRI_LAST
+NF_BR_PRI_NAT_DST_BRIDGED
+NF_BR_PRI_NAT_DST_OTHER
+NF_BR_PRI_NAT_SRC
NF_DROP
NF_INET_FORWARD
+NF_INET_INGRESS
NF_INET_LOCAL_IN
NF_INET_LOCAL_OUT
NF_INET_NUMHOOKS
@@ -1875,6 +1909,7 @@ NF_IP6_PRI_MANGLE
NF_IP6_PRI_NAT_DST
NF_IP6_PRI_NAT_SRC
NF_IP6_PRI_RAW
+NF_IP6_PRI_RAW_BEFORE_DEFRAG
NF_IP6_PRI_SECURITY
NF_IP6_PRI_SELINUX_FIRST
NF_IP6_PRI_SELINUX_LAST
@@ -1895,10 +1930,12 @@ NF_IP_PRI_MANGLE
NF_IP_PRI_NAT_DST
NF_IP_PRI_NAT_SRC
NF_IP_PRI_RAW
+NF_IP_PRI_RAW_BEFORE_DEFRAG
NF_IP_PRI_SECURITY
NF_IP_PRI_SELINUX_FIRST
NF_IP_PRI_SELINUX_LAST
NF_MAX_VERDICT
+NF_NETDEV_EGRESS
NF_QUEUE
NF_REPEAT
NF_STOLEN
|
utmp function family missing on musl
Hello,
functions like getutxent, setutxent, endutxent, struct utmpx, etc. are missing from the musl implementation ( src/unix/linux_like/linux/musl/mod.rs ), even though those functions are implemented in musl (see https://git.musl-libc.org/cgit/musl/tree/include/utmpx.h ).
As reference, see this [commit](https://github.com/rust-lang/libc/commit/98fd3188e7d46db84d321475344f2f82d958b0c7) which added the function for solaris, as well as the man page: https://linux.die.net/man/3/endutxent
Libc-test fails on linux due to Undeclared symbols Elf32_Relr and Elf64_Relr
`cargo test -p libc-test` fails on linux.
I've attached `cargo test -p libc-test`
The libc-test work on windows. For linux and mac, they fail.
On linux rust version = 1.79 nightly.
[libc-test-p_linux_rust_179.txt](https://github.com/rust-lang/libc/files/14820415/libc-test-p_linux_rust_179.txt)
On windows rust version = 1.75 stable.
It ran 753 tests in tests/makedev.rs and all of them passed.
[libc-test-pwindowspass.txt](https://github.com/rust-lang/libc/files/14820416/libc-test-pwindowspass.txt)
|
Why is this trying to change O_LARGEFILE?
@joshtriplett did you mean to ask this in the pull-request?
@Ecordonnier Yes, thank you.
These changes have been merged in, but have not been included in any subsequent releases:
```
diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs
index a4c1f708afd50..d8b2767669309 100644
--- a/src/unix/linux_like/linux/musl/mod.rs
+++ b/src/unix/linux_like/linux/musl/mod.rs
@@ -900,6 +900,13 @@ extern "C" {
pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
+
+ pub fn getutxent() -> *mut utmpx;
+ pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
+ pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
+ pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
+ pub fn setutxent();
+ pub fn endutxent();
}
// Alias <foo> to <foo>64 to mimic glibc's LFS64 support
```
https://github.com/rust-lang/libc/pull/3213/commits/e3caaf6b0ea08ae294e25a861022c256a7535ec4#r1431346483
Is this waiting on version 0.3 (https://github.com/rust-lang/libc/pull/3213#issuecomment-1851732478)?
Yes or is waiting on 0.3 (which was renamed to 1.0, see https://github.com/rust-lang/libc/issues/3248 )
`libc-test` works in recent debian sid. I suggest running in recent Linux, for example, inside Docker
@safinaskar Please share the info on C library that you are using, the Debian OS version info, along with the libc test log.
Generally speaking, the libc tests will only pass on the specific linux release that we use in our docker containers. If you run the test with `run-docker.sh` then they should all pass.
@Amanieu David @devnexen created a PR removing Elf32relr and Elf64relr tests for all systems including linux. Libc -tests worked on mysystem after that.
|
2024-11-17T07:53:53Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
rust-lang/libc
| 4,033
|
rust-lang__libc-4033
|
[
"4031"
] |
3a0b0444d7206aa3feb30297c005597a960d0b33
|
diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs
index 121b5fa06fe7b..62a07f6279030 100644
--- a/src/unix/solarish/illumos.rs
+++ b/src/unix/solarish/illumos.rs
@@ -10,6 +10,19 @@ pub type lgrp_rsrc_t = ::c_int;
pub type lgrp_affinity_t = ::c_int;
s! {
+ pub struct aiocb {
+ pub aio_fildes: ::c_int,
+ pub aio_buf: *mut ::c_void,
+ pub aio_nbytes: ::size_t,
+ pub aio_offset: ::off_t,
+ pub aio_reqprio: ::c_int,
+ pub aio_sigevent: ::sigevent,
+ pub aio_lio_opcode: ::c_int,
+ pub aio_resultp: ::aio_result_t,
+ pub aio_state: ::c_int,
+ pub aio__pad: [::c_int; 1],
+ }
+
pub struct shmid_ds {
pub shm_perm: ::ipc_perm,
pub shm_segsz: ::size_t,
diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs
index a2db25aa1a221..64bedf88b73c9 100644
--- a/src/unix/solarish/mod.rs
+++ b/src/unix/solarish/mod.rs
@@ -420,6 +420,11 @@ s! {
pub portnfy_user: *mut ::c_void,
}
+ pub struct aio_result_t {
+ pub aio_return: ::ssize_t,
+ pub aio_errno: ::c_int,
+ }
+
pub struct exit_status {
e_termination: ::c_short,
e_exit: ::c_short,
@@ -1123,9 +1128,19 @@ pub const SIG_BLOCK: ::c_int = 1;
pub const SIG_UNBLOCK: ::c_int = 2;
pub const SIG_SETMASK: ::c_int = 3;
+pub const AIO_CANCELED: ::c_int = 0;
+pub const AIO_ALLDONE: ::c_int = 1;
+pub const AIO_NOTCANCELED: ::c_int = 2;
+pub const LIO_NOP: ::c_int = 0;
+pub const LIO_READ: ::c_int = 1;
+pub const LIO_WRITE: ::c_int = 2;
+pub const LIO_NOWAIT: ::c_int = 0;
+pub const LIO_WAIT: ::c_int = 1;
+
pub const SIGEV_NONE: ::c_int = 1;
pub const SIGEV_SIGNAL: ::c_int = 2;
pub const SIGEV_THREAD: ::c_int = 3;
+pub const SIGEV_PORT: ::c_int = 4;
pub const CLD_EXITED: ::c_int = 1;
pub const CLD_KILLED: ::c_int = 2;
@@ -3035,6 +3050,30 @@ extern "C" {
pub fn sync();
+ pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
+ pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
+ pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
+ pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
+ pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
+ pub fn aio_suspend(
+ aiocb_list: *const *const aiocb,
+ nitems: ::c_int,
+ timeout: *const ::timespec,
+ ) -> ::c_int;
+ pub fn aio_waitn(
+ aiocb_list: *mut *mut aiocb,
+ nent: ::c_uint,
+ nwait: *mut ::c_uint,
+ timeout: *const ::timespec,
+ ) -> ::c_int;
+ pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
+ pub fn lio_listio(
+ mode: ::c_int,
+ aiocb_list: *const *mut aiocb,
+ nitems: ::c_int,
+ sevp: *mut sigevent,
+ ) -> ::c_int;
+
pub fn __major(version: ::c_int, devnum: ::dev_t) -> ::major_t;
pub fn __minor(version: ::c_int, devnum: ::dev_t) -> ::minor_t;
pub fn __makedev(version: ::c_int, majdev: ::major_t, mindev: ::minor_t) -> ::dev_t;
diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs
index 26bbe38b3e208..2ca6281f495ba 100644
--- a/src/unix/solarish/solaris.rs
+++ b/src/unix/solarish/solaris.rs
@@ -20,6 +20,21 @@ e! {
}
s! {
+ pub struct aiocb {
+ pub aio_fildes: ::c_int,
+ pub aio_buf: *mut ::c_void,
+ pub aio_nbytes: ::size_t,
+ pub aio_offset: ::off_t,
+ pub aio_reqprio: ::c_int,
+ pub aio_sigevent: ::sigevent,
+ pub aio_lio_opcode: ::c_int,
+ pub aio_resultp: ::aio_result_t,
+ pub aio_state: ::c_char,
+ pub aio_returned: ::c_char,
+ pub aio__pad1: [::c_char; 2],
+ pub aio_flags: ::c_int,
+ }
+
pub struct shmid_ds {
pub shm_perm: ::ipc_perm,
pub shm_segsz: ::size_t,
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 48f952f9f7c83..29763626b34d3 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -786,6 +786,7 @@ fn test_solarish(target: &str) {
headers! {
cfg:
+ "aio.h",
"ctype.h",
"dirent.h",
"dlfcn.h",
@@ -948,6 +949,11 @@ fn test_solarish(target: &str) {
}
});
+ cfg.skip_field_type(move |struct_, field| {
+ // aio_buf is "volatile void*"
+ struct_ == "aiocb" && field == "aio_buf"
+ });
+
cfg.skip_field(move |s, field| {
match s {
// C99 sizing on this is tough
@@ -1026,6 +1032,12 @@ fn test_solarish(target: &str) {
// excluded from the tests.
"getifaddrs" if is_illumos => true,
+ // FIXME: Our API is unsound. The Rust API allows aliasing
+ // pointers, but the C API requires pointers not to alias.
+ // We should probably be at least using `&`/`&mut` here, see:
+ // https://github.com/gnzlbg/ctest/issues/68
+ "lio_listio" => true,
+
_ => false,
}
});
diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt
index a17ec146bb456..2dcebd06e3399 100644
--- a/libc-test/semver/solarish.txt
+++ b/libc-test/semver/solarish.txt
@@ -1,3 +1,6 @@
+AIO_ALLDONE
+AIO_CANCELED
+AIO_NOTCANCELED
IPV6_DONTFRAG
IPV6_PKTINFO
IPV6_RECVTCLASS
@@ -6,12 +9,29 @@ IP_DONTFRAG
IP_PKTINFO
IP_TOS
IP_TTL
+LIO_NOP
+LIO_NOWAIT
+LIO_READ
+LIO_WAIT
+LIO_WRITE
PIPE_BUF
+SIGEV_PORT
+aio_cancel
+aio_error
+aio_fsync
+aio_read
+aio_result_t
+aio_return
+aio_suspend
+aio_waitn
+aio_write
+aiocb
arc4random
arc4random_buf
arc4random_uniform
bind
in6_pktinfo
in_pktinfo
+lio_listio
recvmsg
sendmsg
|
API request: AIO methods for illumos & solaris
I would like:
* aiocb
* aio_read
* aio_write
* aio_fsync
* aio_error
* aio_return
* aio_cancel
* SIGEV_PORT
... for illumos & solaris.
|
2024-11-13T13:00:37Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,966
|
rust-lang__libc-3966
|
[
"3688"
] |
42d1000bc82fc608749f9df19f3d699d2b548ed6
|
diff --git a/README.md b/README.md
index 395b94ce0c8f3..3d5b5ec583457 100644
--- a/README.md
+++ b/README.md
@@ -11,10 +11,14 @@ This crate exports all underlying platform types, functions, and constants under
the crate root, so all items are accessible as `libc::foo`. The types and values
of all the exported APIs match the platform that libc is compiled for.
+Windows API bindings are not included in this crate. If you are looking for WinAPI
+bindings, consider using crates like [windows-sys].
+
More detailed information about the design of this library can be found in its
[associated RFC][rfc].
[rfc]: https://github.com/rust-lang/rfcs/blob/HEAD/text/1291-promote-libc.md
+[windows-sys]: https://docs.rs/windows-sys
## v0.3 Roadmap
diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs
index 1dc607496a2ad..11a16aa7afa41 100644
--- a/src/unix/linux_like/emscripten/mod.rs
+++ b/src/unix/linux_like/emscripten/mod.rs
@@ -1776,6 +1776,21 @@ extern "C" {
) -> ::c_int;
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
+
+ pub fn getpwnam_r(
+ name: *const ::c_char,
+ pwd: *mut passwd,
+ buf: *mut ::c_char,
+ buflen: ::size_t,
+ result: *mut *mut passwd,
+ ) -> ::c_int;
+ pub fn getpwuid_r(
+ uid: ::uid_t,
+ pwd: *mut passwd,
+ buf: *mut ::c_char,
+ buflen: ::size_t,
+ result: *mut *mut passwd,
+ ) -> ::c_int;
}
// Alias <foo> to <foo>64 to mimic glibc's LFS64 support
diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
index 75d150c90d58a..7fd7fb190ca9d 100644
--- a/src/unix/linux_like/linux/gnu/mod.rs
+++ b/src/unix/linux_like/linux/gnu/mod.rs
@@ -454,6 +454,55 @@ s! {
pub aio_flags: ::__u32,
pub aio_resfd: ::__u32,
}
+
+ // netinet/tcp.h
+
+ pub struct tcp_info {
+ pub tcpi_state: u8,
+ pub tcpi_ca_state: u8,
+ pub tcpi_retransmits: u8,
+ pub tcpi_probes: u8,
+ pub tcpi_backoff: u8,
+ pub tcpi_options: u8,
+ /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`.
+ /// Each is 4 bits.
+ pub tcpi_snd_rcv_wscale: u8,
+ pub tcpi_rto: u32,
+ pub tcpi_ato: u32,
+ pub tcpi_snd_mss: u32,
+ pub tcpi_rcv_mss: u32,
+ pub tcpi_unacked: u32,
+ pub tcpi_sacked: u32,
+ pub tcpi_lost: u32,
+ pub tcpi_retrans: u32,
+ pub tcpi_fackets: u32,
+ pub tcpi_last_data_sent: u32,
+ pub tcpi_last_ack_sent: u32,
+ pub tcpi_last_data_recv: u32,
+ pub tcpi_last_ack_recv: u32,
+ pub tcpi_pmtu: u32,
+ pub tcpi_rcv_ssthresh: u32,
+ pub tcpi_rtt: u32,
+ pub tcpi_rttvar: u32,
+ pub tcpi_snd_ssthresh: u32,
+ pub tcpi_snd_cwnd: u32,
+ pub tcpi_advmss: u32,
+ pub tcpi_reordering: u32,
+ pub tcpi_rcv_rtt: u32,
+ pub tcpi_rcv_space: u32,
+ pub tcpi_total_retrans: u32,
+ }
+
+ pub struct fanotify_event_info_pidfd {
+ pub hdr: ::fanotify_event_info_header,
+ pub pidfd: ::__s32,
+ }
+
+ pub struct fanotify_event_info_error {
+ pub hdr: ::fanotify_event_info_header,
+ pub error: ::__s32,
+ pub error_count: ::__u32,
+ }
}
impl siginfo_t {
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index a7815ddfc3c14..3ca4446e66ef1 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -16,6 +16,7 @@ pub type loff_t = ::c_longlong;
pub type pthread_key_t = ::c_uint;
pub type pthread_once_t = ::c_int;
pub type pthread_spinlock_t = ::c_int;
+pub type __kernel_fsid_t = __c_anonymous__kernel_fsid_t;
pub type __u8 = ::c_uchar;
pub type __u16 = ::c_ushort;
@@ -548,6 +549,20 @@ s! {
pub sh_entsize: Elf64_Xword,
}
+ pub struct __c_anonymous_elf32_rel {
+ pub r_offset: Elf32_Addr,
+ pub r_info: Elf32_Word,
+ }
+
+ pub struct __c_anonymous_elf64_rel {
+ pub r_offset: Elf64_Addr,
+ pub r_info: Elf64_Xword,
+ }
+
+ pub struct __c_anonymous__kernel_fsid_t {
+ pub val: [::c_int; 2],
+ }
+
pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
@@ -615,6 +630,18 @@ s! {
pub response: __u32,
}
+ pub struct fanotify_event_info_header {
+ pub info_type: __u8,
+ pub pad: __u8,
+ pub len: __u16,
+ }
+
+ pub struct fanotify_event_info_fid {
+ pub hdr: fanotify_event_info_header,
+ pub fsid: ::__kernel_fsid_t,
+ pub handle: [::c_uchar; 0],
+ }
+
pub struct sockaddr_vm {
pub svm_family: ::sa_family_t,
pub svm_reserved1: ::c_ushort,
diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs
index a4c8f79c35cad..d102d5de2cfed 100644
--- a/src/unix/linux_like/linux/musl/mod.rs
+++ b/src/unix/linux_like/linux/musl/mod.rs
@@ -348,6 +348,73 @@ s! {
pub len: ::__u32,
pub options: ::__u32,
}
+
+ // netinet/tcp.h
+
+ pub struct tcp_info {
+ pub tcpi_state: u8,
+ pub tcpi_ca_state: u8,
+ pub tcpi_retransmits: u8,
+ pub tcpi_probes: u8,
+ pub tcpi_backoff: u8,
+ pub tcpi_options: u8,
+ /*
+ * FIXME(musl): when musl headers are more up to date
+ /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`.
+ /// Each is 4 bits.
+ pub tcpi_snd_rcv_wscale: u8,
+ /// This contains the bitfields `tcpi_delivery_rate_app_limited` (1 bit) and
+ /// `tcpi_fastopen_client_fail` (2 bits).
+ pub tcpi_delivery_fastopen_bitfields: u8,
+ */
+ pub tcpi_rto: u32,
+ pub tcpi_ato: u32,
+ pub tcpi_snd_mss: u32,
+ pub tcpi_rcv_mss: u32,
+ pub tcpi_unacked: u32,
+ pub tcpi_sacked: u32,
+ pub tcpi_lost: u32,
+ pub tcpi_retrans: u32,
+ pub tcpi_fackets: u32,
+ pub tcpi_last_data_sent: u32,
+ pub tcpi_last_ack_sent: u32,
+ pub tcpi_last_data_recv: u32,
+ pub tcpi_last_ack_recv: u32,
+ pub tcpi_pmtu: u32,
+ pub tcpi_rcv_ssthresh: u32,
+ pub tcpi_rtt: u32,
+ pub tcpi_rttvar: u32,
+ pub tcpi_snd_ssthresh: u32,
+ pub tcpi_snd_cwnd: u32,
+ pub tcpi_advmss: u32,
+ pub tcpi_reordering: u32,
+ pub tcpi_rcv_rtt: u32,
+ pub tcpi_rcv_space: u32,
+ pub tcpi_total_retrans: u32,
+ pub tcpi_pacing_rate: u64,
+ pub tcpi_max_pacing_rate: u64,
+ pub tcpi_bytes_acked: u64,
+ pub tcpi_bytes_received: u64,
+ pub tcpi_segs_out: u32,
+ pub tcpi_segs_in: u32,
+ pub tcpi_notsent_bytes: u32,
+ pub tcpi_min_rtt: u32,
+ pub tcpi_data_segs_in: u32,
+ pub tcpi_data_segs_out: u32,
+ pub tcpi_delivery_rate: u64,
+ pub tcpi_busy_time: u64,
+ pub tcpi_rwnd_limited: u64,
+ pub tcpi_sndbuf_limited: u64,
+ pub tcpi_delivered: u32,
+ pub tcpi_delivered_ce: u32,
+ pub tcpi_bytes_sent: u64,
+ pub tcpi_bytes_retrans: u64,
+ pub tcpi_dsack_dups: u32,
+ pub tcpi_reord_seen: u32,
+ // FIXME(musl): to uncomment once CI musl is updated
+ //pub tcpi_rcv_ooopack: u32,
+ //pub tcpi_snd_wnd: u32,
+ }
}
s_no_extra_traits! {
diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs
index 5036f458067b6..ac092a372b576 100644
--- a/src/unix/redox/mod.rs
+++ b/src/unix/redox/mod.rs
@@ -22,7 +22,7 @@ pub type clockid_t = ::c_int;
pub type dev_t = ::c_long;
pub type fsblkcnt_t = ::c_ulong;
pub type fsfilcnt_t = ::c_ulong;
-pub type ino_t = ::c_ulong;
+pub type ino_t = ::c_ulonglong;
pub type mode_t = ::c_int;
pub type nfds_t = ::c_ulong;
pub type nlink_t = ::c_ulong;
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index ca1301320b211..fb779daecc123 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -3746,6 +3746,9 @@ fn test_linux(target: &str) {
if musl && ty == "fanout_args" {
return true;
}
+ if sparc64 && ty == "fanotify_event_info_error" {
+ return true;
+ }
match ty {
// These cannot be tested when "resolv.h" is included and are tested
@@ -4480,7 +4483,21 @@ fn test_linux(target: &str) {
// the `ifc_ifcu` field is an anonymous union
(struct_ == "ifconf" && field == "ifc_ifcu") ||
// glibc uses a single array `uregs` instead of individual fields.
- (struct_ == "user_regs" && arm)
+ (struct_ == "user_regs" && arm) ||
+ // the `ifr_ifrn` field is an anonymous union
+ (struct_ == "iwreq" && field == "ifr_ifrn") ||
+ // the `key` field is a zero-sized array
+ (struct_ == "iw_encode_ext" && field == "key") ||
+ // the `tcpi_snd_rcv_wscale` map two bitfield fields stored in a u8
+ (struct_ == "tcp_info" && field == "tcpi_snd_rcv_wscale") ||
+ // the `tcpi_delivery_rate_app_limited` field is a bitfield on musl
+ (musl && struct_ == "tcp_info" && field == "tcpi_delivery_rate_app_limited") ||
+ // the `tcpi_fast_open_client_fail` field is a bitfield on musl
+ (musl && struct_ == "tcp_info" && field == "tcpi_fast_open_client_fail") ||
+ // either fsid_t or int[2] type
+ (struct_ == "fanotify_event_info_fid" && field == "fsid") ||
+ // `handle` is a VLA
+ (struct_ == "fanotify_event_info_fid" && field == "handle")
});
cfg.skip_roundtrip(move |s| match s {
diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt
index 6b1df1aab4c7f..d14abae402367 100644
--- a/libc-test/semver/emscripten.txt
+++ b/libc-test/semver/emscripten.txt
@@ -1,2 +1,4 @@
getentropy
posix_fallocate64
+getpwnam_r
+getpwuid_r
diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt
index ce4f85484eee0..bca6e4fd18ed7 100644
--- a/libc-test/semver/linux-gnu.txt
+++ b/libc-test/semver/linux-gnu.txt
@@ -628,12 +628,15 @@ dlinfo
dlmopen
endutxent
explicit_bzero
+fanotify_event_info_error
+fanotify_event_info_header
+fanotify_event_info_pidfd
+fgetgrent_r
fgetspent_r
futimes
getauxval
getentropy
getgrent_r
-fgetgrent_r
getloadavg
getpt
getpwent_r
@@ -712,3 +715,4 @@ putgrent
execveat
close_range
epoll_pwait2
+tcp_info
diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt
index 5a48357cb79e5..bb8dbb2f9834e 100644
--- a/libc-test/semver/linux-musl.txt
+++ b/libc-test/semver/linux-musl.txt
@@ -80,6 +80,7 @@ process_vm_writev
pwritev2
pwritev64
reallocarray
+tcp_info
timex
euidaccess
eaccess
diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt
index ebbe04d1b7262..d0b966f4f1085 100644
--- a/libc-test/semver/linux.txt
+++ b/libc-test/semver/linux.txt
@@ -3497,6 +3497,7 @@ execvpe
faccessat
fallocate
fallocate64
+fanotify_event_info_fid
fanotify_event_metadata
fanotify_init
fanotify_mark
|
Add struct `fanotify_event_info_fid`
Host triplet: `x86_64-unknown-linux-gnu`
API struct is as follows:
```c
struct fanotify_event_info_fid {
struct fanotify_event_info_header hdr;
__kernel_fsid_t fsid;
unsigned char file_handle[0];
};
```
Man page for more info: https://man7.org/linux/man-pages/man7/fanotify.7.html
Source link: https://github.com/torvalds/linux/blob/dccb07f2914cdab2ac3a5b6c98406f765acab803/include/uapi/linux/fanotify.h#L166
|
2024-10-15T01:50:55Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,952
|
rust-lang__libc-3952
|
[
"3947"
] |
b9e8477fa7c71408bdbc1eed9821af0783f97bdb
|
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 47b4bd36e6d02..3224ac8fef6e9 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -3843,6 +3843,7 @@ pub const TCP_INFO: ::c_int = 32;
pub const TCP_CONGESTION: ::c_int = 64;
pub const TCP_CCALGOOPT: ::c_int = 65;
pub const TCP_MAXUNACKTIME: ::c_int = 68;
+#[deprecated(since = "0.2.160", note = "Removed in FreeBSD 15")]
pub const TCP_MAXPEAKRATE: ::c_int = 69;
pub const TCP_IDLE_REDUCE: ::c_int = 70;
pub const TCP_REMOTE_UDP_ENCAPS_PORT: ::c_int = 71;
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 75dcd14fc83be..b6472b4ea56a8 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -2338,6 +2338,9 @@ fn test_freebsd(target: &str) {
// base system anyway.
"CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "USER_MAXID" => true,
+ // Deprecated and removed in FreeBSD 15. It was never actually implemented.
+ "TCP_MAXPEAKRATE" => true,
+
// FIXME: This is deprecated - remove in a couple of releases.
// This was removed in FreeBSD 14 (git 1b4701fe1e8) and never
// should've been used anywhere anyway.
@@ -2364,6 +2367,10 @@ fn test_freebsd(target: &str) {
| "PWAIT" | "PLOCK" | "PPAUSE" | "PRI_MIN_TIMESHARE" | "PUSER" | "PI_AV" | "PI_NET"
| "PI_DISK" | "PI_TTY" | "PI_DULL" | "PI_SOFT" => true,
+ // This constant changed in FreeBSD 15 (git 3458bbd397783). It was never intended to
+ // be stable, and probably shouldn't be bound by libc at all.
+ "RLIM_NLIMITS" => true,
+
// This symbol changed in FreeBSD 14 (git 051e7d78b03), but the new
// version should be safe to use on older releases.
"IFCAP_CANTCHANGE" => true,
@@ -2494,7 +2501,6 @@ fn test_freebsd(target: &str) {
// Flags introduced in FreeBSD 14.
"TCP_MAXUNACKTIME"
- | "TCP_MAXPEAKRATE"
| "TCP_IDLE_REDUCE"
| "TCP_REMOTE_UDP_ENCAPS_PORT"
| "TCP_DELACK"
|
CI fails on FreeBSD 15 for TCP_MAXPEAKRATE
CI is currently failing on FreeBSD 15 because TCP_MAXPEAKRATE is unknown. That's because it was recently removed by this commit:
https://github.com/freebsd/freebsd-src/commit/87fbd9fc7fc5f8d79fe5e3dcd13ad02b11a67ef0 . That, and other constants removed by the same commit, should be removed from libc's main branch and deprecated in the libc-0.2 branch.
|
2024-09-29T19:56:41Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,950
|
rust-lang__libc-3950
|
[
"3947"
] |
09d7aa0d84f9b87d1a8bcb96dc5727282084397d
|
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 3cf1fc1aeeef3..e7239fd965e07 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -3779,7 +3779,6 @@ pub const TCP_INFO: ::c_int = 32;
pub const TCP_CONGESTION: ::c_int = 64;
pub const TCP_CCALGOOPT: ::c_int = 65;
pub const TCP_MAXUNACKTIME: ::c_int = 68;
-pub const TCP_MAXPEAKRATE: ::c_int = 69;
pub const TCP_IDLE_REDUCE: ::c_int = 70;
pub const TCP_REMOTE_UDP_ENCAPS_PORT: ::c_int = 71;
pub const TCP_DELACK: ::c_int = 72;
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 938294717eee3..743f9f28404db 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -2306,6 +2306,10 @@ fn test_freebsd(target: &str) {
| "PWAIT" | "PLOCK" | "PPAUSE" | "PRI_MIN_TIMESHARE" | "PUSER" | "PI_AV" | "PI_NET"
| "PI_DISK" | "PI_TTY" | "PI_DULL" | "PI_SOFT" => true,
+ // This constant changed in FreeBSD 15 (git 3458bbd397783). It was never intended to
+ // be stable, and probably shouldn't be bound by libc at all.
+ "RLIM_NLIMITS" => true,
+
// This symbol changed in FreeBSD 14 (git 051e7d78b03), but the new
// version should be safe to use on older releases.
"IFCAP_CANTCHANGE" => true,
@@ -2436,7 +2440,6 @@ fn test_freebsd(target: &str) {
// Flags introduced in FreeBSD 14.
"TCP_MAXUNACKTIME"
- | "TCP_MAXPEAKRATE"
| "TCP_IDLE_REDUCE"
| "TCP_REMOTE_UDP_ENCAPS_PORT"
| "TCP_DELACK"
diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt
index 933fea0e63e94..70484bbbb9579 100644
--- a/libc-test/semver/freebsd.txt
+++ b/libc-test/semver/freebsd.txt
@@ -1494,7 +1494,6 @@ TCP_KEEPIDLE
TCP_KEEPINIT
TCP_KEEPINTVL
TCP_LOG_LIMIT
-TCP_MAXPEAKRATE
TCP_MAXSEG
TCP_MAXUNACKTIME
TCP_MD5SIG
|
CI fails on FreeBSD 15 for TCP_MAXPEAKRATE
CI is currently failing on FreeBSD 15 because TCP_MAXPEAKRATE is unknown. That's because it was recently removed by this commit:
https://github.com/freebsd/freebsd-src/commit/87fbd9fc7fc5f8d79fe5e3dcd13ad02b11a67ef0 . That, and other constants removed by the same commit, should be removed from libc's main branch and deprecated in the libc-0.2 branch.
|
2024-09-29T18:50:20Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,934
|
rust-lang__libc-3934
|
[
"3748"
] |
ffb7f0c05718643d06bc20b971cedf20d6928d93
|
diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs
index a73e85315971f..3a4ce49c5c217 100644
--- a/src/unix/newlib/espidf/mod.rs
+++ b/src/unix/newlib/espidf/mod.rs
@@ -109,6 +109,8 @@ extern "C" {
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
+ pub fn gethostname(name: *mut ::c_char, namelen: ::ssize_t);
+
#[link_name = "lwip_sendmsg"]
pub fn sendmsg(s: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t;
#[link_name = "lwip_recvmsg"]
|
diff --git a/libc-test/semver/espidf.txt b/libc-test/semver/espidf.txt
new file mode 100644
index 0000000000000..74f0d0cb5266d
--- /dev/null
+++ b/libc-test/semver/espidf.txt
@@ -0,0 +1,49 @@
+AF_INET6
+AF_UNIX
+FIONBIO
+MSG_CTRUNC
+MSG_DONTROUTE
+MSG_DONTWAIT
+MSG_EOR
+MSG_MORE
+MSG_NOSIGNAL
+MSG_OOB
+MSG_PEEK
+MSG_TRUNC
+MSG_WAITALL
+NSIG
+POLLERR
+POLLHUP
+POLLIN
+POLLOUT
+POLLPRI
+POLLRDBAND
+POLLRDNORM
+POLLWRBAND
+POLLWRNORM
+PTHREAD_STACK_MIN
+SIGABRT
+SIGFPE
+SIGHUP
+SIGILL
+SIGINT
+SIGQUIT
+SIGSEGV
+SIGTERM
+SOL_SOCKET
+cmsghdr
+dirent
+eventfd
+gethostname
+getrandom
+msghdr
+pthread_create
+recvmsg
+sendmsg
+sigset_t
+sockaddr
+sockaddr_in
+sockaddr_in6
+sockaddr_storage
+sockaddr_un
+stat
|
Hostname on xtensa esp-idf esp32s3
Hi,
I need to use hostname_max and the function gethostname for xtensa-esp32s3-espidf but they're not supported for this target.
Can anyone give me any suggestion or help?
Thanks
|
PRs are welcome here! Take a look at https://github.com/rust-lang/libc/blob/1ffe0bde929a43ce3d25a8f08b9f95bde8d3e5d8/CONTRIBUTING.md, it should be pretty easy to add the API on those platforms.
I'm interested in picking this up. As far as I can tell, `libc` doesn't currently support that target - support for it in rust was merged as Tier 3 here: https://github.com/rust-lang/rust/pull/126380/. Is there a guide/policy for adding target support to the `libc` crate?
There is no written guide for this target specifically that i am aware off. Though the target ( and all other `-espidf` targets ) are using a version of `newlib` that is directly integrated in the underlying esp-idf system. Depending on the version of the `esp chip` there are parts of this newlib library directly inside the ROM.
[Here](https://github.com/espressif/esp-idf/tree/v5.2.2/components/newlib) you can find the in tree version of newlib that is used in ESP_IDF version 5.2.2.
What actually lives inside the ROM's is tracked inside this [repository](https://github.com/espressif/newlib-esp32)
We have one [outstanding](https://github.com/rust-lang/libc/pull/3920) PR that does a bit of cleanup inside libc with respect to correct constants. There you see for example how the rust libc site and the esp_idf site can be checked against each other.
If you have any target specific questions all the maintainers are also available in our `esp-rs` matrix channel found [here](https://matrix.to/#/#esp-rs:matrix.org)
|
2024-09-18T22:55:32Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
rust-lang/libc
| 3,885
|
rust-lang__libc-3885
|
[
"3760"
] |
5431bdb756c560b21bce18ea7dff72a2aad9975c
|
diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs
index 1a93c39fd3a0a..c99ac476e5c82 100644
--- a/src/unix/linux_like/linux/musl/mod.rs
+++ b/src/unix/linux_like/linux/musl/mod.rs
@@ -667,6 +667,12 @@ pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
pub const PTRACE_GETSIGMASK: ::c_uint = 0x420a;
pub const PTRACE_SETSIGMASK: ::c_uint = 0x420b;
+pub const RWF_HIPRI: ::c_int = 0x00000001;
+pub const RWF_DSYNC: ::c_int = 0x00000002;
+pub const RWF_SYNC: ::c_int = 0x00000004;
+pub const RWF_NOWAIT: ::c_int = 0x00000008;
+pub const RWF_APPEND: ::c_int = 0x00000010;
+
pub const AF_IB: ::c_int = 27;
pub const AF_MPLS: ::c_int = 28;
pub const AF_NFC: ::c_int = 39;
@@ -857,6 +863,20 @@ extern "C" {
dirfd: ::c_int,
path: *const ::c_char,
) -> ::c_int;
+ pub fn preadv2(
+ fd: ::c_int,
+ iov: *const ::iovec,
+ iovcnt: ::c_int,
+ offset: ::off_t,
+ flags: ::c_int,
+ ) -> ::ssize_t;
+ pub fn pwritev2(
+ fd: ::c_int,
+ iov: *const ::iovec,
+ iovcnt: ::c_int,
+ offset: ::off_t,
+ flags: ::c_int,
+ ) -> ::ssize_t;
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
// Added in `musl` 1.1.20
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 9560e07c8cf7e..b9df07b523aed 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -4311,6 +4311,9 @@ fn test_linux(target: &str) {
// FIXME: function pointers changed since Ubuntu 23.10
"strtol" | "strtoll" | "strtoul" | "strtoull" | "fscanf" | "scanf" | "sscanf" => true,
+ // Added in musl 1.2.5
+ "preadv2" | "pwritev2" if musl => true,
+
_ => false,
}
});
diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt
index f6e293aa9b7fc..5c233c1f206e1 100644
--- a/libc-test/semver/linux-musl.txt
+++ b/libc-test/semver/linux-musl.txt
@@ -23,6 +23,11 @@ PF_XDP
PIDFD_NONBLOCK
PR_SET_VMA
PR_SET_VMA_ANON_NAME
+RWF_APPEND
+RWF_DSYNC
+RWF_HIPRI
+RWF_NOWAIT
+RWF_SYNC
SOL_XDP
XDP_SHARED_UMEM
XDP_COPY
@@ -75,12 +80,14 @@ getutxline
lio_listio
ntptimeval
open_wmemstream
+preadv2
preadv64
prlimit
prlimit64
process_vm_readv
process_vm_writev
pututxline
+pwritev2
pwritev64
reallocarray
setutxent
|
preadv2 is not supported on musl libc
The preadv2 function is present on -gnu target, however when compiling on -musl target, which is surprising.
The jobserver-rs would like to use it to optimize it's performance rust-lang/jobserver-rs#90 (the try_acquire optimization has shipped once but reverted, so I opened another PR to use raw syscall directly).
FYI, my motivation is to that this API is used in cc-rs to improve performance.
|
2024-08-29T10:34:24Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,882
|
rust-lang__libc-3882
|
[
"3704"
] |
5431bdb756c560b21bce18ea7dff72a2aad9975c
|
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 84e725a91cb9d..cf71443d84ddb 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -4147,7 +4147,6 @@ pub const IPV6_RECVHOPLIMIT: ::c_int = 37;
pub const IPV6_PKTINFO: ::c_int = 46;
pub const IPV6_HOPLIMIT: ::c_int = 47;
pub const IPV6_RECVPKTINFO: ::c_int = 61;
-pub const IPV6_DONTFRAG: ::c_int = 62;
pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 70;
pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 71;
pub const IP_BLOCK_SOURCE: ::c_int = 72;
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index 2d401876627d6..af0632882cdbc 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -973,7 +973,6 @@ pub const IPV6_PKTINFO: ::c_int = 46;
pub const IPV6_HOPLIMIT: ::c_int = 47;
pub const IPV6_RECVTCLASS: ::c_int = 57;
pub const IPV6_TCLASS: ::c_int = 61;
-pub const IPV6_DONTFRAG: ::c_int = 62;
pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 70;
pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 71;
pub const IP_BLOCK_SOURCE: ::c_int = 72;
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index 487547d00540a..61f764d1d2dee 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -311,6 +311,7 @@ pub const IPV6_MULTICAST_IF: ::c_int = 9;
pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
pub const IPV6_V6ONLY: ::c_int = 27;
+pub const IPV6_DONTFRAG: ::c_int = 62;
pub const IPTOS_ECN_NOTECT: u8 = 0x00;
pub const IPTOS_ECN_MASK: u8 = 0x03;
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index 3ea931ecb72c1..3e1b83e5adb73 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -2271,6 +2271,8 @@ pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
pub const MFD_CLOEXEC: ::c_uint = 0x0001;
pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
pub const MFD_HUGETLB: ::c_uint = 0x0004;
+pub const MFD_NOEXEC_SEAL: ::c_uint = 0x0008;
+pub const MFD_EXEC: ::c_uint = 0x0010;
pub const MFD_HUGE_64KB: ::c_uint = 0x40000000;
pub const MFD_HUGE_512KB: ::c_uint = 0x4c000000;
pub const MFD_HUGE_1MB: ::c_uint = 0x50000000;
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index e61683fac063a..a47d0618ab230 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -2790,6 +2790,8 @@ pub const CMSPAR: ::tcflag_t = 0o10000000000;
pub const MFD_CLOEXEC: ::c_uint = 0x0001;
pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
pub const MFD_HUGETLB: ::c_uint = 0x0004;
+pub const MFD_NOEXEC_SEAL: ::c_uint = 0x0008;
+pub const MFD_EXEC: ::c_uint = 0x0010;
pub const MFD_HUGE_64KB: ::c_uint = 0x40000000;
pub const MFD_HUGE_512KB: ::c_uint = 0x4c000000;
pub const MFD_HUGE_1MB: ::c_uint = 0x50000000;
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 9560e07c8cf7e..d5f753c0d0d8f 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -3839,6 +3839,10 @@ fn test_linux(target: &str) {
if name.starts_with("NI_IDN") {
return true;
}
+ // FIXME: Requires >= 6.3 kernel headers
+ if name == "MFD_NOEXEC_SEAL" || name == "MFD_EXEC" {
+ return true;
+ }
}
match name {
// These constants are not available if gnu headers have been included
@@ -4049,6 +4053,9 @@ fn test_linux(target: &str) {
if musl => true,
"CLONE_CLEAR_SIGHAND" | "CLONE_INTO_CGROUP" => true,
+ // FIXME: Requires >= 6.3 kernel headers
+ "MFD_EXEC" | "MFD_NOEXEC_SEAL" if sparc64 => true,
+
// kernel 6.1 minimum
"MADV_COLLAPSE" => true,
diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt
index 36785e284a48c..df205a82497c1 100644
--- a/libc-test/semver/android.txt
+++ b/libc-test/semver/android.txt
@@ -1252,7 +1252,9 @@ MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ
MFD_ALLOW_SEALING
MFD_CLOEXEC
+MFD_EXEC
MFD_HUGETLB
+MFD_NOEXEC_SEAL
MINIX2_SUPER_MAGIC
MINIX2_SUPER_MAGIC2
MINIX_SUPER_MAGIC
diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt
index ea0f848017b86..fc7449b91865e 100644
--- a/libc-test/semver/linux.txt
+++ b/libc-test/semver/linux.txt
@@ -1465,7 +1465,9 @@ MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ
MFD_ALLOW_SEALING
MFD_CLOEXEC
+MFD_EXEC
MFD_HUGETLB
+MFD_NOEXEC_SEAL
MINSIGSTKSZ
MMAP_PAGE_ZERO
MNT_DETACH
diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt
index b82d9cbeca065..838f28f71b5d1 100644
--- a/libc-test/semver/netbsd.txt
+++ b/libc-test/semver/netbsd.txt
@@ -468,6 +468,7 @@ IPTOS_ECN_ECT0
IPTOS_ECN_ECT1
IPTOS_ECN_MASK
IPTOS_ECN_NOTECT
+IPV6_DONTFRAG
IPV6_JOIN_GROUP
IPV6_LEAVE_GROUP
IPV6_PKTINFO
diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt
index 3833884c855c5..019ab53d34ff0 100644
--- a/libc-test/semver/openbsd.txt
+++ b/libc-test/semver/openbsd.txt
@@ -311,6 +311,7 @@ IPTOS_ECN_ECT0
IPTOS_ECN_ECT1
IPTOS_ECN_MASK
IPTOS_ECN_NOTECT
+IPV6_DONTFRAG
IPV6_JOIN_GROUP
IPV6_LEAVE_GROUP
IPV6_PKTINFO
|
Add IPV6_DONTFRAG socket option on OpenBSD
* target triple: x86_64-unknown-openbsd
* Header file: https://github.com/openbsd/src/blob/35659bf2453d7eeb12fd24089cf668ca13361c18/sys/netinet6/in6.h#L330C9-L330C24
According to the git history this symbol has been there for a very long time, so there is probably no need to check the openbsd version.
|
2024-08-29T09:31:41Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,848
|
rust-lang__libc-3848
|
[
"3217"
] |
0e6afd534ed7a0406e9dfc9242c2c9370a5b8d05
|
diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs
index af3c8a7cf6f6c..eb90f3f9030e7 100644
--- a/src/unix/bsd/freebsdlike/freebsd/arm.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs
@@ -5,6 +5,8 @@ pub type wchar_t = u32;
pub type time_t = i64;
pub type suseconds_t = i32;
pub type register_t = i32;
+pub type __greg_t = ::c_uint;
+pub type __gregset_t = [::__greg_t; 17];
s! {
pub struct stat {
@@ -36,6 +38,47 @@ s! {
}
}
+s_no_extra_traits! {
+ pub struct mcontext_t {
+ pub __gregs: ::__gregset_t,
+ pub mc_vfp_size: ::__size_t,
+ pub mc_vfp_ptr: *mut ::c_void,
+ pub mc_spare: [::c_uint; 33],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for mcontext_t {
+ fn eq(&self, other: &mcontext_t) -> bool {
+ self.__gregs == other.__gregs &&
+ self.mc_vfp_size == other.mc_vfp_size &&
+ self.mc_vfp_ptr == other.mc_vfp_ptr &&
+ self.mc_spare.iter().zip(other.mc_spare.iter()).all(|(a, b)| a == b)
+ }
+ }
+ impl Eq for mcontext_t {}
+ impl ::fmt::Debug for mcontext_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("mcontext_t")
+ .field("__gregs", &self.__gregs)
+ .field("mc_vfp_size", &self.mc_vfp_size)
+ .field("mc_vfp_ptr", &self.mc_vfp_ptr)
+ .field("mc_spare", &self.mc_spare)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for mcontext_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.__gregs.hash(state);
+ self.mc_vfp_size.hash(state);
+ self.mc_vfp_ptr.hash(state);
+ self.mc_spare.hash(state);
+ }
+ }
+ }
+}
+
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
pub const MAP_32BIT: ::c_int = 0x00080000;
pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 3cf1fc1aeeef3..7017191cc064d 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -1638,6 +1638,15 @@ s_no_extra_traits! {
_kf_cap_spare: u64,
pub kf_path: [::c_char; ::PATH_MAX as usize],
}
+
+ pub struct ucontext_t {
+ pub uc_sigmask: ::sigset_t,
+ pub uc_mcontext: ::mcontext_t,
+ pub uc_link: *mut ::ucontext_t,
+ pub uc_stack: ::stack_t,
+ pub uc_flags: ::c_int,
+ __spare__: [::c_int; 4],
+ }
}
cfg_if! {
@@ -2592,6 +2601,18 @@ cfg_if! {
self.kf_path.hash(state);
}
}
+
+ impl ::fmt::Debug for ucontext_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("ucontext_t")
+ .field("uc_sigmask", &self.uc_sigmask)
+ .field("uc_mcontext", &self.uc_mcontext)
+ .field("uc_link", &self.uc_link)
+ .field("uc_stack", &self.uc_stack)
+ .field("uc_flags", &self.uc_flags)
+ .finish()
+ }
+ }
}
}
diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs
index 0900005166a2e..5de61946de3b9 100644
--- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs
@@ -32,6 +32,68 @@ s! {
}
}
+s_no_extra_traits! {
+ #[repr(align(16))]
+ pub struct mcontext_t {
+ pub mc_vers: ::c_int,
+ pub mc_flags: ::c_int,
+ pub mc_onstack: ::c_int,
+ pub mc_len: ::c_int,
+ pub mc_avec: [u64; 64],
+ pub mc_av: [u32; 2],
+ pub mc_frame: [::register_t; 42],
+ pub mc_fpreg: [u64; 33],
+ pub mc_vsxfpreg: [u64; 32],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for mcontext_t {
+ fn eq(&self, other: &mcontext_t) -> bool {
+ self.mc_vers == other.mc_vers &&
+ self.mc_flags == other.mc_flags &&
+ self.mc_onstack == other.mc_onstack &&
+ self.mc_len == other.mc_len &&
+ self.mc_avec == other.mc_avec &&
+ self.mc_av == other.mc_av &&
+ self.mc_frame == other.mc_frame &&
+ self.mc_fpreg == other.mc_fpreg &&
+ self.mc_vsxfpreg == other.mc_vsxfpreg
+ }
+ }
+ impl Eq for mcontext_t {}
+ impl ::fmt::Debug for mcontext_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("mcontext_t")
+ .field("mc_vers", &self.mc_vers)
+ .field("mc_flags", &self.mc_flags)
+ .field("mc_onstack", &self.mc_onstack)
+ .field("mc_len", &self.mc_len)
+ .field("mc_avec", &self.mc_avec)
+ .field("mc_av", &self.mc_av)
+ .field("mc_frame", &self.mc_frame)
+ .field("mc_fpreg", &self.mc_fpreg)
+ .field("mc_vsxfpreg", &self.mc_vsxfpreg)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for mcontext_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.mc_vers.hash(state);
+ self.mc_flags.hash(state);
+ self.mc_onstack.hash(state);
+ self.mc_len.hash(state);
+ self.mc_avec.hash(state);
+ self.mc_av.hash(state);
+ self.mc_frame.hash(state);
+ self.mc_fpreg.hash(state);
+ self.mc_vsxfpreg.hash(state);
+ }
+ }
+ }
+}
+
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
pub const MAP_32BIT: ::c_int = 0x00080000;
pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
index 07f2f11cdc9a4..ca9cf5c8524f2 100644
--- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
@@ -32,6 +32,68 @@ s! {
}
}
+s_no_extra_traits! {
+ #[repr(align(16))]
+ pub struct mcontext_t {
+ pub mc_vers: ::c_int,
+ pub mc_flags: ::c_int,
+ pub mc_onstack: ::c_int,
+ pub mc_len: ::c_int,
+ pub mc_avec: [u64; 64],
+ pub mc_av: [u32; 2],
+ pub mc_frame: [::register_t; 42],
+ pub mc_fpreg: [u64; 33],
+ pub mc_vsxfpreg: [u64; 32],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for mcontext_t {
+ fn eq(&self, other: &mcontext_t) -> bool {
+ self.mc_vers == other.mc_vers &&
+ self.mc_flags == other.mc_flags &&
+ self.mc_onstack == other.mc_onstack &&
+ self.mc_len == other.mc_len &&
+ self.mc_avec == other.mc_avec &&
+ self.mc_av == other.mc_av &&
+ self.mc_frame == other.mc_frame &&
+ self.mc_fpreg == other.mc_fpreg &&
+ self.mc_vsxfpreg == other.mc_vsxfpreg
+ }
+ }
+ impl Eq for mcontext_t {}
+ impl ::fmt::Debug for mcontext_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("mcontext_t")
+ .field("mc_vers", &self.mc_vers)
+ .field("mc_flags", &self.mc_flags)
+ .field("mc_onstack", &self.mc_onstack)
+ .field("mc_len", &self.mc_len)
+ .field("mc_avec", &self.mc_avec)
+ .field("mc_av", &self.mc_av)
+ .field("mc_frame", &self.mc_frame)
+ .field("mc_fpreg", &self.mc_fpreg)
+ .field("mc_vsxfpreg", &self.mc_vsxfpreg)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for mcontext_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.mc_vers.hash(state);
+ self.mc_flags.hash(state);
+ self.mc_onstack.hash(state);
+ self.mc_len.hash(state);
+ self.mc_avec.hash(state);
+ self.mc_av.hash(state);
+ self.mc_frame.hash(state);
+ self.mc_fpreg.hash(state);
+ self.mc_vsxfpreg.hash(state);
+ }
+ }
+ }
+}
+
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
pub const MAP_32BIT: ::c_int = 0x00080000;
diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs
index 3e3e5cc9f34fb..75a900a043d09 100644
--- a/src/unix/bsd/freebsdlike/freebsd/x86.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs
@@ -66,15 +66,6 @@ s! {
pub st_birthtime_nsec: ::c_long,
__unused: [u8; 8],
}
-
- pub struct ucontext_t {
- pub uc_sigmask: ::sigset_t,
- pub uc_mcontext: ::mcontext_t,
- pub uc_link: *mut ::ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_flags: ::c_int,
- __spare__: [::c_int; 4],
- }
}
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs
index 3a016a0519852..208e7f2c90c0a 100644
--- a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs
@@ -184,14 +184,3 @@ cfg_if! {
}
}
}
-
-s! {
- pub struct ucontext_t {
- pub uc_sigmask: ::sigset_t,
- pub uc_mcontext: ::mcontext_t,
- pub uc_link: *mut ::ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_flags: ::c_int,
- __spare__: [::c_int; 4],
- }
-}
|
diff --git a/libc-test/semver/freebsd-x86_64.txt b/libc-test/semver/freebsd-x86_64.txt
index be73d1f7290fe..14ddc25a1b254 100644
--- a/libc-test/semver/freebsd-x86_64.txt
+++ b/libc-test/semver/freebsd-x86_64.txt
@@ -13,8 +13,6 @@ _MC_HASSEGS
fpreg
fpreg32
max_align_t
-mcontext_t
reg
reg32
-ucontext_t
xmmreg
diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt
index 933fea0e63e94..f5d9ea2fd15f3 100644
--- a/libc-test/semver/freebsd.txt
+++ b/libc-test/semver/freebsd.txt
@@ -2004,6 +2004,7 @@ mallctl
mallctlbymib
mallctlnametomib
mallocx
+mcontext_t
memmem
memrchr
memset_s
@@ -2334,13 +2335,14 @@ timer_t
timex
truncate
ttyname_r
-uuidgen
+ucontext_t
unmount
useconds_t
uselocale
utimensat
utmpx
utrace
+uuidgen
vm_size_t
vmtotal
wait4
|
ucontext_t is missing on aarch64-unknown-freebsd
2e3999ddf0fa added `mcontext_t` but not `ucontext_t`. FreeBSD `ucontext_t` is machine-independent but libc crate limits it by `target_arch`.
See [ucontext_t definition](https://github.com/freebsd/freebsd-src/blob/releng/13.2/sys/sys/_ucontext.h) vs. [mcontext_t definition](https://github.com/freebsd/freebsd-src/blob/releng/13.2/sys/arm64/include/ucontext.h)
```rust
error[E0412]: cannot find type `ucontext_t` in crate `libc`
--> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:219:57
|
219 | let ucontext = &mut *(context as *mut libc::ucontext_t);
| ^^^^^^^^^^ help: a struct with a similar name exists: `mcontext_t`
|
::: veloren-4b6c5f57e3a9/cargo-crates/libc-0.2.133/src/unix/bsd/freebsdlike/freebsd/aarch64.rs:20:1
|
20 | / s_no_extra_traits! {
21 | | pub struct gpregs {
22 | | pub gp_x: [::register_t; 30],
23 | | pub gp_lr: ::register_t,
.. |
44 | | }
45 | | }
| |_- similarly named struct `mcontext_t` defined here
error[E0412]: cannot find type `ucontext_t` in crate `libc`
--> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:259:45
|
259 | unsafe fn get_pc_sp(context: &libc::ucontext_t) -> (usize, usize) {
| ^^^^^^^^^^ help: a struct with a similar name exists: `mcontext_t`
|
::: veloren-4b6c5f57e3a9/cargo-crates/libc-0.2.133/src/unix/bsd/freebsdlike/freebsd/aarch64.rs:20:1
|
20 | / s_no_extra_traits! {
21 | | pub struct gpregs {
22 | | pub gp_x: [::register_t; 30],
23 | | pub gp_lr: ::register_t,
.. |
44 | | }
45 | | }
| |_- similarly named struct `mcontext_t` defined here
error[E0412]: cannot find type `ucontext_t` in crate `libc`
--> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:314:54
|
314 | unsafe fn update_context(context: &mut libc::ucontext_t, regs: TrapHandlerRegs) {
| ^^^^^^^^^^ help: a struct with a similar name exists: `mcontext_t`
|
::: veloren-4b6c5f57e3a9/cargo-crates/libc-0.2.133/src/unix/bsd/freebsdlike/freebsd/aarch64.rs:20:1
|
20 | / s_no_extra_traits! {
21 | | pub struct gpregs {
22 | | pub gp_x: [::register_t; 30],
23 | | pub gp_lr: ::register_t,
.. |
44 | | }
45 | | }
| |_- similarly named struct `mcontext_t` defined here
error[E0425]: cannot find value `pc` in this scope
--> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:420:59
|
420 | context.uc_mcontext.mc_gpregs.gp_pc = pc as libc::register_t;
| ^^ not found in this scope
error[E0425]: cannot find value `sp` in this scope
--> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:421:59
|
421 | context.uc_mcontext.mc_gpregs.gp_sp = sp as libc::register_t;
| ^^ not found in this scope
error[E0425]: cannot find value `x0` in this scope
--> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:422:61
|
422 | context.uc_mcontext.mc_gpregs.gp_x[0] = x0 as libc::register_t;
| ^^ not found in this scope
error[E0425]: cannot find value `x1` in this scope
--> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:423:61
|
423 | context.uc_mcontext.mc_gpregs.gp_x[1] = x1 as libc::register_t;
| ^^ not found in this scope
error[E0425]: cannot find value `x29` in this scope
--> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:424:62
|
424 | context.uc_mcontext.mc_gpregs.gp_x[29] = x29 as libc::register_t;
| ^^^ not found in this scope
error[E0425]: cannot find value `lr` in this scope
--> veloren-4b6c5f57e3a9/cargo-crates/wasmer-vm-2.3.0/src/trap/traphandlers.rs:425:62
|
425 | context.uc_mcontext.mc_gpregs.gp_x[30] = lr as libc::register_t;
| ^^ not found in this scope
Some errors have detailed explanations: E0412, E0425.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `wasmer-vm` due to 9 previous errors
```
|
Thanks for the report, feel free to put up a PR for this!
|
2024-08-17T18:04:05Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
rust-lang/libc
| 3,846
|
rust-lang__libc-3846
|
[
"1618"
] |
d8ff07b336fd28c58088b718fee4f0f350b0f733
|
diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs
index 4707fa4c99991..c28ad931b4c3c 100644
--- a/src/unix/bsd/apple/b32/mod.rs
+++ b/src/unix/bsd/apple/b32/mod.rs
@@ -54,6 +54,11 @@ s_no_extra_traits! {
__sig: c_long,
__opaque: [::c_char; 36]
}
+
+ pub struct pthread_once_t {
+ __sig: c_long,
+ __opaque: [::c_char; ::__PTHREAD_ONCE_SIZE__],
+ }
}
cfg_if! {
@@ -82,6 +87,29 @@ cfg_if! {
self.__opaque.hash(state);
}
}
+ impl PartialEq for pthread_once_t {
+ fn eq(&self, other: &pthread_once_t) -> bool {
+ self.__sig == other.__sig
+ && self.__opaque
+ .iter()
+ .zip(other.__opaque.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for pthread_once_t {}
+ impl ::fmt::Debug for pthread_once_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("pthread_once_t")
+ .field("__sig", &self.__sig)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for pthread_once_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.__sig.hash(state);
+ self.__opaque.hash(state);
+ }
+ }
}
}
@@ -92,6 +120,7 @@ pub const NET_RT_MAXID: ::c_int = 10;
pub const __PTHREAD_MUTEX_SIZE__: usize = 40;
pub const __PTHREAD_COND_SIZE__: usize = 24;
pub const __PTHREAD_CONDATTR_SIZE__: usize = 4;
+pub const __PTHREAD_ONCE_SIZE__: usize = 4;
pub const __PTHREAD_RWLOCK_SIZE__: usize = 124;
pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12;
@@ -103,6 +132,12 @@ pub const BIOCSRTIMEOUT: ::c_ulong = 0x8008426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4008426e;
pub const BIOCSETFNR: ::c_ulong = 0x8008427e;
+const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA;
+pub const PTHREAD_ONCE_INIT: ::pthread_once_t = ::pthread_once_t {
+ __sig: _PTHREAD_ONCE_SIG_INIT,
+ __opaque: [0; 4],
+};
+
extern "C" {
pub fn exchangedata(
path1: *const ::c_char,
diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs
index 48d94bcd6bfdc..2206210da5575 100644
--- a/src/unix/bsd/apple/b64/mod.rs
+++ b/src/unix/bsd/apple/b64/mod.rs
@@ -54,6 +54,11 @@ s_no_extra_traits! {
__sig: c_long,
__opaque: [::c_char; 56]
}
+
+ pub struct pthread_once_t {
+ __sig: c_long,
+ __opaque: [::c_char; __PTHREAD_ONCE_SIZE__],
+ }
}
cfg_if! {
@@ -82,6 +87,29 @@ cfg_if! {
self.__opaque.hash(state);
}
}
+ impl PartialEq for pthread_once_t {
+ fn eq(&self, other: &pthread_once_t) -> bool {
+ self.__sig == other.__sig
+ && self.__opaque
+ .iter()
+ .zip(other.__opaque.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for pthread_once_t {}
+ impl ::fmt::Debug for pthread_once_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("pthread_once_t")
+ .field("__sig", &self.__sig)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for pthread_once_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.__sig.hash(state);
+ self.__opaque.hash(state);
+ }
+ }
}
}
@@ -92,6 +120,7 @@ pub const NET_RT_MAXID: ::c_int = 11;
pub const __PTHREAD_MUTEX_SIZE__: usize = 56;
pub const __PTHREAD_COND_SIZE__: usize = 40;
pub const __PTHREAD_CONDATTR_SIZE__: usize = 8;
+pub const __PTHREAD_ONCE_SIZE__: usize = 8;
pub const __PTHREAD_RWLOCK_SIZE__: usize = 192;
pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16;
@@ -103,6 +132,12 @@ pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
pub const BIOCSETFNR: ::c_ulong = 0x8010427e;
+const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA;
+pub const PTHREAD_ONCE_INIT: ::pthread_once_t = ::pthread_once_t {
+ __sig: _PTHREAD_ONCE_SIG_INIT,
+ __opaque: [0; 8],
+};
+
extern "C" {
pub fn exchangedata(
path1: *const ::c_char,
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 48d6edd86aa6c..54735b3f9801b 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -3761,6 +3761,19 @@ pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 2;
pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
pub const PTHREAD_CREATE_JOINABLE: ::c_int = 1;
pub const PTHREAD_CREATE_DETACHED: ::c_int = 2;
+pub const PTHREAD_INHERIT_SCHED: ::c_int = 1;
+pub const PTHREAD_EXPLICIT_SCHED: ::c_int = 2;
+pub const PTHREAD_CANCEL_ENABLE: ::c_int = 0x01;
+pub const PTHREAD_CANCEL_DISABLE: ::c_int = 0x00;
+pub const PTHREAD_CANCEL_DEFERRED: ::c_int = 0x02;
+pub const PTHREAD_CANCEL_ASYNCHRONOUS: ::c_int = 0x00;
+pub const PTHREAD_CANCELED: *mut ::c_void = 1 as *mut ::c_void;
+pub const PTHREAD_SCOPE_SYSTEM: ::c_int = 1;
+pub const PTHREAD_SCOPE_PROCESS: ::c_int = 2;
+pub const PTHREAD_PRIO_NONE: ::c_int = 0;
+pub const PTHREAD_PRIO_INHERIT: ::c_int = 1;
+pub const PTHREAD_PRIO_PROTECT: ::c_int = 2;
+
#[cfg(target_arch = "aarch64")]
pub const PTHREAD_STACK_MIN: ::size_t = 16384;
#[cfg(not(target_arch = "aarch64"))]
@@ -5700,6 +5713,40 @@ extern "C" {
newp: *mut ::c_void,
newlen: ::size_t,
) -> ::c_int;
+ pub fn pthread_once(
+ once_control: *mut ::pthread_once_t,
+ init_routine: ::Option<unsafe extern "C" fn()>,
+ ) -> ::c_int;
+ pub fn pthread_attr_getinheritsched(
+ attr: *const ::pthread_attr_t,
+ inheritsched: *mut ::c_int,
+ ) -> ::c_int;
+ pub fn pthread_attr_getschedpolicy(
+ attr: *const ::pthread_attr_t,
+ policy: *mut ::c_int,
+ ) -> ::c_int;
+ pub fn pthread_attr_getscope(
+ attr: *const ::pthread_attr_t,
+ contentionscope: *mut ::c_int,
+ ) -> ::c_int;
+ pub fn pthread_attr_getstackaddr(
+ attr: *const ::pthread_attr_t,
+ stackaddr: *mut *mut ::c_void,
+ ) -> ::c_int;
+ pub fn pthread_attr_getdetachstate(
+ attr: *const ::pthread_attr_t,
+ detachstate: *mut ::c_int,
+ ) -> ::c_int;
+ pub fn pthread_attr_setinheritsched(
+ attr: *mut ::pthread_attr_t,
+ inheritsched: ::c_int,
+ ) -> ::c_int;
+ pub fn pthread_attr_setschedpolicy(attr: *mut ::pthread_attr_t, policy: ::c_int) -> ::c_int;
+ pub fn pthread_attr_setscope(attr: *mut ::pthread_attr_t, contentionscope: ::c_int) -> ::c_int;
+ pub fn pthread_attr_setstackaddr(
+ attr: *mut ::pthread_attr_t,
+ stackaddr: *mut ::c_void,
+ ) -> ::c_int;
pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int;
pub fn pthread_getname_np(thread: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn pthread_mach_thread_np(thread: ::pthread_t) -> ::mach_port_t;
|
diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt
index 1b548b594a2cb..ec3791acbfa99 100644
--- a/libc-test/semver/apple.txt
+++ b/libc-test/semver/apple.txt
@@ -1117,16 +1117,29 @@ PROC_CSM_TECS
PROC_PIDTASKALLINFO
PROC_PIDTASKINFO
PROC_PIDTHREADINFO
+PTHREAD_CANCEL_ASYNCHRONOUS
+PTHREAD_CANCEL_DEFERRED
+PTHREAD_CANCEL_DISABLE
+PTHREAD_CANCEL_ENABLE
+PTHREAD_CANCELED
PTHREAD_CREATE_DETACHED
PTHREAD_CREATE_JOINABLE
+PTHREAD_EXPLICIT_SCHED
+PTHREAD_INHERIT_SCHED
PTHREAD_INTROSPECTION_THREAD_CREATE
PTHREAD_INTROSPECTION_THREAD_DESTROY
PTHREAD_INTROSPECTION_THREAD_START
PTHREAD_INTROSPECTION_THREAD_TERMINATE
PTHREAD_MUTEX_DEFAULT
PTHREAD_MUTEX_ERRORCHECK
+PTHREAD_ONCE_INIT
+PTHREAD_PRIO_INHERIT
+PTHREAD_PRIO_NONE
+PTHREAD_PRIO_PROTECT
PTHREAD_PROCESS_PRIVATE
PTHREAD_PROCESS_SHARED
+PTHREAD_SCOPE_PROCESS
+PTHREAD_SCOPE_SYSTEM
PTHREAD_STACK_MIN
PT_ATTACH
PT_ATTACHEXC
@@ -1744,6 +1757,7 @@ _WSTOPPED
__PTHREAD_CONDATTR_SIZE__
__PTHREAD_COND_SIZE__
__PTHREAD_MUTEX_SIZE__
+__PTHREAD_ONCE_SIZE__
__PTHREAD_RWLOCKATTR_SIZE__
__PTHREAD_RWLOCK_SIZE__
__darwin_mcontext64
@@ -2041,8 +2055,18 @@ pseudo_AF_KEY
pseudo_AF_PIP
pseudo_AF_RTIP
pseudo_AF_XTP
+pthread_atfork
+pthread_attr_getdetachstate
+pthread_attr_getinheritsched
pthread_attr_getschedparam
+pthread_attr_getschedpolicy
+pthread_attr_getscope
+pthread_attr_getstackaddr
+pthread_attr_setinheritsched
pthread_attr_setschedparam
+pthread_attr_setschedpolicy
+pthread_attr_setscope
+pthread_attr_setstackaddr
pthread_cancel
pthread_condattr_getpshared
pthread_condattr_setpshared
@@ -2064,6 +2088,8 @@ pthread_kill
pthread_main_np
pthread_mutexattr_getpshared
pthread_mutexattr_setpshared
+pthread_once
+pthread_once_t
pthread_rwlockattr_getpshared
pthread_rwlockattr_setpshared
pthread_setname_np
|
Add posix threads support for macOS
Can we add a possibility to use POSIX threads for the macOS? It seems to be not straightforward to do myself - all the code is mixed across many files. Thanks!
P.S. Maybe it is even better if we share all the POSIX-code among several targets which support it. Right now, for example, the `pthread_setschedprio` function is defined in the `/linux-like/linux` but it shouldn't be Linux-only available.
|
PRs welcome.
|
2024-08-17T08:24:54Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
rust-lang/libc
| 3,844
|
rust-lang__libc-3844
|
[
"3566"
] |
6eddffbaf0de2ade96f780d940c18168bd281bc6
|
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index 97791e6b5a72e..fa291a3694adb 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -2558,6 +2558,14 @@ pub const NFT_CT_PROTO_DST: ::c_int = 12;
pub const NFT_CT_LABELS: ::c_int = 13;
pub const NFT_CT_PKTS: ::c_int = 14;
pub const NFT_CT_BYTES: ::c_int = 15;
+pub const NFT_CT_AVGPKT: ::c_int = 16;
+pub const NFT_CT_ZONE: ::c_int = 17;
+pub const NFT_CT_EVENTMASK: ::c_int = 18;
+pub const NFT_CT_SRC_IP: ::c_int = 19;
+pub const NFT_CT_DST_IP: ::c_int = 20;
+pub const NFT_CT_SRC_IP6: ::c_int = 21;
+pub const NFT_CT_DST_IP6: ::c_int = 22;
+pub const NFT_CT_ID: ::c_int = 23;
pub const NFT_LIMIT_PKTS: ::c_int = 0;
pub const NFT_LIMIT_PKT_BYTES: ::c_int = 1;
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index 2ce09ed168df8..6f6f4d2ea382e 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -4452,6 +4452,13 @@ pub const NFT_CT_PROTO_DST: ::c_int = 12;
pub const NFT_CT_LABELS: ::c_int = 13;
pub const NFT_CT_PKTS: ::c_int = 14;
pub const NFT_CT_BYTES: ::c_int = 15;
+pub const NFT_CT_AVGPKT: ::c_int = 16;
+pub const NFT_CT_ZONE: ::c_int = 17;
+pub const NFT_CT_EVENTMASK: ::c_int = 18;
+pub const NFT_CT_SRC_IP: ::c_int = 19;
+pub const NFT_CT_DST_IP: ::c_int = 20;
+pub const NFT_CT_SRC_IP6: ::c_int = 21;
+pub const NFT_CT_DST_IP6: ::c_int = 22;
pub const NFT_LIMIT_PKTS: ::c_int = 0;
pub const NFT_LIMIT_PKT_BYTES: ::c_int = 1;
|
diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt
index f2f41be9e83d3..c46c11d75cd9f 100644
--- a/libc-test/semver/android.txt
+++ b/libc-test/semver/android.txt
@@ -1500,11 +1500,16 @@ NFT_CMP_LT
NFT_CMP_LTE
NFT_CMP_NEQ
NFT_CONTINUE
+NFT_CT_AVGPKT
NFT_CT_BYTES
NFT_CT_DIRECTION
NFT_CT_DST
+NFT_CT_DST_IP
+NFT_CT_DST_IP6
+NFT_CT_EVENTMASK
NFT_CT_EXPIRATION
NFT_CT_HELPER
+NFT_CT_ID
NFT_CT_L3PROTOCOL
NFT_CT_LABELS
NFT_CT_MARK
@@ -1514,8 +1519,11 @@ NFT_CT_PROTO_DST
NFT_CT_PROTO_SRC
NFT_CT_SECMARK
NFT_CT_SRC
+NFT_CT_SRC_IP
+NFT_CT_SRC_IP6
NFT_CT_STATE
NFT_CT_STATUS
+NFT_CT_ZONE
NFT_DATA_RESERVED_MASK
NFT_DATA_VALUE
NFT_DATA_VALUE_MAXLEN
diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt
index 79c051f4c7c50..09dd98a77e5c4 100644
--- a/libc-test/semver/linux-gnu.txt
+++ b/libc-test/semver/linux-gnu.txt
@@ -191,9 +191,13 @@ NFT_CMP_LT
NFT_CMP_LTE
NFT_CMP_NEQ
NFT_CONTINUE
+NFT_CT_AVGPKT
NFT_CT_BYTES
NFT_CT_DIRECTION
NFT_CT_DST
+NFT_CT_DST_IP
+NFT_CT_DST_IP6
+NFT_CT_EVENTMASK
NFT_CT_EXPIRATION
NFT_CT_HELPER
NFT_CT_L3PROTOCOL
@@ -205,8 +209,11 @@ NFT_CT_PROTO_DST
NFT_CT_PROTO_SRC
NFT_CT_SECMARK
NFT_CT_SRC
+NFT_CT_SRC_IP
+NFT_CT_SRC_IP6
NFT_CT_STATE
NFT_CT_STATUS
+NFT_CT_ZONE
NFT_DATA_RESERVED_MASK
NFT_DATA_VALUE
NFT_DATA_VALUE_MAXLEN
|
Add missing definitions from linux/include/uapi/linux/netfilter/nf_tables.h
<!--
Please provide the below information:
* the target triple
* link to the documentation of the API showing the type signatures, how to use
it, etc.
In general, just please consider that the people who can help you are all very
busy, they will be helping you in their free time, there are a lot of people in
need of help so they need to prioritize to which issues they devote their free
time, etc. So try to give most of the information upfront, be concise, show
small self-contained examples (nobody has time to create a new cargo project,
set up dependencies,...), etc. Help us help you.
-->
There are missing definitons from `linux/include/uapi/linux/netfilter/nf_tables.h`. I am opening this ticket due to a missing definitions for `NFT_CT_ZONE`, but upon checking that I realized there are a bunch of definitions from that file missing as well.
This is the header I am referring to: https://github.com/torvalds/linux/blob/master/include/uapi/linux/netfilter/nf_tables.h
This is where the definitions are: https://github.com/rust-lang/libc/blob/ad75ba1f261a33d118d61c066818b60efc1fa6fe/src/unix/linux_like/linux/mod.rs#L4034
If this is just a matter of adding the missing definitions, I'd be happy to do it. Let me know.
|
Feel free I would say !
|
2024-08-16T21:09:24Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
rust-lang/libc
| 3,843
|
rust-lang__libc-3843
|
[
"3689"
] |
fc282833449475d9e7a4a56b9caa1f3e938435b5
|
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 8984e097b968c..7b39e4784f96d 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -896,6 +896,7 @@ extern "C" {
pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
pub fn pipe(fds: *mut ::c_int) -> ::c_int;
pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int;
+ pub fn aligned_alloc(alignment: ::size_t, size: ::size_t) -> *mut ::c_void;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "read$UNIX2003"
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 16964b75e1d62..26b1c550de22c 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1936,6 +1936,9 @@ fn test_android(target: &str) {
// Added in API level 28, but some tests use level 24.
"fread_unlocked" | "fwrite_unlocked" | "fgets_unlocked" | "fflush_unlocked" => true,
+ // Added in API level 28, but some tests use level 24.
+ "aligned_alloc" => true,
+
// FIXME: bad function pointers:
"isalnum" | "isalpha" | "iscntrl" | "isdigit" | "isgraph" | "islower" | "isprint"
| "ispunct" | "isspace" | "isupper" | "isxdigit" | "isblank" | "tolower"
diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt
index ac28806ab52e0..062d867b8530c 100644
--- a/libc-test/semver/unix.txt
+++ b/libc-test/semver/unix.txt
@@ -452,6 +452,7 @@ accept
access
addrinfo
alarm
+aligned_alloc
atexit
atof
atoi
|
Missing function: aligned_alloc
This function is part of the [C standard](https://en.cppreference.com/w/c/memory/aligned_alloc). I don't know the full set of targets that support it.
- Linux: [glibc has it](https://www.gnu.org/software/libc/manual/html_node/Aligned-Memory-Blocks.html), and I found it in [musl](https://git.musl-libc.org/cgit/musl/tree/src/malloc/mallocng/aligned_alloc.c?h=v1.2.2), too (but that uses `malloc` + offset -- no idea how they're making sure that you can `free` the resulting pointer)
- FreeBSD also [seems to have it](https://man.freebsd.org/cgi/man.cgi?query=aligned_alloc&apropos=0&sektion=3&manpath=FreeBSD+9-current&format=html)
- macOS: available since 10.15 according to [this](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92143) (but buggy until today... but that's not libc's concern)
- Solaris seems to [have it](https://docs.oracle.com/cd/E88353_01/html/E37843/aligned-alloc-3c.html), and same for [Illumos](https://illumos.org/man/3C/aligned_alloc) (again, [buggy](https://www.illumos.org/issues/16545)...)
- The function is mentioned [here](https://android.googlesource.com/platform/bionic/+/master/docs/status.md) so I assume (recent enough) Android also has it.
|
2024-08-16T20:39:05Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,831
|
rust-lang__libc-3831
|
[
"3696"
] |
bc3c8cb3d32a1df087311ab23af6287098d5fc11
|
diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs
index 35a8c0255be69..29f54b92cd48b 100644
--- a/src/unix/bsd/netbsdlike/mod.rs
+++ b/src/unix/bsd/netbsdlike/mod.rs
@@ -92,6 +92,11 @@ s! {
pub piod_addr: *mut ::c_void,
pub piod_len: ::size_t,
}
+
+ pub struct mmsghdr {
+ pub msg_hdr: ::msghdr,
+ pub msg_len: ::c_uint,
+ }
}
pub const D_T_FMT: ::nl_item = 0;
@@ -847,6 +852,20 @@ extern "C" {
pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
+
+ pub fn sendmmsg(
+ sockfd: ::c_int,
+ mmsg: *mut ::mmsghdr,
+ vlen: ::c_uint,
+ flags: ::c_int,
+ ) -> ::c_int;
+ pub fn recvmmsg(
+ sockfd: ::c_int,
+ mmsg: *mut ::mmsghdr,
+ vlen: ::c_uint,
+ flags: ::c_int,
+ timeout: *mut ::timespec,
+ ) -> ::c_int;
}
cfg_if! {
diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs
index 7c58e85c4434c..f919b73e5c2f4 100644
--- a/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs
@@ -401,11 +401,6 @@ s! {
pub sdl_data: [::c_char; 12],
}
- pub struct mmsghdr {
- pub msg_hdr: ::msghdr,
- pub msg_len: ::c_uint,
- }
-
pub struct __exit_status {
pub e_termination: u16,
pub e_exit: u16,
@@ -2759,20 +2754,6 @@ extern "C" {
pub fn kqueue1(flags: ::c_int) -> ::c_int;
- pub fn sendmmsg(
- sockfd: ::c_int,
- msgvec: *mut ::mmsghdr,
- vlen: ::c_uint,
- flags: ::c_int,
- ) -> ::c_int;
- pub fn recvmmsg(
- sockfd: ::c_int,
- msgvec: *mut ::mmsghdr,
- vlen: ::c_uint,
- flags: ::c_int,
- timeout: *mut ::timespec,
- ) -> ::c_int;
-
pub fn _lwp_self() -> lwpid_t;
pub fn memmem(
haystack: *const ::c_void,
|
diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt
index afb8afa7f50f0..3833884c855c5 100644
--- a/libc-test/semver/openbsd.txt
+++ b/libc-test/semver/openbsd.txt
@@ -1131,6 +1131,7 @@ mknodat
mkostemp
mkostemps
mkstemps
+mmsghdr
mount_info
mrand48
msdosfs_args
@@ -1210,6 +1211,7 @@ readlinkat
reallocarray
reboot
recvmsg
+recvmmsg
regcomp
regerror
regex_t
@@ -1231,6 +1233,7 @@ sem_init
sem_open
sem_timedwait
sem_unlink
+sendmmsg
sendmsg
setdomainname
setgrent
|
Add `recvmmsg` and `sendmmsg` on OpenBSD (*-unknown-openbsd)
`recvmmsg` is supported on OpenBSD since OpenBSD 7.2: https://www.openbsd.org/72.html
Same for `sendmmsg`.
Documentation is here:
- https://man.openbsd.org/OpenBSD-7.2/recvmmsg
- https://man.openbsd.org/OpenBSD-7.2/sendmmsg
Related PR made at the time when OpenBSD did not support these functions yet: https://github.com/rust-lang/libc/pull/1231
|
2024-08-15T21:29:19Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,771
|
rust-lang__libc-3771
|
[
"3767"
] |
ce2ccd5c624eaf2aa05a1f692a167cf4a7def0f3
|
diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
index 4d235ba0ad951..6d5deb6b24abd 100644
--- a/src/unix/linux_like/linux/gnu/mod.rs
+++ b/src/unix/linux_like/linux/gnu/mod.rs
@@ -826,6 +826,9 @@ pub const TMP_MAX: ::c_uint = 238328;
pub const FOPEN_MAX: ::c_uint = 16;
pub const FILENAME_MAX: ::c_uint = 4096;
pub const POSIX_MADV_DONTNEED: ::c_int = 4;
+pub const _CS_GNU_LIBC_VERSION: ::c_int = 2;
+pub const _CS_GNU_LIBPTHREAD_VERSION: ::c_int = 3;
+pub const _CS_PATH: ::c_int = 0;
pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41;
pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45;
pub const _SC_PII: ::c_int = 53;
@@ -1485,6 +1488,7 @@ extern "C" {
) -> ::size_t;
pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char;
+ pub fn confstr(name: ::c_int, buf: *mut ::c_char, len: ::size_t) -> ::size_t;
pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
/// POSIX version of `basename(3)`, defined in `libgen.h`.
#[link_name = "__xpg_basename"]
|
diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt
index 0c0d77888e4d5..79c051f4c7c50 100644
--- a/libc-test/semver/linux-gnu.txt
+++ b/libc-test/semver/linux-gnu.txt
@@ -511,6 +511,9 @@ XSK_UNALIGNED_BUF_ADDR_MASK
XDP_PKT_CONTD
XENFS_SUPER_MAGIC
XFS_SUPER_MAGIC
+_CS_GNU_LIBC_VERSION
+_CS_GNU_LIBPTHREAD_VERSION
+_CS_PATH
_SC_2_C_VERSION
_SC_BASE
_SC_CHARCLASS_NAME_MAX
@@ -611,6 +614,7 @@ aio_write
aiocb
backtrace
clock_adjtime
+confstr
copy_file_range
ctermid
dlinfo
|
Missing POSIX confstr and _CS_* symbols on Linux.
Apple Darwin provides the POSIX standard `confstr(3)` function and associated `_CS_*` symbols. Tested on Darwin and is working.
Requesting the same for Linux.
Quoting src/unix/bsd/apple/mod.rs:
```
// `confstr` keys (only the values guaranteed by `man confstr`).
pub const _CS_PATH: ::c_int = 1;
pub const _CS_DARWIN_USER_DIR: ::c_int = 65536;
pub const _CS_DARWIN_USER_TEMP_DIR: ::c_int = 65537;
pub const _CS_DARWIN_USER_CACHE_DIR: ::c_int = 65538;
...
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "confstr$UNIX2003"
)]
pub fn confstr(name: ::c_int, buf: *mut ::c_char, len: ::size_t) -> ::size_t
```
The Linux version for this crate should be very similar. The Linux man page for `confstr(3)` also helpfully lists the few key `_CS_*` symbols that the developer should expect to be available:
```
_CS_GNU_LIBC_VERSION (GNU C library only; since glibc 2.3.2)
_CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2)
_CS_PATH
```
|
Would you be pleased to create a PR ?
@devnexen I gave it a shot with #3771, but I do not understand why the arm test is failing, so I'm a bit stuck.
|
2024-07-11T00:25:54Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
rust-lang/libc
| 3,762
|
rust-lang__libc-3762
|
[
"3760"
] |
251a968b712a2c274f66605095d5ee820f4243c2
|
diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs
index 36d8c20381432..699c8181f8466 100644
--- a/src/unix/linux_like/linux/musl/mod.rs
+++ b/src/unix/linux_like/linux/musl/mod.rs
@@ -671,6 +671,12 @@ pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
pub const PTRACE_GETSIGMASK: ::c_uint = 0x420a;
pub const PTRACE_SETSIGMASK: ::c_uint = 0x420b;
+pub const RWF_HIPRI: ::c_int = 0x00000001;
+pub const RWF_DSYNC: ::c_int = 0x00000002;
+pub const RWF_SYNC: ::c_int = 0x00000004;
+pub const RWF_NOWAIT: ::c_int = 0x00000008;
+pub const RWF_APPEND: ::c_int = 0x00000010;
+
pub const AF_IB: ::c_int = 27;
pub const AF_MPLS: ::c_int = 28;
pub const AF_NFC: ::c_int = 39;
@@ -862,6 +868,20 @@ extern "C" {
dirfd: ::c_int,
path: *const ::c_char,
) -> ::c_int;
+ pub fn preadv2(
+ fd: ::c_int,
+ iov: *const ::iovec,
+ iovcnt: ::c_int,
+ offset: ::off_t,
+ flags: ::c_int,
+ ) -> ::ssize_t;
+ pub fn pwritev2(
+ fd: ::c_int,
+ iov: *const ::iovec,
+ iovcnt: ::c_int,
+ offset: ::off_t,
+ flags: ::c_int,
+ ) -> ::ssize_t;
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
// Added in `musl` 1.1.20
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 30af90fc8844c..a847f46448938 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -4307,6 +4307,9 @@ fn test_linux(target: &str) {
// FIXME: function pointers changed since Ubuntu 23.10
"strtol" | "strtoll" | "strtoul" | "strtoull" | "fscanf" | "scanf" | "sscanf" => true,
+ // Added in musl 1.2.5
+ "preadv2" | "pwritev2" if musl => true,
+
_ => false,
}
});
diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt
index 7e5a81194bdf8..5a48357cb79e5 100644
--- a/libc-test/semver/linux-musl.txt
+++ b/libc-test/semver/linux-musl.txt
@@ -23,6 +23,11 @@ PF_XDP
PIDFD_NONBLOCK
PR_SET_VMA
PR_SET_VMA_ANON_NAME
+RWF_APPEND
+RWF_DSYNC
+RWF_HIPRI
+RWF_NOWAIT
+RWF_SYNC
SOL_XDP
XDP_SHARED_UMEM
XDP_COPY
@@ -66,11 +71,13 @@ getloadavg
lio_listio
ntptimeval
open_wmemstream
+preadv2
preadv64
prlimit
prlimit64
process_vm_readv
process_vm_writev
+pwritev2
pwritev64
reallocarray
timex
|
preadv2 is not supported on musl libc
The preadv2 function is present on -gnu target, however when compiling on -musl target, which is surprising.
The jobserver-rs would like to use it to optimize it's performance rust-lang/jobserver-rs#90 (the try_acquire optimization has shipped once but reverted, so I opened another PR to use raw syscall directly).
FYI, my motivation is to that this API is used in cc-rs to improve performance.
|
2024-06-28T19:20:10Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,745
|
rust-lang__libc-3745
|
[
"3730"
] |
e209061f6eaf5a3aa6af70d247c76b16462f27f6
|
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index a2942913b95d1..53f1f7adcaffd 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -5534,6 +5534,12 @@ extern "C" {
idx1: ::c_ulong,
idx2: ::c_ulong,
) -> ::c_int;
+
+ pub fn execvpe(
+ file: *const ::c_char,
+ argv: *const *const ::c_char,
+ envp: *const *const ::c_char,
+ ) -> ::c_int;
}
#[link(name = "memstat")]
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index f2c6c3ccddf5a..09dc440400590 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -2489,6 +2489,8 @@ fn test_freebsd(target: &str) {
cfg.skip_fn(move |name| {
// skip those that are manually verified
match name {
+ // This is introduced in FreeBSD 14.1
+ "execvpe" => true,
// The `uname` function in the `utsname.h` FreeBSD header is a C
// inline function (has no symbol) that calls the `__xuname` symbol.
// Therefore the function pointer comparison does not make sense for it.
diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt
index 5a049d102114e..bb6d67c6d0079 100644
--- a/libc-test/semver/freebsd.txt
+++ b/libc-test/semver/freebsd.txt
@@ -1873,6 +1873,7 @@ eui64_hostton
eui64_ntoa
eui64_ntohost
exect
+execvpe
execvP
explicit_bzero
extattr_delete_fd
|
Missing execvpe on FreeBSD >= 14.1
Target: `x86_64-unknown-freebsd`
API: [GNU-compatible](https://github.com/freebsd/freebsd-src/commit/0667d0e0e365)
Test case: [nix](https://github.com/nix-rust/nix/blob/1939f922431c2009cc726a9ff260e978a2b15fd7/src/unistd.rs#L885), [pager](https://gitlab.com/imp/pager-rs/-/commit/6efe69c173fa), [libafl](https://github.com/AFLplusplus/LibAFL/blob/0f9c82f893b0bb8e91b78c5c17f8d1c8d452669e/utils/noaslr/libnoaslr/src/lib.rs#L188)
|
2024-06-09T09:46:40Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,716
|
rust-lang__libc-3716
|
[
"3704"
] |
1333dcfd8df024a16b9309748d3fc4b8bc83b666
|
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 9a672fae7ee68..84143e1986bfb 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -4153,7 +4153,6 @@ pub const IPV6_RECVHOPLIMIT: ::c_int = 37;
pub const IPV6_PKTINFO: ::c_int = 46;
pub const IPV6_HOPLIMIT: ::c_int = 47;
pub const IPV6_RECVPKTINFO: ::c_int = 61;
-pub const IPV6_DONTFRAG: ::c_int = 62;
pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 70;
pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 71;
pub const IP_BLOCK_SOURCE: ::c_int = 72;
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index 4d1d32c725287..d9da55d028ec6 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -980,7 +980,6 @@ pub const IPV6_PKTINFO: ::c_int = 46;
pub const IPV6_HOPLIMIT: ::c_int = 47;
pub const IPV6_RECVTCLASS: ::c_int = 57;
pub const IPV6_TCLASS: ::c_int = 61;
-pub const IPV6_DONTFRAG: ::c_int = 62;
pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 70;
pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 71;
pub const IP_BLOCK_SOURCE: ::c_int = 72;
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index 6ee2a3de44035..7acda9076d1f0 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -311,6 +311,7 @@ pub const IPV6_MULTICAST_IF: ::c_int = 9;
pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
pub const IPV6_V6ONLY: ::c_int = 27;
+pub const IPV6_DONTFRAG: ::c_int = 62;
pub const IPTOS_ECN_NOTECT: u8 = 0x00;
pub const IPTOS_ECN_MASK: u8 = 0x03;
|
diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt
index 353b1e7356ff5..35d64153f2650 100644
--- a/libc-test/semver/netbsd.txt
+++ b/libc-test/semver/netbsd.txt
@@ -468,6 +468,7 @@ IPTOS_ECN_ECT0
IPTOS_ECN_ECT1
IPTOS_ECN_MASK
IPTOS_ECN_NOTECT
+IPV6_DONTFRAG
IPV6_JOIN_GROUP
IPV6_LEAVE_GROUP
IPV6_PKTINFO
diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt
index fd4563212d60d..6f07fec590ff5 100644
--- a/libc-test/semver/openbsd.txt
+++ b/libc-test/semver/openbsd.txt
@@ -311,6 +311,7 @@ IPTOS_ECN_ECT0
IPTOS_ECN_ECT1
IPTOS_ECN_MASK
IPTOS_ECN_NOTECT
+IPV6_DONTFRAG
IPV6_JOIN_GROUP
IPV6_LEAVE_GROUP
IPV6_PKTINFO
|
Add IPV6_DONTFRAG socket option on OpenBSD
* target triple: x86_64-unknown-openbsd
* Header file: https://github.com/openbsd/src/blob/35659bf2453d7eeb12fd24089cf668ca13361c18/sys/netinet6/in6.h#L330C9-L330C24
According to the git history this symbol has been there for a very long time, so there is probably no need to check the openbsd version.
|
You re in the luck, seems [it is already there](https://github.com/rust-lang/libc/blob/libc-0.2/src/unix/bsd/netbsdlike/mod.rs#L504).
Huh, totally true. I'm afraid I mixed up the symbol, I am looking for IPV6_DONTFRAG:
https://github.com/openbsd/src/blob/35659bf2453d7eeb12fd24089cf668ca13361c18/sys/netinet6/in6.h#L336
Also has been there since forever in OpenBSD, but I don't think is defined by the libc crate.
|
2024-05-21T19:23:49Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
rust-lang/libc
| 3,714
|
rust-lang__libc-3714
|
[
"3711"
] |
113efbf2f2c01bfc125807e85608ae1d9b6b6865
|
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 54735b3f9801b..9c12439e54cbd 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -4914,22 +4914,11 @@ pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020;
pub const NET_RT_IFLIST2: ::c_int = 0x0006;
// net/route.h
-pub const RTF_UP: ::c_int = 0x1;
-pub const RTF_GATEWAY: ::c_int = 0x2;
-pub const RTF_HOST: ::c_int = 0x4;
-pub const RTF_REJECT: ::c_int = 0x8;
-pub const RTF_DYNAMIC: ::c_int = 0x10;
-pub const RTF_MODIFIED: ::c_int = 0x20;
-pub const RTF_DONE: ::c_int = 0x40;
pub const RTF_DELCLONE: ::c_int = 0x80;
pub const RTF_CLONING: ::c_int = 0x100;
pub const RTF_XRESOLVE: ::c_int = 0x200;
pub const RTF_LLINFO: ::c_int = 0x400;
-pub const RTF_STATIC: ::c_int = 0x800;
-pub const RTF_BLACKHOLE: ::c_int = 0x1000;
pub const RTF_NOIFREF: ::c_int = 0x2000;
-pub const RTF_PROTO2: ::c_int = 0x4000;
-pub const RTF_PROTO1: ::c_int = 0x8000;
pub const RTF_PRCLONING: ::c_int = 0x10000;
pub const RTF_WASCLONED: ::c_int = 0x20000;
pub const RTF_PROTO3: ::c_int = 0x40000;
@@ -4948,13 +4937,6 @@ pub const RTF_GLOBAL: ::c_int = 0x40000000;
pub const RTM_VERSION: ::c_int = 5;
// Message types
-pub const RTM_ADD: ::c_int = 0x1;
-pub const RTM_DELETE: ::c_int = 0x2;
-pub const RTM_CHANGE: ::c_int = 0x3;
-pub const RTM_GET: ::c_int = 0x4;
-pub const RTM_LOSING: ::c_int = 0x5;
-pub const RTM_REDIRECT: ::c_int = 0x6;
-pub const RTM_MISS: ::c_int = 0x7;
pub const RTM_LOCK: ::c_int = 0x8;
pub const RTM_OLDADD: ::c_int = 0x9;
pub const RTM_OLDDEL: ::c_int = 0xa;
@@ -4978,25 +4960,6 @@ pub const RTV_SSTHRESH: ::c_int = 0x20;
pub const RTV_RTT: ::c_int = 0x40;
pub const RTV_RTTVAR: ::c_int = 0x80;
-// Bitmask values for rtm_addrs.
-pub const RTA_DST: ::c_int = 0x1;
-pub const RTA_GATEWAY: ::c_int = 0x2;
-pub const RTA_NETMASK: ::c_int = 0x4;
-pub const RTA_GENMASK: ::c_int = 0x8;
-pub const RTA_IFP: ::c_int = 0x10;
-pub const RTA_IFA: ::c_int = 0x20;
-pub const RTA_AUTHOR: ::c_int = 0x40;
-pub const RTA_BRD: ::c_int = 0x80;
-
-// Index offsets for sockaddr array for alternate internal encoding.
-pub const RTAX_DST: ::c_int = 0;
-pub const RTAX_GATEWAY: ::c_int = 1;
-pub const RTAX_NETMASK: ::c_int = 2;
-pub const RTAX_GENMASK: ::c_int = 3;
-pub const RTAX_IFP: ::c_int = 4;
-pub const RTAX_IFA: ::c_int = 5;
-pub const RTAX_AUTHOR: ::c_int = 6;
-pub const RTAX_BRD: ::c_int = 7;
pub const RTAX_MAX: ::c_int = 8;
pub const KERN_PROCARGS2: ::c_int = 49;
diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
index 489b82adb84b9..e00e60290369d 100644
--- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs
+++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
@@ -1522,6 +1522,19 @@ pub const NGROUPS: usize = 16;
pub const RB_PAUSE: ::c_int = 0x40000;
pub const RB_VIDEO: ::c_int = 0x20000000;
+// net/route.h
+pub const RTF_CLONING: ::c_int = 0x100;
+pub const RTF_PRCLONING: ::c_int = 0x10000;
+pub const RTF_WASCLONED: ::c_int = 0x20000;
+pub const RTF_MPLSOPS: ::c_int = 0x1000000;
+
+pub const RTM_VERSION: ::c_int = 7;
+
+pub const RTAX_MPLS1: ::c_int = 8;
+pub const RTAX_MPLS2: ::c_int = 9;
+pub const RTAX_MPLS3: ::c_int = 10;
+pub const RTAX_MAX: ::c_int = 11;
+
const_fn! {
{const} fn _CMSG_ALIGN(n: usize) -> usize {
(n + (::mem::size_of::<::c_long>() - 1)) & !(::mem::size_of::<::c_long>() - 1)
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index fc01d8e5463b8..0905d3c94f7f4 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -4697,6 +4697,14 @@ pub const CPU_WHICH_CPUSET: ::c_int = 3;
pub const CPU_WHICH_IRQ: ::c_int = 4;
pub const CPU_WHICH_JAIL: ::c_int = 5;
+// net/route.h
+pub const RTF_LLDATA: ::c_int = 0x400;
+pub const RTF_FIXEDMTU: ::c_int = 0x80000;
+
+pub const RTM_VERSION: ::c_int = 5;
+
+pub const RTAX_MAX: ::c_int = 8;
+
// sys/signal.h
pub const SIGTHR: ::c_int = 32;
pub const SIGLWP: ::c_int = SIGTHR;
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index af0632882cdbc..5ce3600d94ac9 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -1009,6 +1009,25 @@ pub const SO_TYPE: ::c_int = 0x1008;
pub const LOCAL_PEERCRED: ::c_int = 1;
+// net/route.h
+pub const RTF_XRESOLVE: ::c_int = 0x200;
+pub const RTF_LLINFO: ::c_int = 0x400;
+pub const RTF_PROTO3: ::c_int = 0x40000;
+pub const RTF_PINNED: ::c_int = 0x100000;
+pub const RTF_LOCAL: ::c_int = 0x200000;
+pub const RTF_BROADCAST: ::c_int = 0x400000;
+pub const RTF_MULTICAST: ::c_int = 0x800000;
+
+pub const RTM_LOCK: ::c_int = 0x8;
+pub const RTM_RESOLVE: ::c_int = 0xb;
+pub const RTM_NEWADDR: ::c_int = 0xc;
+pub const RTM_DELADDR: ::c_int = 0xd;
+pub const RTM_IFINFO: ::c_int = 0xe;
+pub const RTM_NEWMADDR: ::c_int = 0xf;
+pub const RTM_DELMADDR: ::c_int = 0x10;
+pub const RTM_IFANNOUNCE: ::c_int = 0x11;
+pub const RTM_IEEE80211: ::c_int = 0x12;
+
pub const SHUT_RD: ::c_int = 0;
pub const SHUT_WR: ::c_int = 1;
pub const SHUT_RDWR: ::c_int = 2;
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index 61f764d1d2dee..918007159862e 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -543,6 +543,49 @@ pub const ITIMER_REAL: ::c_int = 0;
pub const ITIMER_VIRTUAL: ::c_int = 1;
pub const ITIMER_PROF: ::c_int = 2;
+// net/route.h
+
+pub const RTF_UP: ::c_int = 0x1;
+pub const RTF_GATEWAY: ::c_int = 0x2;
+pub const RTF_HOST: ::c_int = 0x4;
+pub const RTF_REJECT: ::c_int = 0x8;
+pub const RTF_DYNAMIC: ::c_int = 0x10;
+pub const RTF_MODIFIED: ::c_int = 0x20;
+pub const RTF_DONE: ::c_int = 0x40;
+pub const RTF_STATIC: ::c_int = 0x800;
+pub const RTF_BLACKHOLE: ::c_int = 0x1000;
+pub const RTF_PROTO2: ::c_int = 0x4000;
+pub const RTF_PROTO1: ::c_int = 0x8000;
+
+// Message types
+pub const RTM_ADD: ::c_int = 0x1;
+pub const RTM_DELETE: ::c_int = 0x2;
+pub const RTM_CHANGE: ::c_int = 0x3;
+pub const RTM_GET: ::c_int = 0x4;
+pub const RTM_LOSING: ::c_int = 0x5;
+pub const RTM_REDIRECT: ::c_int = 0x6;
+pub const RTM_MISS: ::c_int = 0x7;
+
+// Bitmask values for rtm_addrs.
+pub const RTA_DST: ::c_int = 0x1;
+pub const RTA_GATEWAY: ::c_int = 0x2;
+pub const RTA_NETMASK: ::c_int = 0x4;
+pub const RTA_GENMASK: ::c_int = 0x8;
+pub const RTA_IFP: ::c_int = 0x10;
+pub const RTA_IFA: ::c_int = 0x20;
+pub const RTA_AUTHOR: ::c_int = 0x40;
+pub const RTA_BRD: ::c_int = 0x80;
+
+// Index offsets for sockaddr array for alternate internal encoding.
+pub const RTAX_DST: ::c_int = 0;
+pub const RTAX_GATEWAY: ::c_int = 1;
+pub const RTAX_NETMASK: ::c_int = 2;
+pub const RTAX_GENMASK: ::c_int = 3;
+pub const RTAX_IFP: ::c_int = 4;
+pub const RTAX_IFA: ::c_int = 5;
+pub const RTAX_AUTHOR: ::c_int = 6;
+pub const RTAX_BRD: ::c_int = 7;
+
f! {
pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr {
if (*mhdr).msg_controllen as usize >= ::mem::size_of::<::cmsghdr>() {
diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs
index 318557daf52b8..0921d56912cd2 100644
--- a/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs
@@ -2402,6 +2402,33 @@ pub const fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int {
alignment << MAP_ALIGNMENT_SHIFT
}
+// net/route.h
+pub const RTF_MASK: ::c_int = 0x80;
+pub const RTF_CONNECTED: ::c_int = 0x100;
+pub const RTF_ANNOUNCE: ::c_int = 0x20000;
+pub const RTF_SRC: ::c_int = 0x10000;
+pub const RTF_LOCAL: ::c_int = 0x40000;
+pub const RTF_BROADCAST: ::c_int = 0x80000;
+pub const RTF_UPDATING: ::c_int = 0x100000;
+pub const RTF_DONTCHANGEIFA: ::c_int = 0x200000;
+
+pub const RTM_VERSION: ::c_int = 4;
+pub const RTM_LOCK: ::c_int = 0x8;
+pub const RTM_IFANNOUNCE: ::c_int = 0x10;
+pub const RTM_IEEE80211: ::c_int = 0x11;
+pub const RTM_SETGATE: ::c_int = 0x12;
+pub const RTM_LLINFO_UPD: ::c_int = 0x13;
+pub const RTM_IFINFO: ::c_int = 0x14;
+pub const RTM_OCHGADDR: ::c_int = 0x15;
+pub const RTM_NEWADDR: ::c_int = 0x16;
+pub const RTM_DELADDR: ::c_int = 0x17;
+pub const RTM_CHGADDR: ::c_int = 0x18;
+
+pub const RTA_TAG: ::c_int = 0x100;
+
+pub const RTAX_TAG: ::c_int = 8;
+pub const RTAX_MAX: ::c_int = 9;
+
const_fn! {
{const} fn _ALIGN(p: usize) -> usize {
(p + _ALIGNBYTES) & !_ALIGNBYTES
diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs
index 357662547b8e3..9e14e89515e47 100644
--- a/src/unix/bsd/netbsdlike/openbsd/mod.rs
+++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs
@@ -1881,6 +1881,54 @@ pub const RB_RESET: ::c_int = 0x08000;
pub const RB_GOODRANDOM: ::c_int = 0x10000;
pub const RB_UNHIBERNATE: ::c_int = 0x20000;
+// net/route.h
+pub const RTF_CLONING: ::c_int = 0x100;
+pub const RTF_MULTICAST: ::c_int = 0x200;
+pub const RTF_LLINFO: ::c_int = 0x400;
+pub const RTF_PROTO3: ::c_int = 0x2000;
+pub const RTF_ANNOUNCE: ::c_int = ::RTF_PROTO2;
+
+pub const RTF_CLONED: ::c_int = 0x10000;
+pub const RTF_CACHED: ::c_int = 0x20000;
+pub const RTF_MPATH: ::c_int = 0x40000;
+pub const RTF_MPLS: ::c_int = 0x100000;
+pub const RTF_LOCAL: ::c_int = 0x200000;
+pub const RTF_BROADCAST: ::c_int = 0x400000;
+pub const RTF_CONNECTED: ::c_int = 0x800000;
+pub const RTF_BFD: ::c_int = 0x1000000;
+pub const RTF_FMASK: ::c_int = b'\\' as _;
+
+pub const RTM_VERSION: ::c_int = 5;
+pub const RTM_RESOLVE: ::c_int = 0xb;
+pub const RTM_NEWADDR: ::c_int = 0xc;
+pub const RTM_DELADDR: ::c_int = 0xd;
+pub const RTM_IFINFO: ::c_int = 0xe;
+pub const RTM_IFANNOUNCE: ::c_int = 0xf;
+pub const RTM_DESYNC: ::c_int = 0x10;
+pub const RTM_INVALIDATE: ::c_int = 0x11;
+pub const RTM_BFD: ::c_int = 0x12;
+pub const RTM_PROPOSAL: ::c_int = 0x13;
+pub const RTM_CHGADDRATTR: ::c_int = 0x14;
+pub const RTM_80211INFO: ::c_int = 0x15;
+pub const RTM_SOURCE: ::c_int = 0x16;
+
+pub const RTA_SRC: ::c_int = 0x100;
+pub const RTA_SRCMASK: ::c_int = 0x200;
+pub const RTA_LABEL: ::c_int = 0x400;
+pub const RTA_BFD: ::c_int = 0x800;
+pub const RTA_DNS: ::c_int = 0x1000;
+pub const RTA_STATIC: ::c_int = 0x2000;
+pub const RTA_SEARCH: ::c_int = 0x4000;
+
+pub const RTAX_SRC: ::c_int = 8;
+pub const RTAX_SRCMASK: ::c_int = 9;
+pub const RTAX_LABEL: ::c_int = 10;
+pub const RTAX_BFD: ::c_int = 11;
+pub const RTAX_DNS: ::c_int = 12;
+pub const RTAX_STATIC: ::c_int = 13;
+pub const RTAX_SEARCH: ::c_int = 14;
+pub const RTAX_MAX: ::c_int = 15;
+
const_fn! {
{const} fn _ALIGN(p: usize) -> usize {
(p + _ALIGNBYTES) & !_ALIGNBYTES
|
diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt
index b9ccffb681ad3..e01fe55d72ff3 100644
--- a/libc-test/semver/dragonfly.txt
+++ b/libc-test/semver/dragonfly.txt
@@ -873,6 +873,31 @@ RLIMIT_STACK
RLIMIT_VMEM
RLIM_INFINITY
RLIM_NLIMITS
+RTF_XRESOLVE
+RTF_LLINFO
+RTF_PROTO3
+RTF_PINNED
+RTF_LOCAL
+RTF_BROADCAST
+RTF_MULTICAST
+RTM_LOCK
+RTM_RESOLVE
+RTM_NEWADDR
+RTM_DELADDR
+RTM_IFINFO
+RTM_NEWMADDR
+RTM_DELMADDR
+RTM_IFANNOUNCE
+RTM_IEEE80211
+RTF_CLONING
+RTF_PRCLONING
+RTF_WASCLONED
+RTF_MPLSOPS
+RTM_VERSION
+RTAX_MPLS1
+RTAX_MPLS2
+RTAX_MPLS3
+RTAX_MAX
RTLD_NEXT
RTLD_NODELETE
RTLD_NOLOAD
diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt
index cb36429fb36ab..5d4253029e5e6 100644
--- a/libc-test/semver/freebsd.txt
+++ b/libc-test/semver/freebsd.txt
@@ -1222,6 +1222,26 @@ RLIMIT_UMTXP
RLIMIT_VMEM
RLIM_INFINITY
RLIM_NLIMITS
+RTF_XRESOLVE
+RTF_LLINFO
+RTF_PROTO3
+RTF_PINNED
+RTF_LOCAL
+RTF_BROADCAST
+RTF_MULTICAST
+RTM_LOCK
+RTM_RESOLVE
+RTM_NEWADDR
+RTM_DELADDR
+RTM_IFINFO
+RTM_NEWMADDR
+RTM_DELMADDR
+RTM_IFANNOUNCE
+RTM_IEEE80211
+RTF_LLDATA
+RTF_FIXEDMTU
+RTM_VERSION
+RTAX_MAX
RTLD_NEXT
RTLD_NODELETE
RTLD_NOLOAD
diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt
index e07a7dbf08ae6..cfde7caca0c55 100644
--- a/libc-test/semver/netbsd.txt
+++ b/libc-test/semver/netbsd.txt
@@ -929,6 +929,28 @@ RLIM_INFINITY
RLIM_NLIMITS
RLIM_SAVED_CUR
RLIM_SAVED_MAX
+RTF_MASK
+RTF_CONNECTED
+RTF_ANNOUNCE
+RTF_SRC
+RTF_LOCAL
+RTF_BROADCAST
+RTF_UPDATING
+RTF_DONTCHANGEIFA
+RTM_VERSION
+RTM_LOCK
+RTM_IFANNOUNCE
+RTM_IEEE80211
+RTM_SETGATE
+RTM_LLINFO_UPD
+RTM_IFINFO
+RTM_OCHGADDR
+RTM_NEWADDR
+RTM_DELADDR
+RTM_CHGADDR
+RTA_TAG
+RTAX_TAG
+RTAX_MAX
RTLD_NEXT
RTLD_NOLOAD
RTLD_SELF
diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt
index 019ab53d34ff0..9297c4ac4b81e 100644
--- a/libc-test/semver/openbsd.txt
+++ b/libc-test/semver/openbsd.txt
@@ -761,8 +761,50 @@ RLIM_INFINITY
RLIM_NLIMITS
RLIM_SAVED_CUR
RLIM_SAVED_MAX
+RTA_BFD
+RTA_DNS
+RTA_LABEL
+RTA_SEARCH
+RTA_SRC
+RTA_SRCMASK
+RTA_STATIC
+RTAX_BFD
+RTAX_DNS
+RTAX_LABEL
+RTAX_MAX
+RTAX_SEARCH
+RTAX_SRC
+RTAX_SRCMASK
+RTAX_STATIC
+RTF_ANNOUNCE
+RTF_BFD
+RTF_BROADCAST
+RTF_CACHED
+RTF_CLONED
+RTF_CLONING
+RTF_CONNECTED
+RTF_FMASK
+RTF_LLINFO
+RTF_LOCAL
+RTF_MPATH
+RTF_MPLS
+RTF_MULTICAST
+RTF_PROTO3
RTLD_NEXT
RTLD_SELF
+RTM_80211INFO
+RTM_BFD
+RTM_CHGADDRATTR
+RTM_DELADDR
+RTM_DESYNC
+RTM_IFANNOUNCE
+RTM_IFINFO
+RTM_INVALIDATE
+RTM_NEWADDR
+RTM_PROPOSAL
+RTM_RESOLVE
+RTM_SOURCE
+RTM_VERSION
RUSAGE_CHILDREN
RUSAGE_SELF
RUSAGE_THREAD
|
Missing RTF_*, RTA_*, RTAX_*, RTM_* definitions on BSDs
Target: `x86_64-unknown-dragonfly`, `x86_64-unknown-freebsd`, `x86_64-unknown-netbsd`, `x86_64-unknown-openbsd`
API: [BSD 4.3 Reno](https://github.com/dspinellis/unix-history-repo/blob/BSD-4_3_Reno/usr/src/sys/net/route.h) (historic), [DragonFly](https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/net/route.h), [FreeBSD](https://github.com/freebsd/freebsd-src/blob/main/sys/net/route.h), [NetBSD](https://github.com/netbsd/src/blob/trunk/sys/net/route.h), [OpenBSD](https://github.com/openbsd/src/blob/master/sys/net/route.h)
Test case: https://github.com/n0-computer/iroh/issues/2306
See also: [downstream fix](https://github.com/freebsd/freebsd-ports/blob/78ad38f04f51/games/jumpy/files/patch-libc), copy-pasted from macOS and likely incorrect/incomplete
|
2024-05-19T16:09:04Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,695
|
rust-lang__libc-3695
|
[
"3688"
] |
2899529e27b303af0029624813823fd89a7ba605
|
diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
index a7dd919399fd9..5a350b7a57d84 100644
--- a/src/unix/linux_like/linux/gnu/mod.rs
+++ b/src/unix/linux_like/linux/gnu/mod.rs
@@ -491,6 +491,17 @@ s! {
pub tcpi_rcv_space: u32,
pub tcpi_total_retrans: u32,
}
+
+ pub struct fanotify_event_info_pidfd {
+ pub hdr: ::fanotify_event_info_header,
+ pub pidfd: ::__s32,
+ }
+
+ pub struct fanotify_event_info_error {
+ pub hdr: ::fanotify_event_info_header,
+ pub error: ::__s32,
+ pub error_count: ::__u32,
+ }
}
impl siginfo_t {
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index a47d0618ab230..616e2e7c7d466 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -16,6 +16,7 @@ pub type loff_t = ::c_longlong;
pub type pthread_key_t = ::c_uint;
pub type pthread_once_t = ::c_int;
pub type pthread_spinlock_t = ::c_int;
+pub type __kernel_fsid_t = __c_anonymous__kernel_fsid_t;
pub type __u8 = ::c_uchar;
pub type __u16 = ::c_ushort;
@@ -590,6 +591,10 @@ s! {
pub r_info: Elf64_Xword,
}
+ pub struct __c_anonymous__kernel_fsid_t {
+ pub val: [::c_int; 2],
+ }
+
pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
@@ -657,6 +662,18 @@ s! {
pub response: __u32,
}
+ pub struct fanotify_event_info_header {
+ pub info_type: __u8,
+ pub pad: __u8,
+ pub len: __u16,
+ }
+
+ pub struct fanotify_event_info_fid {
+ pub hdr: fanotify_event_info_header,
+ pub fsid: ::__kernel_fsid_t,
+ pub handle: [::c_uchar; 0],
+ }
+
pub struct sockaddr_vm {
pub svm_family: ::sa_family_t,
pub svm_reserved1: ::c_ushort,
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index eeb119e9549a9..da12acade8f00 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -3700,6 +3700,9 @@ fn test_linux(target: &str) {
if musl && ty == "fanout_args" {
return true;
}
+ if sparc64 && ty == "fanotify_event_info_error" {
+ return true;
+ }
match ty {
// These cannot be tested when "resolv.h" is included and are tested
@@ -4449,7 +4452,11 @@ fn test_linux(target: &str) {
// the `tcpi_delivery_rate_app_limited` field is a bitfield on musl
(musl && struct_ == "tcp_info" && field == "tcpi_delivery_rate_app_limited") ||
// the `tcpi_fast_open_client_fail` field is a bitfield on musl
- (musl && struct_ == "tcp_info" && field == "tcpi_fast_open_client_fail")
+ (musl && struct_ == "tcp_info" && field == "tcpi_fast_open_client_fail") ||
+ // either fsid_t or int[2] type
+ (struct_ == "fanotify_event_info_fid" && field == "fsid") ||
+ // `handle` is a VLA
+ (struct_ == "fanotify_event_info_fid" && field == "handle")
});
cfg.skip_roundtrip(move |s| match s {
diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt
index f775994cd6725..5b079941bb970 100644
--- a/libc-test/semver/linux-gnu.txt
+++ b/libc-test/semver/linux-gnu.txt
@@ -628,6 +628,9 @@ dlinfo
dlmopen
endutxent
explicit_bzero
+fanotify_event_info_error
+fanotify_event_info_header
+fanotify_event_info_pidfd
fgetgrent_r
fgetspent_r
futimes
diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt
index 2e928030486d4..402241df1d033 100644
--- a/libc-test/semver/linux.txt
+++ b/libc-test/semver/linux.txt
@@ -3540,6 +3540,7 @@ execvpe
faccessat
fallocate
fallocate64
+fanotify_event_info_fid
fanotify_event_metadata
fanotify_init
fanotify_mark
|
Add struct `fanotify_event_info_fid`
Host triplet: `x86_64-unknown-linux-gnu`
API struct is as follows:
```c
struct fanotify_event_info_fid {
struct fanotify_event_info_header hdr;
__kernel_fsid_t fsid;
unsigned char file_handle[0];
};
```
Man page for more info: https://man7.org/linux/man-pages/man7/fanotify.7.html
Source link: https://github.com/torvalds/linux/blob/dccb07f2914cdab2ac3a5b6c98406f765acab803/include/uapi/linux/fanotify.h#L166
|
2024-05-11T13:19:32Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,690
|
rust-lang__libc-3690
|
[
"3608",
"3677"
] |
76462771b6f8a6889ba6becadb53418df5515370
|
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index ce8e9782c49a0..fb0b06701507c 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -48,6 +48,10 @@ pub type Elf64_Xword = u64;
pub type eventfd_t = u64;
+// these structs sit behind a heap allocation on Android
+pub type posix_spawn_file_actions_t = *mut ::c_void;
+pub type posix_spawnattr_t = *mut ::c_void;
+
s! {
pub struct stack_t {
pub ss_sp: *mut ::c_void,
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 2b15c958d2d51..f8d797f126736 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1613,6 +1613,7 @@ fn test_android(target: &str) {
"sched.h",
"semaphore.h",
"signal.h",
+ "spawn.h",
"stddef.h",
"stdint.h",
"stdio.h",
@@ -1767,6 +1768,9 @@ fn test_android(target: &str) {
// These are tested in the `linux_elf.rs` file.
"Elf64_Phdr" | "Elf32_Phdr" => true,
+ // These are intended to be opaque
+ "posix_spawn_file_actions_t" => true,
+ "posix_spawnattr_t" => true,
_ => false,
}
});
|
[libc-0.2] `posix_spawn_file_actions_t` cannot be used on Linux after #3602
We found an issue when updating ferrocene's libc submodule (ferrocene/ferrocene#356) to revision 947a1855124bdd13029d322ae6ab2b4f0451db9b . the only change included in our libc update was PR #3602 .
when building stage 2 of libstd to x86_64-linux the build failed to execute the build script of the `quote` crate with the following error:
``` text
thread 'main' panicked at library/std/src/sys_common/process.rs:155:17:
called Result::unwrap() on an Err value: Os { code: 9, kind: Uncategorized, message: "Bad file descriptor" }
```
where the mentioned line corresponds to [this revision](https://github.com/ferrocene/ferrocene/blob/46faebf340ed558b70026eaad44ca32d36d1542b/library/std/src/sys_common/process.rs#L155).
Tracking down the error led us to this usage of [the `posix_spawn` API](https://github.com/ferrocene/ferrocene/blob/46faebf340ed558b70026eaad44ca32d36d1542b/library/std/src/sys/pal/unix/process/process_unix.rs#L585-L586):
``` rust
let mut file_actions = MaybeUninit::uninit();
cvt_nz(libc::posix_spawn_file_actions_init(file_actions.as_mut_ptr()))?;
```
This code allocates a `posix_spawn_file_actions_init` type *on the stack*. before #3602, the `file_actions` stack variable had the correct size and alignment but after #3602, it now has a size and alignment of `*mut c_void` (8 bytes on x86_64) and that results in UB when `posix_spawn_file_actions_init` is called.
GLIBC implements `posix_spawn_file_actions_init` as [a memset operation](https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/spawn_faction_init.c;h=09ee703d33bd6ce9af090ef38bc3921622380783;hb=b6e3898194bbae78910bbe9cd086937014961e45#l51) that zeroes the struct. In Rust syntax, that would be more or less this code:
``` rust
#[repr(C)]
struct posix_spawn_file_actions_t {
// fields and padding here
}
unsafe fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int {
ptr::write_bytes(actions, 0, 1);
0
}
```
Bionic implements `posix_spawn_file_actions_init` differently. It uses a heap allocation as indirection. The Rust version of the bionic implementation looks roughly like this:
``` rust
#[repr(C)]
struct __actual_posix_spawn_file_actions_t {
// fields and padding here
}
type posix_spawn_file_actions_t = *mut c_void;
unsafe fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int {
let mut alloc = Box::new(MaybeUninit::<__actual_posix_spawn_file_actions_t>::uninit());
ptr::write_bytes(alloc.as_mut_ptr(), 0, 1);
*actions = Box::into_raw(alloc).cast();
0
}
```
This usage of `posix_spawn_file_actions_t` in libstd:
``` rust
let mut file_actions = MaybeUninit::uninit();
cvt_nz(libc::posix_spawn_file_actions_init(file_actions.as_mut_ptr()))?;
```
is compatible with both GLIBC and Bionic but the `libc` crate needs to provide the correct size and alignment on Linux.
So, the conditional code should produce this on Linux
``` rust
pub struct posix_spawn_file_actions_t {
__allocated: ::c_int,
__used: ::c_int,
__actions: *mut ::c_int,
__pad: [::c_int; 16],
}
```
but this on Android
``` rust
pub type posix_spawn_file_actions_t = *mut ::c_void;
```
---
All this probably also applies to the `posix_spawnattr_t` type but I have yet to look into the details of the GLIBC code around that type.
I'll send up a fix PR after I have done some more testing.
Recent changes to posix spawn seems to cause a segfault in std::process::Command
Hi.
The CI of rustc_codegen_gcc suddendly started failing.
After investigation, it seems to be caused by recent changes to libc, regarding posix spawn stuff (so possibly related to [this change](https://github.com/rust-lang/libc/pull/3629)).
My target triple is: `x86_64-unknown-linux-gnu`.
Here's the code (inspired by `std::process::Command`) that works with libc 0.2.153, but segfaults with 0.2.154 (it doesn't reproduce in the playground since [it still uses version 0.2.153](https://github.com/rust-lang/rust-playground/blob/main/compiler/base/Cargo.toml#L692)):
```rust
use std::{ffi::OsStr, io};
use std::ffi::{c_int, c_ulong, c_short};
use libc::{gid_t, pid_t, uid_t};
//use std::os::unix::raw::{uid_t, gid_t, pid_t};
mod imp {
use std::{ffi::{CString, OsStr}, io, os::unix::ffi::OsStrExt, process::Stdio};
use libc::{gid_t, pid_t, uid_t};
//use std::os::unix::raw::{uid_t, gid_t, pid_t};
pub struct Command {
pub program: CString,
args: Vec<CString>,
cwd: Option<CString>,
pub uid: Option<uid_t>,
pub gid: Option<gid_t>,
saw_nul: bool,
pub closures: Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>>,
pub groups: Option<Box<[gid_t]>>,
stdin: Option<Stdio>,
stdout: Option<Stdio>,
stderr: Option<Stdio>,
#[cfg(target_os = "linux")]
pub create_pidfd: bool,
pub pgroup: Option<pid_t>,
}
fn os2c(s: &OsStr, saw_nul: &mut bool) -> CString {
CString::new(s.as_bytes()).unwrap_or_else(|_e| {
*saw_nul = true;
CString::new("<string-with-nul>").unwrap()
})
}
impl Command {
pub fn new(program: &OsStr) -> Command {
let mut saw_nul = false;
let program = os2c(program, &mut saw_nul);
Command {
args: vec![program.clone()],
program,
cwd: None,
uid: None,
gid: None,
saw_nul,
closures: Vec::new(),
groups: None,
stdin: None,
stdout: None,
stderr: None,
create_pidfd: false,
pgroup: None,
}
}
}
}
pub fn cvt_nz(error: c_int) -> io::Result<()> {
if error == 0 {
return Ok(())
}
panic!();
}
pub struct Command {
inner: imp::Command,
}
impl Command {
pub fn new<S: AsRef<OsStr>>(program: S) -> Command {
Command { inner: imp::Command::new(program.as_ref()) }
}
pub fn get_pgroup(&self) -> Option<pid_t> {
self.inner.pgroup
}
pub fn get_create_pidfd(&self) -> bool {
self.inner.create_pidfd
}
pub fn get_uid(&self) -> Option<uid_t> {
self.inner.uid
}
pub fn get_gid(&self) -> Option<gid_t> {
self.inner.gid
}
pub fn env_saw_path(&self) -> bool {
false
}
pub fn program_is_path(&self) -> bool {
self.inner.program.to_bytes().contains(&b'/')
}
pub fn get_closures(&mut self) -> &mut Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>> {
&mut self.inner.closures
}
pub fn get_groups(&self) -> Option<&[gid_t]> {
self.inner.groups.as_deref()
}
fn posix_spawn(
&mut self,
) -> io::Result<Option<i32>> {
use std::mem::MaybeUninit;
if self.get_gid().is_some()
|| self.get_uid().is_some()
|| (self.env_saw_path() && !self.program_is_path())
|| !self.get_closures().is_empty()
|| self.get_groups().is_some()
|| self.get_create_pidfd()
{
return Ok(None);
}
#[repr(C)]
struct sched_param {
sched_priority: c_int,
}
#[repr(C)]
struct sigset_t {
__val: [c_ulong; 16],
}
#[repr(C)]
pub struct posix_spawnattr_t {
__flags: c_short,
__pgrp: pid_t,
__sd: sigset_t,
__ss: sigset_t,
#[cfg(any(target_env = "musl", target_env = "ohos"))]
__prio: c_int,
#[cfg(not(any(target_env = "musl", target_env = "ohos")))]
__sp: sched_param,
__policy: c_int,
__pad: [c_int; 16],
}
extern "C" {
fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int;
}
unsafe {
let mut attrs = MaybeUninit::uninit();
//cvt_nz(posix_spawnattr_init(attrs.as_mut_ptr()))?; // This works.
cvt_nz(libc::posix_spawnattr_init(attrs.as_mut_ptr()))?; // This segfaults.
Ok(None)
}
}
}
fn main() {
let mut command = Command::new("ls");
command.posix_spawn().unwrap();
}
```
It seems there's stack corruption.
It could be interesting to run the std tests in the CI to check if changes to libc breaks anything.
Thanks.
**Edit:** Pinning to the version 0.2.153 fixes the CI in rustc_codegen_gcc: https://github.com/rust-lang/rustc_codegen_gcc/pull/512
|
@JohnTitor: This is blocking [updating `libc` in the standard library](https://github.com/rust-lang/rust/pull/124560), specifically because Cargo build scripts seem to break.
The problematic PR has been reverted in https://github.com/rust-lang/libc/pull/3678.
Note that #3608 exists since 0.2.153, #3678 just fixes #3677. We still have to merge https://github.com/rust-lang/libc/pull/3609.
After wasting a day, I also found out that posix_spawnattr_init is fine in 0.2.153, but 0.2.154 causes Segmentation fault......
https://github.com/rust-lang/libc/pull/3602 should be related (note that the changes to v0.2 exist on the libc-0.2 branch).
I'm going to revert that PR as a quick fix: https://github.com/rust-lang/libc/pull/3678
+1 we're also seeing segfaults after updating libc to 0.2.154 with code [that uses posix_spawn directly](https://github.com/evmar/n2/blob/117dfc642a5c724b629dc0d4ab768278803d4395/src/process_posix.rs).
Edit: Same conclusion as in #3608
Linux [`posix_spawnattr_init`](https://github.com/bminor/glibc/blob/ea73eb5f581ef5931fd67005aa0c526ba43366c9/posix/spawnattr_init.c#L23) really is just an wrapper for memset an value of type `posix_spawnattr_t`. #3602 changed `posix_spawnattr_t` to `*mut c_void`, and that caused a buffer overflow.
```rust
unsafe {
let mut attrs = <MaybeUninit<*mut c_void>>::uninit();
let ptr = attrs.as_mut_ptr();
memset(ptr as _, 0, size_of::<libc::posix_spawnattr_t>());
}
```
On Android (with Bionic libc), `posix_spawnattr_init` calls an `calloc` that [allocates](https://github.com/aosp-mirror/platform_bionic/blob/b1f23829ee8a6fc2762ae80b350ac0638197bf4b/libc/bionic/spawn.cpp#L225)
a new `posix_spawnattr_t`. Which is valid on that target.
I propose maintainers to yank libc v0.2.154.
|
2024-05-09T14:02:03Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
rust-lang/libc
| 3,617
|
rust-lang__libc-3617
|
[
"3611"
] |
7d7151c51285bf238d2d02dc736c64b3c6dfbcc8
|
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index ea19b71366cf8..d19c0e9dd9cea 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -37,6 +37,8 @@ pub type rusage_info_t = *mut ::c_void;
pub type vm_offset_t = ::uintptr_t;
pub type vm_size_t = ::uintptr_t;
pub type vm_address_t = vm_offset_t;
+pub type quad_t = i64;
+pub type u_quad_t = u64;
pub type posix_spawnattr_t = *mut ::c_void;
pub type posix_spawn_file_actions_t = *mut ::c_void;
@@ -1136,6 +1138,77 @@ s! {
pub tcpi_rxoutoforderbytes: u64,
pub tcpi_rxretransmitpackets: u64,
}
+
+ pub struct in6_addrlifetime {
+ pub ia6t_expire: time_t,
+ pub ia6t_preferred: time_t,
+ pub ia6t_vltime: u32,
+ pub ia6t_pltime: u32,
+ }
+
+ pub struct in6_ifstat {
+ pub ifs6_in_receive: ::u_quad_t,
+ pub ifs6_in_hdrerr: ::u_quad_t,
+ pub ifs6_in_toobig: ::u_quad_t,
+ pub ifs6_in_noroute: ::u_quad_t,
+ pub ifs6_in_addrerr: ::u_quad_t,
+ pub ifs6_in_protounknown: ::u_quad_t,
+ pub ifs6_in_truncated: ::u_quad_t,
+ pub ifs6_in_discard: ::u_quad_t,
+ pub ifs6_in_deliver: ::u_quad_t,
+ pub ifs6_out_forward: ::u_quad_t,
+ pub ifs6_out_request: ::u_quad_t,
+ pub ifs6_out_discard: ::u_quad_t,
+ pub ifs6_out_fragok: ::u_quad_t,
+ pub ifs6_out_fragfail: ::u_quad_t,
+ pub ifs6_out_fragcreat: ::u_quad_t,
+ pub ifs6_reass_reqd: ::u_quad_t,
+ pub ifs6_reass_ok: ::u_quad_t,
+ pub ifs6_atmfrag_rcvd: ::u_quad_t,
+ pub ifs6_reass_fail: ::u_quad_t,
+ pub ifs6_in_mcast: ::u_quad_t,
+ pub ifs6_out_mcast: ::u_quad_t,
+ pub ifs6_cantfoward_icmp6: ::u_quad_t,
+ pub ifs6_addr_expiry_cnt: ::u_quad_t,
+ pub ifs6_pfx_expiry_cnt: ::u_quad_t,
+ pub ifs6_defrtr_expiry_cnt: ::u_quad_t,
+ }
+ pub struct icmp6_ifstat {
+ pub ifs6_in_msg: ::u_quad_t,
+ pub ifs6_in_error: ::u_quad_t,
+ pub ifs6_in_dstunreach: ::u_quad_t,
+ pub ifs6_in_adminprohib: ::u_quad_t,
+ pub ifs6_in_timeexceed: ::u_quad_t,
+ pub ifs6_in_paramprob: ::u_quad_t,
+ pub ifs6_in_pkttoobig: ::u_quad_t,
+ pub ifs6_in_echo: ::u_quad_t,
+ pub ifs6_in_echoreply: ::u_quad_t,
+ pub ifs6_in_routersolicit: ::u_quad_t,
+ pub ifs6_in_routeradvert: ::u_quad_t,
+ pub ifs6_in_neighborsolicit: ::u_quad_t,
+ pub ifs6_in_neighboradvert: ::u_quad_t,
+ pub ifs6_in_redirect: ::u_quad_t,
+ pub ifs6_in_mldquery: ::u_quad_t,
+ pub ifs6_in_mldreport: ::u_quad_t,
+ pub ifs6_in_mlddone: ::u_quad_t,
+ pub ifs6_out_msg: ::u_quad_t,
+ pub ifs6_out_error: ::u_quad_t,
+ pub ifs6_out_dstunreach: ::u_quad_t,
+ pub ifs6_out_adminprohib: ::u_quad_t,
+ pub ifs6_out_timeexceed: ::u_quad_t,
+ pub ifs6_out_paramprob: ::u_quad_t,
+ pub ifs6_out_pkttoobig: ::u_quad_t,
+ pub ifs6_out_echo: ::u_quad_t,
+ pub ifs6_out_echoreply: ::u_quad_t,
+ pub ifs6_out_routersolicit: ::u_quad_t,
+ pub ifs6_out_routeradvert: ::u_quad_t,
+ pub ifs6_out_neighborsolicit: ::u_quad_t,
+ pub ifs6_out_neighboradvert: ::u_quad_t,
+ pub ifs6_out_redirect: ::u_quad_t,
+ pub ifs6_out_mldquery: ::u_quad_t,
+ pub ifs6_out_mldreport: ::u_quad_t,
+ pub ifs6_out_mlddone: ::u_quad_t,
+ }
}
s_no_extra_traits! {
@@ -1473,6 +1546,25 @@ s_no_extra_traits! {
pub ifcu_buf: *mut ::c_char,
pub ifcu_req: *mut ifreq,
}
+
+ pub union __c_anonymous_ifr_ifru6 {
+ pub ifru_addr: ::sockaddr_in6,
+ pub ifru_dstaddr: ::sockaddr_in6,
+ pub ifru_flags: ::c_int,
+ pub ifru_flags6: ::c_int,
+ pub ifru_metrics: ::c_int,
+ pub ifru_intval: ::c_int,
+ pub ifru_data: *mut ::c_char,
+ pub ifru_lifetime: in6_addrlifetime,
+ pub ifru_stat: in6_ifstat,
+ pub ifru_icmp6stat: icmp6_ifstat,
+ pub ifru_scope_id: [u32; SCOPE6_ID_MAX],
+ }
+
+ pub struct in6_ifreq {
+ pub ifr_name: [::c_char; ::IFNAMSIZ],
+ pub ifr_ifru: __c_anonymous_ifr_ifru6,
+ }
}
impl siginfo_t {
@@ -3021,6 +3113,74 @@ cfg_if! {
unsafe { self.ifcu_req.hash(state) };
}
}
+
+ impl PartialEq for __c_anonymous_ifr_ifru6 {
+ fn eq(&self, other: &__c_anonymous_ifr_ifru6) -> bool {
+ unsafe {
+ self.ifru_addr == other.ifru_addr
+ && self.ifru_dstaddr == other.ifru_dstaddr
+ && self.ifru_flags == other.ifru_flags
+ && self.ifru_flags6 == other.ifru_flags6
+ && self.ifru_metrics == other.ifru_metrics
+ && self.ifru_intval == other.ifru_intval
+ && self.ifru_data == other.ifru_data
+ && self.ifru_scope_id
+ .iter()
+ .zip(other.ifru_scope_id.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ }
+
+ impl Eq for __c_anonymous_ifr_ifru6 {}
+
+ impl ::fmt::Debug for __c_anonymous_ifr_ifru6 {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("__c_anonymous_ifr_ifru6")
+ .field("ifru_addr", unsafe { &self.ifru_addr })
+ .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr })
+ .field("ifru_flags", unsafe { &self.ifru_flags })
+ .field("ifru_flags6", unsafe { &self.ifru_flags6 })
+ .field("ifru_metrics", unsafe { &self.ifru_metrics })
+ .field("ifru_intval", unsafe { &self.ifru_intval })
+ .field("ifru_data", unsafe { &self.ifru_data })
+ .field("ifru_scope_id", unsafe { &self.ifru_scope_id })
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for __c_anonymous_ifr_ifru6 {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ unsafe {
+ self.ifru_addr.hash(state);
+ self.ifru_dstaddr.hash(state);
+ self.ifru_flags.hash(state);
+ self.ifru_flags6.hash(state);
+ self.ifru_metrics.hash(state);
+ self.ifru_intval.hash(state);
+ self.ifru_data.hash(state);
+ self.ifru_scope_id.hash(state);
+ }
+ }
+ }
+
+ impl PartialEq for in6_ifreq {
+ fn eq(&self, other: &in6_ifreq) -> bool {
+ self.ifr_name == other.ifr_name
+ && self.ifr_ifru == other.ifr_ifru
+ }
+ }
+
+ impl Eq for in6_ifreq {}
+
+ impl ::fmt::Debug for in6_ifreq {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("in6_ifreq")
+ .field("ifr_name", &self.ifr_name)
+ .field("ifr_ifru", &self.ifr_ifru)
+ .finish()
+ }
+ }
}
}
@@ -4085,6 +4245,8 @@ pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
+pub const SCOPE6_ID_MAX: ::size_t = 16;
+
pub const SHUT_RD: ::c_int = 0;
pub const SHUT_WR: ::c_int = 1;
pub const SHUT_RDWR: ::c_int = 2;
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 29636554bd5e3..126fd3bd763bc 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -213,6 +213,7 @@ fn test_apple(target: &str) {
"netinet/ip.h",
"netinet/tcp.h",
"netinet/udp.h",
+ "netinet6/in6_var.h",
"os/lock.h",
"os/signpost.h",
"poll.h",
@@ -351,6 +352,7 @@ fn test_apple(target: &str) {
// MAXPATHLEN is too big for auto-derive traits on arrays.
("vnode_info_path", "vip_path") => true,
("ifreq", "ifr_ifru") => true,
+ ("in6_ifreq", "ifr_ifru") => true,
("ifkpi", "ifk_data") => true,
("ifconf", "ifc_ifcu") => true,
_ => false,
diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt
index bd076264a1212..b4e91dd083463 100644
--- a/libc-test/semver/apple.txt
+++ b/libc-test/semver/apple.txt
@@ -1861,6 +1861,7 @@ getxattr
glob
glob_t
globfree
+icmp6_ifstat
iconv_t
id_t
idtype_t
@@ -1874,6 +1875,9 @@ ifkpi
ifreq
image_offset
in6_pktinfo
+in6_addrlifetime
+in6_ifreq
+in6_ifstat
in_pktinfo
initgroups
integer_t
@@ -2157,6 +2161,7 @@ timeval32
timex
truncate
ttyname_r
+u_quad_t
ucontext_t
unmount
useconds_t
|
Why in6_ifreq does not exist on macOS
<!--
Please provide the below information:
* the target triple
* link to the documentation of the API showing the type signatures, how to use
it, etc.
In general, just please consider that the people who can help you are all very
busy, they will be helping you in their free time, there are a lot of people in
need of help so they need to prioritize to which issues they devote their free
time, etc. So try to give most of the information upfront, be concise, show
small self-contained examples (nobody has time to create a new cargo project,
set up dependencies,...), etc. Help us help you.
-->
https://github.com/apple-oss-distributions/xnu/blob/main/bsd/netinet6/in6_var.h
It seems that all related ipv6 structures in this header file do not exist
|
2024-03-10T23:14:34Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
|
rust-lang/libc
| 3,604
|
rust-lang__libc-3604
|
[
"3598"
] |
6f47f51387d88d8f394d2a4ca9f1d1bbe1f9d91c
|
diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs
index 1f4f796f2a94a..aa29267f9db50 100644
--- a/src/unix/linux_like/android/b32/mod.rs
+++ b/src/unix/linux_like/android/b32/mod.rs
@@ -9,6 +9,7 @@ pub type sigset_t = ::c_ulong;
pub type socklen_t = i32;
pub type time64_t = i64;
pub type __u64 = ::c_ulonglong;
+pub type __s64 = ::c_longlong;
s! {
pub struct sigaction {
diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs
index 1deb3586d8cef..46cde40ae4c73 100644
--- a/src/unix/linux_like/android/b64/aarch64/mod.rs
+++ b/src/unix/linux_like/android/b64/aarch64/mod.rs
@@ -1,6 +1,7 @@
pub type c_char = u8;
pub type wchar_t = u32;
pub type __u64 = ::c_ulonglong;
+pub type __s64 = ::c_longlong;
s! {
pub struct stat {
diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs
index 5142b3d4fca44..405b9ac005439 100644
--- a/src/unix/linux_like/android/b64/riscv64/mod.rs
+++ b/src/unix/linux_like/android/b64/riscv64/mod.rs
@@ -2,6 +2,7 @@ pub type c_char = i8;
pub type wchar_t = u32;
pub type greg_t = i64;
pub type __u64 = ::c_ulonglong;
+pub type __s64 = ::c_longlong;
s! {
pub struct stat {
diff --git a/src/unix/linux_like/android/b64/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs
index ee12fa7cc1ca3..9062e2feea701 100644
--- a/src/unix/linux_like/android/b64/x86_64/mod.rs
+++ b/src/unix/linux_like/android/b64/x86_64/mod.rs
@@ -2,6 +2,7 @@ pub type c_char = i8;
pub type wchar_t = i32;
pub type greg_t = i64;
pub type __u64 = ::c_ulonglong;
+pub type __s64 = ::c_longlong;
s! {
pub struct stat {
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index 31f84c106a590..ef8c2ccaa4fde 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -510,8 +510,40 @@ s! {
pub ifr6_addr: ::in6_addr,
pub ifr6_prefixlen: u32,
pub ifr6_ifindex: ::c_int,
- }
+ }
+
+ pub struct statx {
+ pub stx_mask: ::__u32,
+ pub stx_blksize: ::__u32,
+ pub stx_attributes: ::__u64,
+ pub stx_nlink: ::__u32,
+ pub stx_uid: ::__u32,
+ pub stx_gid: ::__u32,
+ pub stx_mode: ::__u16,
+ __statx_pad1: [::__u16; 1],
+ pub stx_ino: ::__u64,
+ pub stx_size: ::__u64,
+ pub stx_blocks: ::__u64,
+ pub stx_attributes_mask: ::__u64,
+ pub stx_atime: ::statx_timestamp,
+ pub stx_btime: ::statx_timestamp,
+ pub stx_ctime: ::statx_timestamp,
+ pub stx_mtime: ::statx_timestamp,
+ pub stx_rdev_major: ::__u32,
+ pub stx_rdev_minor: ::__u32,
+ pub stx_dev_major: ::__u32,
+ pub stx_dev_minor: ::__u32,
+ pub stx_mnt_id: ::__u64,
+ pub stx_dio_mem_align: ::__u32,
+ pub stx_dio_offset_align: ::__u32,
+ __statx_pad3: [::__u64; 12],
+ }
+ pub struct statx_timestamp {
+ pub tv_sec: ::__s64,
+ pub tv_nsec: ::__u32,
+ pub __reserved: ::__s32,
+ }
}
s_no_extra_traits! {
@@ -4014,6 +4046,22 @@ extern "C" {
) -> ::size_t;
pub fn fflush_unlocked(stream: *mut ::FILE) -> ::c_int;
pub fn fgets_unlocked(buf: *mut ::c_char, size: ::c_int, stream: *mut ::FILE) -> *mut ::c_char;
+
+ pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
+ pub fn renameat2(
+ olddirfd: ::c_int,
+ oldpath: *const ::c_char,
+ newdirfd: ::c_int,
+ newpath: *const ::c_char,
+ flags: ::c_uint,
+ ) -> ::c_int;
+ pub fn statx(
+ dirfd: ::c_int,
+ pathname: *const c_char,
+ flags: ::c_int,
+ mask: ::c_uint,
+ statxbuf: *mut statx,
+ ) -> ::c_int;
}
cfg_if! {
|
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 1a72e195f23c4..7b3aa70a406d9 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1913,7 +1913,7 @@ fn test_android(target: &str) {
"__system_property_wait" => true,
// Added in API level 30, but tests use level 28.
- "mlock2" => true,
+ "memfd_create" | "mlock2" | "renameat2" | "statx" | "statx_timestamp" => true,
// Added in glibc 2.25.
"getentropy" => true,
diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt
index 1a5321d4b486a..9fb550325d511 100644
--- a/libc-test/semver/android.txt
+++ b/libc-test/semver/android.txt
@@ -3370,6 +3370,7 @@ memalign
memchr
memcmp
memcpy
+memfd_create
memmem
memmove
memrchr
@@ -3385,6 +3386,7 @@ mknodat
mkstemp
mktime
mlock
+mlock2
mlockall
mmap
mmap64
@@ -3574,6 +3576,7 @@ remove
removexattr
rename
renameat
+renameat2
res_init
rewind
rewinddir
@@ -3698,6 +3701,8 @@ statfs
statfs64
statvfs
statvfs64
+statx
+statx_timestamp
strcasecmp
strcasestr
strcat
|
memfd_create on android api level 30 and above
<!--
Please provide the below information:
* the target triple
* link to the documentation of the API showing the type signatures, how to use
it, etc.
In general, just please consider that the people who can help you are all very
busy, they will be helping you in their free time, there are a lot of people in
need of help so they need to prioritize to which issues they devote their free
time, etc. So try to give most of the information upfront, be concise, show
small self-contained examples (nobody has time to create a new cargo project,
set up dependencies,...), etc. Help us help you.
-->
Looks like this function is now available in android libc for api level 30 and above. check the bionic libc status [docs](https://android.googlesource.com/platform/bionic/+/master/docs/status.md). There are few other functions listed there too but this is the only one I tested by building a rust program against the latest ndk(r26c).
prototype is
```
pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
```
|
2024-02-29T20:06:40Z
|
0.2
|
78d6dcb4b8d60c9ae0f2c59444613ecf5a2bf919
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 2