Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
2027: Update to bitflags 2.2.1. r=asomers a=qwandor

This is a new major version and requires some code changes.

2057: Haiku: `speed_t` is defined as `u8` for 32 and 64 bit systems r=asomers a=nielx

This fixes the build on 32 bit Haiku systems.

Co-authored-by: Andrew Walbran <qwandor@google.com>
Co-authored-by: Niels Sascha Reedijk <niels.reedijk@gmail.com>
  • Loading branch information
3 people authored and asomers committed Aug 27, 2023
1 parent 6d85712 commit 0c3afc2
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ targets = [

[dependencies]
libc = { version = "0.2.137", features = [ "extra_traits" ] }
bitflags = "1.1"
bitflags = "2.3.1"
cfg-if = "1.0"
pin-utils = { version = "0.1.0", optional = true }

Expand Down
2 changes: 2 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ macro_rules! libc_bitflags {
}
) => {
::bitflags::bitflags! {
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(transparent)]
$(#[$outer])*
pub struct $BitFlags: $T {
$(
Expand Down
4 changes: 2 additions & 2 deletions src/mount/bsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl<'a> Nmount<'a> {

let niov = self.iov.len() as c_uint;
let iovp = self.iov.as_mut_ptr() as *mut libc::iovec;
let res = unsafe { libc::nmount(iovp, niov, flags.bits) };
let res = unsafe { libc::nmount(iovp, niov, flags.bits()) };
match Errno::result(res) {
Ok(_) => Ok(()),
Err(error) => {
Expand Down Expand Up @@ -446,7 +446,7 @@ where
P: ?Sized + NixPath,
{
let res = mountpoint.with_nix_path(|cstr| unsafe {
libc::unmount(cstr.as_ptr(), flags.bits)
libc::unmount(cstr.as_ptr(), flags.bits())
})?;

Errno::result(res).map(drop)
Expand Down
4 changes: 2 additions & 2 deletions src/mount/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn mount<
s,
t.as_ptr(),
ty,
flags.bits,
flags.bits(),
d as *const libc::c_void,
)
})
Expand All @@ -108,7 +108,7 @@ pub fn umount<P: ?Sized + NixPath>(target: &P) -> Result<()> {

pub fn umount2<P: ?Sized + NixPath>(target: &P, flags: MntFlags) -> Result<()> {
let res = target.with_nix_path(|cstr| unsafe {
libc::umount2(cstr.as_ptr(), flags.bits)
libc::umount2(cstr.as_ptr(), flags.bits())
})?;

Errno::result(res).map(drop)
Expand Down
2 changes: 1 addition & 1 deletion src/mqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl MqAttr {
/// Open a message queue
///
/// See also [`mq_open(2)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_open.html)
// The mode.bits cast is only lossless on some OSes
// The mode.bits() cast is only lossless on some OSes
#[allow(clippy::cast_lossless)]
pub fn mq_open(
name: &CStr,
Expand Down
4 changes: 2 additions & 2 deletions src/sys/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct KEvent {
target_os = "openbsd"
))]
type type_of_udata = *mut libc::c_void;
#[cfg(any(target_os = "netbsd"))]
#[cfg(target_os = "netbsd")]
type type_of_udata = intptr_t;

#[cfg(target_os = "netbsd")]
Expand Down Expand Up @@ -87,7 +87,7 @@ libc_enum! {
target_os = "openbsd"
))]
pub type type_of_event_flag = u16;
#[cfg(any(target_os = "netbsd"))]
#[cfg(target_os = "netbsd")]
pub type type_of_event_flag = u32;
libc_bitflags! {
pub struct EventFlag: type_of_event_flag {
Expand Down
4 changes: 2 additions & 2 deletions src/sys/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub fn mknod<P: ?Sized + NixPath>(
dev: dev_t,
) -> Result<()> {
let res = path.with_nix_path(|cstr| unsafe {
libc::mknod(cstr.as_ptr(), kind.bits | perm.bits() as mode_t, dev)
libc::mknod(cstr.as_ptr(), kind.bits() | perm.bits() as mode_t, dev)
})?;

Errno::result(res).map(drop)
Expand All @@ -202,7 +202,7 @@ pub fn mknodat<P: ?Sized + NixPath>(
libc::mknodat(
dirfd,
cstr.as_ptr(),
kind.bits | perm.bits() as mode_t,
kind.bits() | perm.bits() as mode_t,
dev,
)
})?;
Expand Down
1 change: 0 additions & 1 deletion src/sys/statvfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::{errno::Errno, NixPath, Result};
#[cfg(not(target_os = "redox"))]
libc_bitflags!(
/// File system mount Flags
#[repr(C)]
#[derive(Default)]
pub struct FsFlags: c_ulong {
/// Read Only
Expand Down
6 changes: 3 additions & 3 deletions src/sys/termios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl Termios {
let termios = *self.inner.borrow_mut();
self.input_flags = InputFlags::from_bits_truncate(termios.c_iflag);
self.output_flags = OutputFlags::from_bits_truncate(termios.c_oflag);
self.control_flags = ControlFlags::from_bits_truncate(termios.c_cflag);
self.control_flags = ControlFlags::from_bits_retain(termios.c_cflag);
self.local_flags = LocalFlags::from_bits_truncate(termios.c_lflag);
self.control_chars = termios.c_cc;
#[cfg(any(
Expand Down Expand Up @@ -355,9 +355,9 @@ libc_enum! {
/// enum.
///
/// B0 is special and will disable the port.
#[cfg_attr(all(any(target_os = "haiku"), target_pointer_width = "64"), repr(u8))]
#[cfg_attr(target_os = "haiku", repr(u8))]
#[cfg_attr(all(any(target_os = "ios", target_os = "macos"), target_pointer_width = "64"), repr(u64))]
#[cfg_attr(not(all(any(target_os = "ios", target_os = "macos", target_os = "haiku"), target_pointer_width = "64")), repr(u32))]
#[cfg_attr(all(not(all(any(target_os = "ios", target_os = "macos"), target_pointer_width = "64")), not(target_os = "haiku")), repr(u32))]
#[non_exhaustive]
pub enum BaudRate {
B0,
Expand Down
2 changes: 2 additions & 0 deletions src/sys/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub(crate) mod timer {
#[cfg(any(target_os = "android", target_os = "linux"))]
bitflags! {
/// Flags that are used for arming the timer.
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct TimerSetTimeFlags: libc::c_int {
const TFD_TIMER_ABSTIME = libc::TFD_TIMER_ABSTIME;
}
Expand All @@ -103,6 +104,7 @@ pub(crate) mod timer {
))]
bitflags! {
/// Flags that are used for arming the timer.
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct TimerSetTimeFlags: libc::c_int {
const TFD_TIMER_ABSTIME = libc::TIMER_ABSTIME;
}
Expand Down
4 changes: 2 additions & 2 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2906,7 +2906,7 @@ feature! {
pub fn access<P: ?Sized + NixPath>(path: &P, amode: AccessFlags) -> Result<()> {
let res = path.with_nix_path(|cstr| {
unsafe {
libc::access(cstr.as_ptr(), amode.bits)
libc::access(cstr.as_ptr(), amode.bits())
}
})?;
Errno::result(res).map(drop)
Expand Down Expand Up @@ -2947,7 +2947,7 @@ pub fn faccessat<P: ?Sized + NixPath>(dirfd: Option<RawFd>, path: &P, mode: Acce
pub fn eaccess<P: ?Sized + NixPath>(path: &P, mode: AccessFlags) -> Result<()> {
let res = path.with_nix_path(|cstr| {
unsafe {
libc::eaccess(cstr.as_ptr(), mode.bits)
libc::eaccess(cstr.as_ptr(), mode.bits())
}
})?;
Errno::result(res).map(drop)
Expand Down

0 comments on commit 0c3afc2

Please sign in to comment.