Skip to content

Commit

Permalink
Merge pull request #4091 from tgross35/backport-scallion
Browse files Browse the repository at this point in the history
[0.2] Backports
  • Loading branch information
tgross35 authored Nov 18, 2024
2 parents 78d6dcb + 4f2cde3 commit 53db662
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 29 deletions.
2 changes: 1 addition & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3469,6 +3469,7 @@ memalign
memchr
memcmp
memcpy
memfd_create
memmem
memmove
memrchr
Expand All @@ -3484,6 +3485,7 @@ mknodat
mkstemp
mktime
mlock
mlock2
mlockall
mmap
mmap64
Expand Down Expand Up @@ -3672,6 +3674,7 @@ remove
removexattr
rename
renameat
renameat2
res_init
rewind
rewinddir
Expand Down Expand Up @@ -3797,6 +3800,8 @@ statfs
statfs64
statvfs
statvfs64
statx
statx_timestamp
strcasecmp
strcasestr
strcat
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ accept
access
addrinfo
alarm
aligned_alloc
atexit
atof
atoi
Expand Down
2 changes: 1 addition & 1 deletion src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
9 changes: 5 additions & 4 deletions src/unix/aix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 })
Expand All @@ -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)
Expand All @@ -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 })
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions src/unix/aix/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/bsd/netbsdlike/netbsd/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/android/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/android/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/android/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/android/b64/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
50 changes: 49 additions & 1 deletion src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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! {
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux_like/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/unix/newlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/unix/nto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/unix/redox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 53db662

Please sign in to comment.