Skip to content

Commit 53db662

Browse files
authored
Merge pull request #4091 from tgross35/backport-scallion
[0.2] Backports
2 parents 78d6dcb + 4f2cde3 commit 53db662

File tree

22 files changed

+90
-29
lines changed

22 files changed

+90
-29
lines changed

libc-test/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2075,7 +2075,7 @@ fn test_android(target: &str) {
20752075
"__system_property_wait" => true,
20762076

20772077
// Added in API level 30, but tests use level 28.
2078-
"mlock2" => true,
2078+
"memfd_create" | "mlock2" | "renameat2" | "statx" | "statx_timestamp" => true,
20792079

20802080
// Added in glibc 2.25.
20812081
"getentropy" => true,

libc-test/semver/android.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3469,6 +3469,7 @@ memalign
34693469
memchr
34703470
memcmp
34713471
memcpy
3472+
memfd_create
34723473
memmem
34733474
memmove
34743475
memrchr
@@ -3484,6 +3485,7 @@ mknodat
34843485
mkstemp
34853486
mktime
34863487
mlock
3488+
mlock2
34873489
mlockall
34883490
mmap
34893491
mmap64
@@ -3672,6 +3674,7 @@ remove
36723674
removexattr
36733675
rename
36743676
renameat
3677+
renameat2
36753678
res_init
36763679
rewind
36773680
rewinddir
@@ -3797,6 +3800,8 @@ statfs
37973800
statfs64
37983801
statvfs
37993802
statvfs64
3803+
statx
3804+
statx_timestamp
38003805
strcasecmp
38013806
strcasestr
38023807
strcat

libc-test/semver/unix.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ accept
453453
access
454454
addrinfo
455455
alarm
456+
aligned_alloc
456457
atexit
457458
atof
458459
atoi

src/fuchsia/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ s! {
382382
}
383383

384384
pub struct fd_set {
385-
fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
385+
fds_bits: [::c_ulong; FD_SETSIZE as usize / ULONG_SIZE],
386386
}
387387

388388
pub struct tm {

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ cfg_if! {
4646
#[allow(unused_imports)]
4747
use core::clone::Clone;
4848
#[allow(unused_imports)]
49+
use core::ffi;
50+
#[allow(unused_imports)]
4951
use core::fmt;
5052
#[allow(unused_imports)]
5153
use core::hash;

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ macro_rules! s_paren {
9898
($(
9999
$(#[$attr:meta])*
100100
pub struct $i:ident ( $($field:tt)* );
101-
)* ) => ($(
101+
)*) => ($(
102102
__item! {
103103
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
104104
#[derive(Copy, Clone)]

src/unix/aix/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub type posix_spawn_file_actions_t = *mut ::c_char;
6060
pub type iconv_t = *mut ::c_void;
6161

6262
e! {
63+
#[repr(u32)]
6364
pub enum uio_rw {
6465
UIO_READ = 0,
6566
UIO_WRITE,
@@ -573,7 +574,7 @@ cfg_if! {
573574
}
574575
impl Eq for __sigaction_sa_union {}
575576
impl ::fmt::Debug for __sigaction_sa_union {
576-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
577+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
577578
f.debug_struct("__sigaction_sa_union")
578579
.field("__su_handler", unsafe { &self.__su_handler })
579580
.field("__su_sigaction", unsafe { &self.__su_sigaction })
@@ -598,7 +599,7 @@ cfg_if! {
598599
}
599600
impl Eq for sigaction {}
600601
impl ::fmt::Debug for sigaction {
601-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
602+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
602603
f.debug_struct("sigaction")
603604
.field("sa_union", &self.sa_union)
604605
.field("sa_mask", &self.sa_mask)
@@ -625,7 +626,7 @@ cfg_if! {
625626
}
626627
impl Eq for __poll_ctl_ext_u {}
627628
impl ::fmt::Debug for __poll_ctl_ext_u {
628-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
629+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
629630
f.debug_struct("__poll_ctl_ext_u")
630631
.field("addr", unsafe { &self.addr })
631632
.field("data32", unsafe { &self.data32 })
@@ -655,7 +656,7 @@ cfg_if! {
655656
}
656657
impl Eq for poll_ctl_ext {}
657658
impl ::fmt::Debug for poll_ctl_ext {
658-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
659+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
659660
f.debug_struct("poll_ctl_ext")
660661
.field("version", &self.version)
661662
.field("command", &self.command)

src/unix/aix/powerpc64.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ cfg_if! {
307307
}
308308
impl Eq for siginfo_t {}
309309
impl ::fmt::Debug for siginfo_t {
310-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
310+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
311311
f.debug_struct("siginfo_t")
312312
.field("si_signo", &self.si_signo)
313313
.field("si_errno", &self.si_errno)
@@ -347,7 +347,7 @@ cfg_if! {
347347
}
348348
impl Eq for _kernel_simple_lock {}
349349
impl ::fmt::Debug for _kernel_simple_lock {
350-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
350+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
351351
f.debug_struct("_kernel_simple_lock")
352352
.field("_slock", unsafe { &self._slock })
353353
.field("_slockp", unsafe { &self._slockp })
@@ -410,12 +410,12 @@ cfg_if! {
410410
&& self.f_fnamep == other.f_fnamep
411411
&& self.f_fdata == other.f_fdata
412412
&& self.f_lock == other.f_lock
413-
&& self.f_offset_lock == other.f_offset_lock;
413+
&& self.f_offset_lock == other.f_offset_lock
414414
}
415415
}
416416
impl Eq for file {}
417417
impl ::fmt::Debug for file {
418-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
418+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
419419
f.debug_struct("file")
420420
.field("f_flag", &self.f_flag)
421421
.field("f_count", &self.f_count)
@@ -466,7 +466,7 @@ cfg_if! {
466466
}
467467
impl Eq for __ld_info_file {}
468468
impl ::fmt::Debug for __ld_info_file {
469-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
469+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
470470
f.debug_struct("__ld_info_file")
471471
.field("_ldinfo_fd", unsafe { &self._ldinfo_fd })
472472
.field("_ldinfo_fp", unsafe { &self._ldinfo_fp })
@@ -498,7 +498,7 @@ cfg_if! {
498498
}
499499
impl Eq for ld_info {}
500500
impl ::fmt::Debug for ld_info {
501-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
501+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
502502
f.debug_struct("ld_info")
503503
.field("ldinfo_next", &self.ldinfo_next)
504504
.field("ldinfo_flags", &self.ldinfo_flags)
@@ -535,7 +535,7 @@ cfg_if! {
535535
}
536536
impl Eq for __pollfd_ext_u {}
537537
impl ::fmt::Debug for __pollfd_ext_u {
538-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
538+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
539539
f.debug_struct("__pollfd_ext_u")
540540
.field("addr", unsafe { &self.addr })
541541
.field("data32", unsafe { &self.data32 })
@@ -563,7 +563,7 @@ cfg_if! {
563563
}
564564
impl Eq for pollfd_ext {}
565565
impl ::fmt::Debug for pollfd_ext {
566-
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
566+
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
567567
f.debug_struct("pollfd_ext")
568568
.field("fd", &self.fd)
569569
.field("events", &self.events)

src/unix/bsd/apple/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ s_no_extra_traits! {
15951595
_os_unfair_lock_opaque: u32,
15961596
}
15971597

1598-
#[repr(packed(1))]
1598+
#[repr(packed(1))]
15991599
pub struct sockaddr_vm {
16001600
pub svm_len: ::c_uchar,
16011601
pub svm_family: ::sa_family_t,
@@ -1722,8 +1722,7 @@ cfg_if! {
17221722
}
17231723
impl Eq for semun {}
17241724
impl ::fmt::Debug for semun {
1725-
fn fmt(&self, f: &mut ::fmt::Formatter)
1726-
-> ::fmt::Result {
1725+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
17271726
f.debug_struct("semun")
17281727
.field("val", unsafe { &self.val })
17291728
.finish()
@@ -1775,7 +1774,6 @@ cfg_if! {
17751774
&& self.udata == other.udata
17761775
}
17771776
}
1778-
17791777
impl Eq for kevent {}
17801778
impl ::fmt::Debug for kevent {
17811779
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {

src/unix/bsd/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ s! {
6060
pub struct fd_set {
6161
#[cfg(all(target_pointer_width = "64",
6262
any(target_os = "freebsd", target_os = "dragonfly")))]
63-
fds_bits: [i64; FD_SETSIZE / 64],
63+
fds_bits: [i64; FD_SETSIZE as usize / 64],
6464
#[cfg(not(all(target_pointer_width = "64",
6565
any(target_os = "freebsd", target_os = "dragonfly"))))]
66-
fds_bits: [i32; FD_SETSIZE / 32],
66+
fds_bits: [i32; FD_SETSIZE as usize / 32],
6767
}
6868

6969
pub struct tm {
@@ -129,7 +129,7 @@ s_no_extra_traits! {
129129
pub struct sockaddr_un {
130130
pub sun_len: u8,
131131
pub sun_family: sa_family_t,
132-
pub sun_path: [c_char; 104]
132+
pub sun_path: [::c_char; 104]
133133
}
134134

135135
pub struct utsname {

src/unix/bsd/netbsdlike/netbsd/aarch64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ cfg_if! {
8181
}
8282

8383
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
84+
8485
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0;
8586
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1;
8687
pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 2;

src/unix/linux_like/android/b32/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub type sigset_t = ::c_ulong;
99
pub type socklen_t = i32;
1010
pub type time64_t = i64;
1111
pub type __u64 = ::c_ulonglong;
12+
pub type __s64 = ::c_longlong;
1213

1314
s! {
1415
pub struct sigaction {

src/unix/linux_like/android/b64/aarch64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub type c_char = u8;
22
pub type wchar_t = u32;
33
pub type __u64 = ::c_ulonglong;
4+
pub type __s64 = ::c_longlong;
45

56
s! {
67
pub struct stat {

src/unix/linux_like/android/b64/riscv64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub type c_char = i8;
22
pub type wchar_t = u32;
33
pub type greg_t = i64;
44
pub type __u64 = ::c_ulonglong;
5+
pub type __s64 = ::c_longlong;
56

67
s! {
78
pub struct stat {

src/unix/linux_like/android/b64/x86_64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub type c_char = i8;
22
pub type wchar_t = i32;
33
pub type greg_t = i64;
44
pub type __u64 = ::c_ulonglong;
5+
pub type __s64 = ::c_longlong;
56

67
s! {
78
pub struct stat {

src/unix/linux_like/android/mod.rs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,40 @@ s! {
514514
pub ifr6_addr: ::in6_addr,
515515
pub ifr6_prefixlen: u32,
516516
pub ifr6_ifindex: ::c_int,
517-
}
517+
}
518+
519+
pub struct statx {
520+
pub stx_mask: ::__u32,
521+
pub stx_blksize: ::__u32,
522+
pub stx_attributes: ::__u64,
523+
pub stx_nlink: ::__u32,
524+
pub stx_uid: ::__u32,
525+
pub stx_gid: ::__u32,
526+
pub stx_mode: ::__u16,
527+
__statx_pad1: [::__u16; 1],
528+
pub stx_ino: ::__u64,
529+
pub stx_size: ::__u64,
530+
pub stx_blocks: ::__u64,
531+
pub stx_attributes_mask: ::__u64,
532+
pub stx_atime: ::statx_timestamp,
533+
pub stx_btime: ::statx_timestamp,
534+
pub stx_ctime: ::statx_timestamp,
535+
pub stx_mtime: ::statx_timestamp,
536+
pub stx_rdev_major: ::__u32,
537+
pub stx_rdev_minor: ::__u32,
538+
pub stx_dev_major: ::__u32,
539+
pub stx_dev_minor: ::__u32,
540+
pub stx_mnt_id: ::__u64,
541+
pub stx_dio_mem_align: ::__u32,
542+
pub stx_dio_offset_align: ::__u32,
543+
__statx_pad3: [::__u64; 12],
544+
}
518545

546+
pub struct statx_timestamp {
547+
pub tv_sec: ::__s64,
548+
pub tv_nsec: ::__u32,
549+
pub __reserved: ::__s32,
550+
}
519551
}
520552

521553
s_no_extra_traits! {
@@ -4169,6 +4201,22 @@ extern "C" {
41694201
pub fn fgets_unlocked(buf: *mut ::c_char, size: ::c_int, stream: *mut ::FILE) -> *mut ::c_char;
41704202

41714203
pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int;
4204+
4205+
pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
4206+
pub fn renameat2(
4207+
olddirfd: ::c_int,
4208+
oldpath: *const ::c_char,
4209+
newdirfd: ::c_int,
4210+
newpath: *const ::c_char,
4211+
flags: ::c_uint,
4212+
) -> ::c_int;
4213+
pub fn statx(
4214+
dirfd: ::c_int,
4215+
pathname: *const c_char,
4216+
flags: ::c_int,
4217+
mask: ::c_uint,
4218+
statxbuf: *mut statx,
4219+
) -> ::c_int;
41724220
}
41734221

41744222
cfg_if! {

src/unix/linux_like/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ s! {
8585
}
8686

8787
pub struct fd_set {
88-
fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
88+
fds_bits: [::c_ulong; FD_SETSIZE as usize / ULONG_SIZE],
8989
}
9090

9191
pub struct tm {

src/unix/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ extern "C" {
940940
pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
941941
pub fn pipe(fds: *mut ::c_int) -> ::c_int;
942942
pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int;
943+
pub fn aligned_alloc(alignment: ::size_t, size: ::size_t) -> *mut ::c_void;
943944
#[cfg_attr(
944945
all(target_os = "macos", target_arch = "x86"),
945946
link_name = "read$UNIX2003"

src/unix/newlib/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ s! {
183183
}
184184

185185
pub struct fd_set { // Unverified
186-
fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
186+
fds_bits: [::c_ulong; FD_SETSIZE as usize / ULONG_SIZE],
187187
}
188188

189189
pub struct passwd { // Unverified

src/unix/nto/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ s! {
154154
}
155155

156156
pub struct fd_set {
157-
fds_bits: [::c_uint; 2 * FD_SETSIZE / ULONG_SIZE],
157+
fds_bits: [::c_uint; 2 * FD_SETSIZE as usize / ULONG_SIZE],
158158
}
159159

160160
pub struct tm {

src/unix/redox/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ s! {
116116
}
117117

118118
pub struct fd_set {
119-
fds_bits: [::c_ulong; ::FD_SETSIZE / ULONG_SIZE],
119+
fds_bits: [::c_ulong; ::FD_SETSIZE as usize / ULONG_SIZE],
120120
}
121121

122122
pub struct in_addr {

src/unix/solarish/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,9 @@ s_no_extra_traits! {
513513

514514
pub struct fd_set {
515515
#[cfg(target_pointer_width = "64")]
516-
fds_bits: [i64; FD_SETSIZE / 64],
516+
fds_bits: [i64; FD_SETSIZE as usize / 64],
517517
#[cfg(target_pointer_width = "32")]
518-
fds_bits: [i32; FD_SETSIZE / 32],
518+
fds_bits: [i32; FD_SETSIZE as usize / 32],
519519
}
520520

521521
pub struct sockaddr_storage {

0 commit comments

Comments
 (0)