From dc0db358abe19481e475e10c32149b53370f1a1c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:57:31 +0200 Subject: Merging upstream version 1.72.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/rustix/src/process/membarrier.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'vendor/rustix/src/process/membarrier.rs') diff --git a/vendor/rustix/src/process/membarrier.rs b/vendor/rustix/src/process/membarrier.rs index 8709337bc..df9f1a44c 100644 --- a/vendor/rustix/src/process/membarrier.rs +++ b/vendor/rustix/src/process/membarrier.rs @@ -1,24 +1,20 @@ //! The Linux `membarrier` syscall. -//! -//! # Safety -//! -//! This file defines an enum and a bitflags type that represent the same -//! set of values and are kept in sync. -#![allow(unsafe_code)] use crate::process::Cpuid; use crate::{backend, io}; pub use backend::process::types::MembarrierCommand; -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(linux_kernel)] bitflags::bitflags! { /// A result from [`membarrier_query`]. /// /// These flags correspond to values of [`MembarrierCommand`] which are /// supported in the OS. + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct MembarrierQuery: u32 { - /// `MEMBARRIER_CMD_GLOBAL` + /// `MEMBARRIER_CMD_GLOBAL` (also known as `MEMBARRIER_CMD_SHARED`) #[doc(alias = "SHARED")] #[doc(alias = "MEMBARRIER_CMD_SHARED")] const GLOBAL = MembarrierCommand::Global as _; @@ -41,14 +37,14 @@ bitflags::bitflags! { } } -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(linux_kernel)] impl MembarrierQuery { /// Test whether this query result contains the given command. #[inline] pub fn contains_command(self, cmd: MembarrierCommand) -> bool { - // SAFETY: `MembarrierCommand` is an enum that only contains values - // also valid in `MembarrierQuery`. - self.contains(unsafe { Self::from_bits_unchecked(cmd as _) }) + // `MembarrierCommand` is an enum that only contains values also valid + // in `MembarrierQuery`. + self.contains(Self::from_bits_retain(cmd as _)) } } -- cgit v1.2.3