Skip to content

Commit 1376e15

Browse files
bors[bot]qwandornielx
authored
Merge #2027 #2057
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 <[email protected]> Co-authored-by: Niels Sascha Reedijk <[email protected]>
3 parents 2a7ea3a + aef996a + e63dd8f commit 1376e15

File tree

11 files changed

+18
-15
lines changed

11 files changed

+18
-15
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ targets = [
2828

2929
[dependencies]
3030
libc = { version = "0.2.141", features = ["extra_traits"] }
31-
bitflags = "1.1"
31+
bitflags = "2.3.1"
3232
cfg-if = "1.0"
3333
pin-utils = { version = "0.1.0", optional = true }
3434
memoffset = { version = "0.9", optional = true }

src/macros.rs

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ macro_rules! libc_bitflags {
6363
}
6464
) => {
6565
::bitflags::bitflags! {
66+
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
67+
#[repr(transparent)]
6668
$(#[$outer])*
6769
pub struct $BitFlags: $T {
6870
$(

src/mount/bsd.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<'a> Nmount<'a> {
392392

393393
let niov = self.iov.len() as c_uint;
394394
let iovp = self.iov.as_mut_ptr() as *mut libc::iovec;
395-
let res = unsafe { libc::nmount(iovp, niov, flags.bits) };
395+
let res = unsafe { libc::nmount(iovp, niov, flags.bits()) };
396396
match Errno::result(res) {
397397
Ok(_) => Ok(()),
398398
Err(error) => {
@@ -446,7 +446,7 @@ where
446446
P: ?Sized + NixPath,
447447
{
448448
let res = mountpoint.with_nix_path(|cstr| unsafe {
449-
libc::unmount(cstr.as_ptr(), flags.bits)
449+
libc::unmount(cstr.as_ptr(), flags.bits())
450450
})?;
451451

452452
Errno::result(res).map(drop)

src/mount/linux.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub fn mount<
132132
s,
133133
t.as_ptr(),
134134
ty,
135-
flags.bits,
135+
flags.bits(),
136136
d as *const libc::c_void,
137137
)
138138
})
@@ -156,7 +156,7 @@ pub fn umount<P: ?Sized + NixPath>(target: &P) -> Result<()> {
156156
/// See also [`umount`](https://man7.org/linux/man-pages/man2/umount.2.html)
157157
pub fn umount2<P: ?Sized + NixPath>(target: &P, flags: MntFlags) -> Result<()> {
158158
let res = target.with_nix_path(|cstr| unsafe {
159-
libc::umount2(cstr.as_ptr(), flags.bits)
159+
libc::umount2(cstr.as_ptr(), flags.bits())
160160
})?;
161161

162162
Errno::result(res).map(drop)

src/mqueue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl MqAttr {
139139
/// Open a message queue
140140
///
141141
/// See also [`mq_open(2)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_open.html)
142-
// The mode.bits cast is only lossless on some OSes
142+
// The mode.bits() cast is only lossless on some OSes
143143
#[allow(clippy::cast_lossless)]
144144
pub fn mq_open(
145145
name: &CStr,

src/sys/event.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Kqueue {
7171
timeout as *const timespec
7272
} else {
7373
ptr::null()
74-
}
74+
},
7575
)
7676
};
7777
Errno::result(res).map(|r| r as usize)

src/sys/stat.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub fn mknod<P: ?Sized + NixPath>(
177177
dev: dev_t,
178178
) -> Result<()> {
179179
let res = path.with_nix_path(|cstr| unsafe {
180-
libc::mknod(cstr.as_ptr(), kind.bits | perm.bits() as mode_t, dev)
180+
libc::mknod(cstr.as_ptr(), kind.bits() | perm.bits() as mode_t, dev)
181181
})?;
182182

183183
Errno::result(res).map(drop)
@@ -202,7 +202,7 @@ pub fn mknodat<P: ?Sized + NixPath>(
202202
libc::mknodat(
203203
dirfd,
204204
cstr.as_ptr(),
205-
kind.bits | perm.bits() as mode_t,
205+
kind.bits() | perm.bits() as mode_t,
206206
dev,
207207
)
208208
})?;

src/sys/statvfs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::{errno::Errno, NixPath, Result};
1212
#[cfg(not(target_os = "redox"))]
1313
libc_bitflags!(
1414
/// File system mount Flags
15-
#[repr(C)]
1615
#[derive(Default)]
1716
pub struct FsFlags: c_ulong {
1817
/// Read Only

src/sys/termios.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl Termios {
309309
let termios = *self.inner.borrow_mut();
310310
self.input_flags = InputFlags::from_bits_truncate(termios.c_iflag);
311311
self.output_flags = OutputFlags::from_bits_truncate(termios.c_oflag);
312-
self.control_flags = ControlFlags::from_bits_truncate(termios.c_cflag);
312+
self.control_flags = ControlFlags::from_bits_retain(termios.c_cflag);
313313
self.local_flags = LocalFlags::from_bits_truncate(termios.c_lflag);
314314
self.control_chars = termios.c_cc;
315315
#[cfg(any(
@@ -355,9 +355,9 @@ libc_enum! {
355355
/// enum.
356356
///
357357
/// B0 is special and will disable the port.
358-
#[cfg_attr(all(any(target_os = "haiku"), target_pointer_width = "64"), repr(u8))]
358+
#[cfg_attr(target_os = "haiku", repr(u8))]
359359
#[cfg_attr(all(any(target_os = "ios", target_os = "macos"), target_pointer_width = "64"), repr(u64))]
360-
#[cfg_attr(not(all(any(target_os = "ios", target_os = "macos", target_os = "haiku"), target_pointer_width = "64")), repr(u32))]
360+
#[cfg_attr(all(not(all(any(target_os = "ios", target_os = "macos"), target_pointer_width = "64")), not(target_os = "haiku")), repr(u32))]
361361
#[non_exhaustive]
362362
pub enum BaudRate {
363363
B0,

src/sys/time.rs

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ pub(crate) mod timer {
9191
#[cfg(any(target_os = "android", target_os = "linux"))]
9292
bitflags! {
9393
/// Flags that are used for arming the timer.
94+
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
9495
pub struct TimerSetTimeFlags: libc::c_int {
9596
const TFD_TIMER_ABSTIME = libc::TFD_TIMER_ABSTIME;
9697
const TFD_TIMER_CANCEL_ON_SET = libc::TFD_TIMER_CANCEL_ON_SET;
@@ -104,6 +105,7 @@ pub(crate) mod timer {
104105
))]
105106
bitflags! {
106107
/// Flags that are used for arming the timer.
108+
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
107109
pub struct TimerSetTimeFlags: libc::c_int {
108110
const TFD_TIMER_ABSTIME = libc::TIMER_ABSTIME;
109111
}

src/unistd.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3375,7 +3375,7 @@ feature! {
33753375
/// See [access(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html)
33763376
pub fn access<P: ?Sized + NixPath>(path: &P, amode: AccessFlags) -> Result<()> {
33773377
let res = path.with_nix_path(|cstr| unsafe {
3378-
libc::access(cstr.as_ptr(), amode.bits)
3378+
libc::access(cstr.as_ptr(), amode.bits())
33793379
})?;
33803380
Errno::result(res).map(drop)
33813381
}
@@ -3422,7 +3422,7 @@ pub fn faccessat<P: ?Sized + NixPath>(
34223422
))]
34233423
pub fn eaccess<P: ?Sized + NixPath>(path: &P, mode: AccessFlags) -> Result<()> {
34243424
let res = path.with_nix_path(|cstr| unsafe {
3425-
libc::eaccess(cstr.as_ptr(), mode.bits)
3425+
libc::eaccess(cstr.as_ptr(), mode.bits())
34263426
})?;
34273427
Errno::result(res).map(drop)
34283428
}

0 commit comments

Comments
 (0)