From 2abfdb4123f55e3475d8c1b10436682b511de09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 27 Dec 2020 17:59:57 +0100 Subject: Port mqueue to x32 Test fix obtained from https://github.com/nix-rust/nix/issues/1384#issuecomment-774708486 --- src/mqueue.rs | 21 ++++++++++++++------- test/test_mq.rs | 18 ++++++++---------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/mqueue.rs b/src/mqueue.rs index 122705a5..0215de5a 100644 --- a/src/mqueue.rs +++ b/src/mqueue.rs @@ -5,7 +5,7 @@ use crate::Result; use crate::errno::Errno; -use libc::{self, c_char, c_long, mqd_t, size_t}; +use libc::{self, c_char, mqd_t, size_t}; use std::ffi::CString; use crate::sys::stat::Mode; use std::mem; @@ -34,11 +34,18 @@ pub struct MqAttr { mq_attr: libc::mq_attr, } +// x32 compatibility +// See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +pub type mq_attr_member_t = i64; +#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] +pub type mq_attr_member_t = libc::c_long; + impl MqAttr { - pub fn new(mq_flags: c_long, - mq_maxmsg: c_long, - mq_msgsize: c_long, - mq_curmsgs: c_long) + pub fn new(mq_flags: mq_attr_member_t, + mq_maxmsg: mq_attr_member_t, + mq_msgsize: mq_attr_member_t, + mq_curmsgs: mq_attr_member_t) -> MqAttr { let mut attr = mem::MaybeUninit::::uninit(); @@ -52,7 +59,7 @@ impl MqAttr { } } - pub fn flags(&self) -> c_long { + pub fn flags(&self) -> mq_attr_member_t { self.mq_attr.mq_flags } } @@ -150,7 +157,7 @@ pub fn mq_setattr(mqd: mqd_t, newattr: &MqAttr) -> Result { /// Returns the old attributes pub fn mq_set_nonblock(mqd: mqd_t) -> Result { let oldattr = mq_getattr(mqd)?; - let newattr = MqAttr::new(c_long::from(MQ_OFlag::O_NONBLOCK.bits()), + let newattr = MqAttr::new(mq_attr_member_t::from(MQ_OFlag::O_NONBLOCK.bits()), oldattr.mq_attr.mq_maxmsg, oldattr.mq_attr.mq_msgsize, oldattr.mq_attr.mq_curmsgs); diff --git a/test/test_mq.rs b/test/test_mq.rs index ecee2009..1667a35b 100644 --- a/test/test_mq.rs +++ b/test/test_mq.rs @@ -1,17 +1,15 @@ -use libc::c_long; - use std::ffi::CString; use std::str; use nix::errno::Errno::*; use nix::Error::Sys; -use nix::mqueue::{mq_open, mq_close, mq_send, mq_receive}; +use nix::mqueue::{mq_open, mq_close, mq_send, mq_receive, mq_attr_member_t}; use nix::mqueue::{MqAttr, MQ_OFlag}; use nix::sys::stat::Mode; #[test] fn test_mq_send_and_receive() { - const MSG_SIZE: c_long = 32; + const MSG_SIZE: mq_attr_member_t = 32; let attr = MqAttr::new(0, 10, MSG_SIZE, 0); let mq_name= &CString::new(b"/a_nix_test_queue".as_ref()).unwrap(); @@ -43,7 +41,7 @@ fn test_mq_send_and_receive() { #[cfg(not(any(target_os = "netbsd")))] fn test_mq_getattr() { use nix::mqueue::mq_getattr; - const MSG_SIZE: c_long = 32; + const MSG_SIZE: mq_attr_member_t = 32; let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0); let mq_name = &CString::new(b"/attr_test_get_attr".as_ref()).unwrap(); let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY; @@ -66,7 +64,7 @@ fn test_mq_getattr() { #[cfg_attr(any(target_arch = "mips", target_arch = "mips64"), ignore)] fn test_mq_setattr() { use nix::mqueue::{mq_getattr, mq_setattr}; - const MSG_SIZE: c_long = 32; + const MSG_SIZE: mq_attr_member_t = 32; let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0); let mq_name = &CString::new(b"/attr_test_get_attr".as_ref()).unwrap(); let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY; @@ -87,7 +85,7 @@ fn test_mq_setattr() { // O_NONBLOCK can be set (see tests below) assert_ne!(new_attr_get, new_attr); - let new_attr_non_blocking = MqAttr::new(MQ_OFlag::O_NONBLOCK.bits() as c_long, 10, MSG_SIZE, 0); + let new_attr_non_blocking = MqAttr::new(MQ_OFlag::O_NONBLOCK.bits() as mq_attr_member_t, 10, MSG_SIZE, 0); mq_setattr(mqd, &new_attr_non_blocking).unwrap(); let new_attr_get = mq_getattr(mqd).unwrap(); @@ -103,7 +101,7 @@ fn test_mq_setattr() { #[cfg_attr(any(target_arch = "mips", target_arch = "mips64"), ignore)] fn test_mq_set_nonblocking() { use nix::mqueue::{mq_getattr, mq_set_nonblock, mq_remove_nonblock}; - const MSG_SIZE: c_long = 32; + const MSG_SIZE: mq_attr_member_t = 32; let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0); let mq_name = &CString::new(b"/attr_test_get_attr".as_ref()).unwrap(); let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY; @@ -116,7 +114,7 @@ fn test_mq_set_nonblocking() { let mqd = r.unwrap(); mq_set_nonblock(mqd).unwrap(); let new_attr = mq_getattr(mqd); - assert_eq!(new_attr.unwrap().flags(), MQ_OFlag::O_NONBLOCK.bits() as c_long); + assert_eq!(new_attr.unwrap().flags(), MQ_OFlag::O_NONBLOCK.bits() as mq_attr_member_t); mq_remove_nonblock(mqd).unwrap(); let new_attr = mq_getattr(mqd); assert_eq!(new_attr.unwrap().flags(), 0); @@ -127,7 +125,7 @@ fn test_mq_set_nonblocking() { #[cfg(not(any(target_os = "netbsd")))] fn test_mq_unlink() { use nix::mqueue::mq_unlink; - const MSG_SIZE: c_long = 32; + const MSG_SIZE: mq_attr_member_t = 32; let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0); let mq_name_opened = &CString::new(b"/mq_unlink_test".as_ref()).unwrap(); let mq_name_not_opened = &CString::new(b"/mq_unlink_test".as_ref()).unwrap(); -- cgit v1.2.3 From 1f69c1da2facf7d5d14d290081d58813744c687e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 27 Dec 2020 18:00:29 +0100 Subject: Port sysinfo to x32 --- src/sys/sysinfo.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sys/sysinfo.rs b/src/sys/sysinfo.rs index f4b82798..222a2fc0 100644 --- a/src/sys/sysinfo.rs +++ b/src/sys/sysinfo.rs @@ -10,6 +10,12 @@ use crate::errno::Errno; #[repr(transparent)] pub struct SysInfo(libc::sysinfo); +// The fields are c_ulong on 32-bit linux, u64 on 64-bit linux; x32's ulong is u32 +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +type mem_blocks_t = u64; +#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] +type mem_blocks_t = libc::c_ulong; + impl SysInfo { /// Returns the load average tuple. /// @@ -58,7 +64,7 @@ impl SysInfo { self.scale_mem(self.0.freeram) } - fn scale_mem(&self, units: libc::c_ulong) -> u64 { + fn scale_mem(&self, units: mem_blocks_t) -> u64 { units as u64 * self.0.mem_unit as u64 } } -- cgit v1.2.3 From 90b273439ee02cd484bc73d8201472a889148a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 27 Dec 2020 18:01:12 +0100 Subject: Port timespec to x32 --- src/sys/time.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/sys/time.rs b/src/sys/time.rs index bdcfe3c9..7546d1b3 100644 --- a/src/sys/time.rs +++ b/src/sys/time.rs @@ -1,7 +1,7 @@ use std::{cmp, fmt, ops}; use std::time::Duration; use std::convert::From; -use libc::{c_long, timespec, timeval}; +use libc::{timespec, timeval}; #[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848 pub use libc::{time_t, suseconds_t}; @@ -62,6 +62,13 @@ const TS_MAX_SECONDS: i64 = ::std::isize::MAX as i64; const TS_MIN_SECONDS: i64 = -TS_MAX_SECONDS; +// x32 compatibility +// See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +type timespec_tv_nsec_t = i64; +#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] +type timespec_tv_nsec_t = libc::c_long; + impl From for TimeSpec { fn from(ts: timespec) -> Self { Self(ts) @@ -73,7 +80,7 @@ impl From for TimeSpec { #[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848 TimeSpec(timespec { tv_sec: duration.as_secs() as time_t, - tv_nsec: duration.subsec_nanos() as c_long + tv_nsec: duration.subsec_nanos() as timespec_tv_nsec_t }) } } @@ -148,7 +155,7 @@ impl TimeValLike for TimeSpec { "TimeSpec out of bounds"); #[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848 TimeSpec(timespec {tv_sec: secs as time_t, - tv_nsec: nanos as c_long }) + tv_nsec: nanos as timespec_tv_nsec_t }) } fn num_seconds(&self) -> i64 { @@ -175,9 +182,9 @@ impl TimeValLike for TimeSpec { } impl TimeSpec { - fn nanos_mod_sec(&self) -> c_long { + fn nanos_mod_sec(&self) -> timespec_tv_nsec_t { if self.tv_sec() < 0 && self.tv_nsec() > 0 { - self.tv_nsec() - NANOS_PER_SEC as c_long + self.tv_nsec() - NANOS_PER_SEC as timespec_tv_nsec_t } else { self.tv_nsec() } @@ -188,7 +195,7 @@ impl TimeSpec { self.0.tv_sec } - pub fn tv_nsec(&self) -> c_long { + pub fn tv_nsec(&self) -> timespec_tv_nsec_t { self.0.tv_nsec } } -- cgit v1.2.3 From f13f57a03344fe8924fb71541353742e2db20695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 27 Dec 2020 18:24:12 +0100 Subject: Port statfs to x32 --- src/sys/statfs.rs | 115 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 52 deletions(-) diff --git a/src/sys/statfs.rs b/src/sys/statfs.rs index 924d293f..27b72592 100644 --- a/src/sys/statfs.rs +++ b/src/sys/statfs.rs @@ -16,79 +16,85 @@ pub type fsid_t = libc::fsid_t; pub struct Statfs(libc::statfs); #[cfg(target_os = "freebsd")] -#[derive(Eq, Copy, Clone, PartialEq, Debug)] -pub struct FsType(pub u32); +type fs_type_t = u32; #[cfg(target_os = "android")] -#[derive(Eq, Copy, Clone, PartialEq, Debug)] -pub struct FsType(pub libc::c_ulong); +type fs_type_t = libc::c_ulong; #[cfg(all(target_os = "linux", target_arch = "s390x"))] -#[derive(Eq, Copy, Clone, PartialEq, Debug)] -pub struct FsType(pub u32); +type fs_type_t = libc::c_uint; #[cfg(all(target_os = "linux", target_env = "musl"))] -#[derive(Eq, Copy, Clone, PartialEq, Debug)] -pub struct FsType(pub libc::c_ulong); +type fs_type_t = libc::c_ulong; #[cfg(all(target_os = "linux", not(any(target_arch = "s390x", target_env = "musl"))))] +type fs_type_t = libc::__fsword_t; + +#[cfg(any( + target_os = "freebsd", + target_os = "android", + all(target_os = "linux", target_arch = "s390x"), + all(target_os = "linux", target_env = "musl"), + all(target_os = "linux", not(any(target_arch = "s390x", target_env = "musl"))), +))] #[derive(Eq, Copy, Clone, PartialEq, Debug)] -pub struct FsType(pub libc::c_long); +pub struct FsType(pub fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const ADFS_SUPER_MAGIC: FsType = FsType(libc::ADFS_SUPER_MAGIC); +pub const ADFS_SUPER_MAGIC: FsType = FsType(libc::ADFS_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const AFFS_SUPER_MAGIC: FsType = FsType(libc::AFFS_SUPER_MAGIC); +pub const AFFS_SUPER_MAGIC: FsType = FsType(libc::AFFS_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const CODA_SUPER_MAGIC: FsType = FsType(libc::CODA_SUPER_MAGIC); +pub const CODA_SUPER_MAGIC: FsType = FsType(libc::CODA_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const CRAMFS_MAGIC: FsType = FsType(libc::CRAMFS_MAGIC); +pub const CRAMFS_MAGIC: FsType = FsType(libc::CRAMFS_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const EFS_SUPER_MAGIC: FsType = FsType(libc::EFS_SUPER_MAGIC); +pub const EFS_SUPER_MAGIC: FsType = FsType(libc::EFS_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const EXT2_SUPER_MAGIC: FsType = FsType(libc::EXT2_SUPER_MAGIC); +pub const EXT2_SUPER_MAGIC: FsType = FsType(libc::EXT2_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const EXT3_SUPER_MAGIC: FsType = FsType(libc::EXT3_SUPER_MAGIC); +pub const EXT3_SUPER_MAGIC: FsType = FsType(libc::EXT3_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const EXT4_SUPER_MAGIC: FsType = FsType(libc::EXT4_SUPER_MAGIC); +pub const EXT4_SUPER_MAGIC: FsType = FsType(libc::EXT4_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const HPFS_SUPER_MAGIC: FsType = FsType(libc::HPFS_SUPER_MAGIC); +pub const HPFS_SUPER_MAGIC: FsType = FsType(libc::HPFS_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const HUGETLBFS_MAGIC: FsType = FsType(libc::HUGETLBFS_MAGIC); +pub const HUGETLBFS_MAGIC: FsType = FsType(libc::HUGETLBFS_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const ISOFS_SUPER_MAGIC: FsType = FsType(libc::ISOFS_SUPER_MAGIC); +pub const ISOFS_SUPER_MAGIC: FsType = FsType(libc::ISOFS_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const JFFS2_SUPER_MAGIC: FsType = FsType(libc::JFFS2_SUPER_MAGIC); +pub const JFFS2_SUPER_MAGIC: FsType = FsType(libc::JFFS2_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const MINIX_SUPER_MAGIC: FsType = FsType(libc::MINIX_SUPER_MAGIC); +pub const MINIX_SUPER_MAGIC: FsType = FsType(libc::MINIX_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const MINIX_SUPER_MAGIC2: FsType = FsType(libc::MINIX_SUPER_MAGIC2); +pub const MINIX_SUPER_MAGIC2: FsType = FsType(libc::MINIX_SUPER_MAGIC2 as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const MINIX2_SUPER_MAGIC: FsType = FsType(libc::MINIX2_SUPER_MAGIC); +pub const MINIX2_SUPER_MAGIC: FsType = FsType(libc::MINIX2_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const MINIX2_SUPER_MAGIC2: FsType = FsType(libc::MINIX2_SUPER_MAGIC2); +pub const MINIX2_SUPER_MAGIC2: FsType = FsType(libc::MINIX2_SUPER_MAGIC2 as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const MSDOS_SUPER_MAGIC: FsType = FsType(libc::MSDOS_SUPER_MAGIC); +pub const MSDOS_SUPER_MAGIC: FsType = FsType(libc::MSDOS_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const NCP_SUPER_MAGIC: FsType = FsType(libc::NCP_SUPER_MAGIC); +pub const NCP_SUPER_MAGIC: FsType = FsType(libc::NCP_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const NFS_SUPER_MAGIC: FsType = FsType(libc::NFS_SUPER_MAGIC); +pub const NFS_SUPER_MAGIC: FsType = FsType(libc::NFS_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const OPENPROM_SUPER_MAGIC: FsType = FsType(libc::OPENPROM_SUPER_MAGIC); +pub const OPENPROM_SUPER_MAGIC: FsType = FsType(libc::OPENPROM_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const OVERLAYFS_SUPER_MAGIC: FsType = FsType(libc::OVERLAYFS_SUPER_MAGIC); +pub const OVERLAYFS_SUPER_MAGIC: FsType = FsType(libc::OVERLAYFS_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const PROC_SUPER_MAGIC: FsType = FsType(libc::PROC_SUPER_MAGIC); +pub const PROC_SUPER_MAGIC: FsType = FsType(libc::PROC_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const QNX4_SUPER_MAGIC: FsType = FsType(libc::QNX4_SUPER_MAGIC); +pub const QNX4_SUPER_MAGIC: FsType = FsType(libc::QNX4_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const REISERFS_SUPER_MAGIC: FsType = FsType(libc::REISERFS_SUPER_MAGIC); +pub const REISERFS_SUPER_MAGIC: FsType = FsType(libc::REISERFS_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const SMB_SUPER_MAGIC: FsType = FsType(libc::SMB_SUPER_MAGIC); +pub const SMB_SUPER_MAGIC: FsType = FsType(libc::SMB_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const TMPFS_MAGIC: FsType = FsType(libc::TMPFS_MAGIC); +pub const TMPFS_MAGIC: FsType = FsType(libc::TMPFS_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const USBDEVICE_SUPER_MAGIC: FsType = FsType(libc::USBDEVICE_SUPER_MAGIC); +pub const USBDEVICE_SUPER_MAGIC: FsType = FsType(libc::USBDEVICE_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const CGROUP_SUPER_MAGIC: FsType = FsType(libc::CGROUP_SUPER_MAGIC); +pub const CGROUP_SUPER_MAGIC: FsType = FsType(libc::CGROUP_SUPER_MAGIC as fs_type_t); #[cfg(all(target_os = "linux", not(target_env = "musl")))] -pub const CGROUP2_SUPER_MAGIC: FsType = FsType(libc::CGROUP2_SUPER_MAGIC); +pub const CGROUP2_SUPER_MAGIC: FsType = FsType(libc::CGROUP2_SUPER_MAGIC as fs_type_t); + impl Statfs { /// Magic code defining system type @@ -138,7 +144,7 @@ impl Statfs { /// Optimal transfer block size #[cfg(all(target_os = "linux", not(any(target_arch = "s390x", target_env = "musl"))))] - pub fn optimal_transfer_size(&self) -> libc::c_long { + pub fn optimal_transfer_size(&self) -> libc::__fsword_t { self.0.f_bsize } @@ -177,7 +183,7 @@ impl Statfs { /// Size of a block // f_bsize on linux: https://github.com/torvalds/linux/blob/master/fs/nfs/super.c#L471 #[cfg(all(target_os = "linux", not(any(target_arch = "s390x", target_env = "musl"))))] - pub fn block_size(&self) -> libc::c_long { + pub fn block_size(&self) -> libc::__fsword_t { self.0.f_bsize } @@ -219,7 +225,7 @@ impl Statfs { /// Maximum length of filenames #[cfg(all(target_os = "linux", not(any(target_arch = "s390x", target_env = "musl"))))] - pub fn maximum_name_length(&self) -> libc::c_long { + pub fn maximum_name_length(&self) -> libc::__fsword_t { self.0.f_namelen } @@ -248,7 +254,7 @@ impl Statfs { } /// Total data blocks in filesystem - #[cfg(all(target_os = "linux", target_env = "musl"))] + #[cfg(all(target_os = "linux", any(target_env = "musl", all(target_arch = "x86_64", target_pointer_width = "32"))))] pub fn blocks(&self) -> u64 { self.0.f_blocks } @@ -261,7 +267,7 @@ impl Statfs { target_os = "freebsd", target_os = "openbsd", target_os = "dragonfly", - all(target_os = "linux", target_env = "musl") + all(target_os = "linux", any(target_env = "musl", all(target_arch = "x86_64", target_pointer_width = "32"))) )))] pub fn blocks(&self) -> libc::c_ulong { self.0.f_blocks @@ -286,7 +292,7 @@ impl Statfs { } /// Free blocks in filesystem - #[cfg(all(target_os = "linux", target_env = "musl"))] + #[cfg(all(target_os = "linux", any(target_env = "musl", all(target_arch = "x86_64", target_pointer_width = "32"))))] pub fn blocks_free(&self) -> u64 { self.0.f_bfree } @@ -299,7 +305,7 @@ impl Statfs { target_os = "freebsd", target_os = "openbsd", target_os = "dragonfly", - all(target_os = "linux", target_env = "musl") + all(target_os = "linux", any(target_env = "musl", all(target_arch = "x86_64", target_pointer_width = "32"))) )))] pub fn blocks_free(&self) -> libc::c_ulong { self.0.f_bfree @@ -324,7 +330,7 @@ impl Statfs { } /// Free blocks available to unprivileged user - #[cfg(all(target_os = "linux", target_env = "musl"))] + #[cfg(all(target_os = "linux", any(target_env = "musl", all(target_arch = "x86_64", target_pointer_width = "32"))))] pub fn blocks_available(&self) -> u64 { self.0.f_bavail } @@ -337,7 +343,7 @@ impl Statfs { target_os = "freebsd", target_os = "openbsd", target_os = "dragonfly", - all(target_os = "linux", target_env = "musl") + all(target_os = "linux", any(target_env = "musl", all(target_arch = "x86_64", target_pointer_width = "32"))) )))] pub fn blocks_available(&self) -> libc::c_ulong { self.0.f_bavail @@ -362,8 +368,8 @@ impl Statfs { } /// Total file nodes in filesystem - #[cfg(all(target_os = "linux", target_env = "musl"))] - pub fn files(&self) -> u64 { + #[cfg(all(target_os = "linux", any(target_env = "musl", all(target_arch = "x86_64", target_pointer_width = "32"))))] + pub fn files(&self) -> libc::fsfilcnt_t { self.0.f_files } @@ -375,7 +381,7 @@ impl Statfs { target_os = "freebsd", target_os = "openbsd", target_os = "dragonfly", - all(target_os = "linux", target_env = "musl") + all(target_os = "linux", any(target_env = "musl", all(target_arch = "x86_64", target_pointer_width = "32"))) )))] pub fn files(&self) -> libc::c_ulong { self.0.f_files @@ -385,7 +391,6 @@ impl Statfs { #[cfg(any( target_os = "android", target_os = "ios", - all(target_os = "linux", target_env = "musl"), target_os = "macos", target_os = "openbsd" ))] @@ -405,6 +410,12 @@ impl Statfs { self.0.f_ffree } + /// Free file nodes in filesystem + #[cfg(all(target_os = "linux", any(target_env = "musl", all(target_arch = "x86_64", target_pointer_width = "32"))))] + pub fn files_free(&self) -> libc::fsfilcnt_t { + self.0.f_ffree + } + /// Free file nodes in filesystem #[cfg(not(any( target_os = "ios", @@ -413,7 +424,7 @@ impl Statfs { target_os = "freebsd", target_os = "openbsd", target_os = "dragonfly", - all(target_os = "linux", target_env = "musl") + all(target_os = "linux", any(target_env = "musl", all(target_arch = "x86_64", target_pointer_width = "32"))) )))] pub fn files_free(&self) -> libc::c_ulong { self.0.f_ffree -- cgit v1.2.3 From 59c18e2c2fd608d0dbe42f7abe507a992e1c1472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 8 Feb 2021 11:20:54 +0100 Subject: Fix test_ptrace_syscall() on x32 Based on https://github.com/nix-rust/nix/issues/1384#issuecomment-774708486 --- test/sys/test_ptrace.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs index 38cf408b..b9793b39 100644 --- a/test/sys/test_ptrace.rs +++ b/test/sys/test_ptrace.rs @@ -100,7 +100,7 @@ fn test_ptrace_cont() { ptrace::cont(child, Some(Signal::SIGKILL)).unwrap(); match waitpid(child, None) { Ok(WaitStatus::Signaled(pid, Signal::SIGKILL, _)) if pid == child => { - // FIXME It's been observed on some systems (apple) the + // FIXME It's been observed on some systems (apple) the // tracee may not be killed but remain as a zombie process // affecting other wait based tests. Add an extra kill just // to make sure there are no zombies. @@ -150,11 +150,11 @@ fn test_ptrace_syscall() { // set this option to recognize syscall-stops ptrace::setoptions(child, ptrace::Options::PTRACE_O_TRACESYSGOOD).unwrap(); - #[cfg(target_pointer_width = "64")] - let get_syscall_id = || ptrace::getregs(child).unwrap().orig_rax as i64; + #[cfg(target_arch = "x86_64")] + let get_syscall_id = || ptrace::getregs(child).unwrap().orig_rax as libc::c_long; - #[cfg(target_pointer_width = "32")] - let get_syscall_id = || ptrace::getregs(child).unwrap().orig_eax as i32; + #[cfg(target_arch = "x86")] + let get_syscall_id = || ptrace::getregs(child).unwrap().orig_eax as libc::c_long; // kill entry ptrace::syscall(child, None).unwrap(); -- cgit v1.2.3 From 95559c6dffe6ece478fa8de1f5cbddb20c644184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 13 Feb 2021 09:30:39 +0100 Subject: Bump caps to 0.5.1. Add x32 to CI for cross-builds and Tier 3 list in README --- .cirrus.yml | 4 ++++ Cargo.toml | 2 +- README.md | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index d2df8701..d15b7eec 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -157,6 +157,10 @@ task: - name: Linux s390x env: TARGET: s390x-unknown-linux-gnu + - name: Linux x32 + env: + TARGET: x86_64-unknown-linux-gnux32 + CHECK_TESTS: true - name: NetBSD x86_64 env: TARGET: x86_64-unknown-netbsd diff --git a/Cargo.toml b/Cargo.toml index c74889b0..46f8cad0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ tempfile = "3.0.5" semver = "0.9.0" [target.'cfg(any(target_os = "android", target_os = "linux"))'.dev-dependencies] -caps = "0.3.1" +caps = "0.5.1" [target.'cfg(target_os = "freebsd")'.dev-dependencies] sysctl = "0.1" diff --git a/README.md b/README.md index 177f6f2a..67e76726 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ Tier 2: Tier 3: * x86_64-fuchsia * x86_64-unknown-redox + * x86_64-unknown-linux-gnux32 ## Usage -- cgit v1.2.3 From 7cdae09e2957f8578c9b8cd88934c669a2f3a13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 15 Feb 2021 11:01:34 +0100 Subject: Log x32 fixes --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f67271f..c18d70cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Implemented `IntoIterator` for `Dir` (#[1333](https://github.com/nix-rust/nix/pull/1333)). ### Changed + ### Fixed - Define `*_MAGIC` filesystem constants on Linux s390x (#[1372](https://github.com/nix-rust/nix/pull/1372)) +- mqueue, sysinfo, timespec, statfs, test_ptrace_syscall() on x32 + (#[1366](https://github.com/nix-rust/nix/pull/1366)) ### Changed -- cgit v1.2.3