diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:06:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:06:37 +0000 |
commit | 246f239d9f40f633160f0c18f87a20922d4e77bb (patch) | |
tree | 5a88572663584b3d4d28e5a20e10abab1be40884 /vendor/crossbeam-channel/src/flavors | |
parent | Releasing progress-linux version 1.64.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-246f239d9f40f633160f0c18f87a20922d4e77bb.tar.xz rustc-246f239d9f40f633160f0c18f87a20922d4e77bb.zip |
Merging debian version 1.65.0+dfsg1-2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/crossbeam-channel/src/flavors')
-rw-r--r-- | vendor/crossbeam-channel/src/flavors/array.rs | 4 | ||||
-rw-r--r-- | vendor/crossbeam-channel/src/flavors/list.rs | 18 | ||||
-rw-r--r-- | vendor/crossbeam-channel/src/flavors/zero.rs | 10 |
3 files changed, 17 insertions, 15 deletions
diff --git a/vendor/crossbeam-channel/src/flavors/array.rs b/vendor/crossbeam-channel/src/flavors/array.rs index 73557d385..63b82eb85 100644 --- a/vendor/crossbeam-channel/src/flavors/array.rs +++ b/vendor/crossbeam-channel/src/flavors/array.rs @@ -216,7 +216,7 @@ impl<T> Channel<T> { return Err(msg); } - let slot: &Slot<T> = &*(token.array.slot as *const Slot<T>); + let slot: &Slot<T> = &*token.array.slot.cast::<Slot<T>>(); // Write the message into the slot and update the stamp. slot.msg.get().write(MaybeUninit::new(msg)); @@ -307,7 +307,7 @@ impl<T> Channel<T> { return Err(()); } - let slot: &Slot<T> = &*(token.array.slot as *const Slot<T>); + let slot: &Slot<T> = &*token.array.slot.cast::<Slot<T>>(); // Read the message from the slot and update the stamp. let msg = slot.msg.get().read().assume_init(); diff --git a/vendor/crossbeam-channel/src/flavors/list.rs b/vendor/crossbeam-channel/src/flavors/list.rs index 9bda6d1cc..6090b8d47 100644 --- a/vendor/crossbeam-channel/src/flavors/list.rs +++ b/vendor/crossbeam-channel/src/flavors/list.rs @@ -49,6 +49,11 @@ struct Slot<T> { } impl<T> Slot<T> { + const UNINIT: Self = Self { + msg: UnsafeCell::new(MaybeUninit::uninit()), + state: AtomicUsize::new(0), + }; + /// Waits until a message is written into the slot. fn wait_write(&self) { let backoff = Backoff::new(); @@ -72,13 +77,10 @@ struct Block<T> { impl<T> Block<T> { /// Creates an empty block. fn new() -> Block<T> { - // SAFETY: This is safe because: - // [1] `Block::next` (AtomicPtr) may be safely zero initialized. - // [2] `Block::slots` (Array) may be safely zero initialized because of [3, 4]. - // [3] `Slot::msg` (UnsafeCell) may be safely zero initialized because it - // holds a MaybeUninit. - // [4] `Slot::state` (AtomicUsize) may be safely zero initialized. - unsafe { MaybeUninit::zeroed().assume_init() } + Self { + next: AtomicPtr::new(ptr::null_mut()), + slots: [Slot::UNINIT; BLOCK_CAP], + } } /// Waits until the next pointer is set. @@ -283,7 +285,7 @@ impl<T> Channel<T> { } // Write the message into the slot. - let block = token.list.block as *mut Block<T>; + let block = token.list.block.cast::<Block<T>>(); let offset = token.list.offset; let slot = (*block).slots.get_unchecked(offset); slot.msg.get().write(MaybeUninit::new(msg)); diff --git a/vendor/crossbeam-channel/src/flavors/zero.rs b/vendor/crossbeam-channel/src/flavors/zero.rs index 31e62afac..aae2ea300 100644 --- a/vendor/crossbeam-channel/src/flavors/zero.rs +++ b/vendor/crossbeam-channel/src/flavors/zero.rs @@ -190,7 +190,7 @@ impl<T> Channel<T> { // heap-allocated packet. packet.wait_ready(); let msg = packet.msg.get().replace(None).unwrap(); - drop(Box::from_raw(token.zero.0 as *mut Packet<T>)); + drop(Box::from_raw(token.zero.0.cast::<Packet<T>>())); Ok(msg) } } @@ -409,7 +409,7 @@ impl<T> SelectHandle for Receiver<'_, T> { let mut inner = self.0.inner.lock().unwrap(); inner .receivers - .register_with_packet(oper, packet as *mut (), cx); + .register_with_packet(oper, packet.cast::<()>(), cx); inner.senders.notify(); inner.senders.can_select() || inner.is_disconnected } @@ -417,7 +417,7 @@ impl<T> SelectHandle for Receiver<'_, T> { fn unregister(&self, oper: Operation) { if let Some(operation) = self.0.inner.lock().unwrap().receivers.unregister(oper) { unsafe { - drop(Box::from_raw(operation.packet as *mut Packet<T>)); + drop(Box::from_raw(operation.packet.cast::<Packet<T>>())); } } } @@ -459,7 +459,7 @@ impl<T> SelectHandle for Sender<'_, T> { let mut inner = self.0.inner.lock().unwrap(); inner .senders - .register_with_packet(oper, packet as *mut (), cx); + .register_with_packet(oper, packet.cast::<()>(), cx); inner.receivers.notify(); inner.receivers.can_select() || inner.is_disconnected } @@ -467,7 +467,7 @@ impl<T> SelectHandle for Sender<'_, T> { fn unregister(&self, oper: Operation) { if let Some(operation) = self.0.inner.lock().unwrap().senders.unregister(oper) { unsafe { - drop(Box::from_raw(operation.packet as *mut Packet<T>)); + drop(Box::from_raw(operation.packet.cast::<Packet<T>>())); } } } |