Skip to content

Commit f40513e

Browse files
Fix compilation on targets without atomics
1 parent 9558598 commit f40513e

File tree

1 file changed

+72
-2
lines changed

1 file changed

+72
-2
lines changed

src/storage.rs

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,24 @@
22
33
use core::borrow::{Borrow, BorrowMut};
44

5+
#[cfg(any(
6+
feature = "portable-atomic",
7+
all(feature = "mpmc_large", target_has_atomic = "ptr"),
8+
all(not(feature = "mpmc_large"), target_has_atomic = "8")
9+
))]
10+
use crate::mpmc::{MpMcQueueInner, MpMcQueueView};
11+
#[cfg(any(
12+
feature = "portable-atomic",
13+
target_has_atomic = "ptr",
14+
has_atomic_load_store
15+
))]
16+
use crate::spsc::{QueueInner, QueueView};
517
use crate::{
618
binary_heap::{BinaryHeapInner, BinaryHeapView},
719
deque::{DequeInner, DequeView},
820
histbuf::{HistoryBufferInner, HistoryBufferView},
921
linear_map::{LinearMapInner, LinearMapView},
10-
mpmc::{MpMcQueueInner, MpMcQueueView},
1122
sorted_linked_list::{SortedLinkedListIndex, SortedLinkedListInner, SortedLinkedListView},
12-
spsc::{QueueInner, QueueView},
1323
string::{StringInner, StringView},
1424
vec::VecInner,
1525
VecView,
@@ -40,10 +50,20 @@ pub(crate) trait SealedStorage: Sized {
4050
fn as_mut_histbuf_view<T>(this: &mut HistoryBufferInner<T, Self>) -> &mut HistoryBufferView<T>
4151
where
4252
Self: Storage;
53+
#[cfg(any(
54+
feature = "portable-atomic",
55+
all(feature = "mpmc_large", target_has_atomic = "ptr"),
56+
all(not(feature = "mpmc_large"), target_has_atomic = "8")
57+
))]
4358
/// Convert a `MpMcQueue` to a `MpMcQueueView`
4459
fn as_mpmc_queue_view<T>(this: &MpMcQueueInner<T, Self>) -> &MpMcQueueView<T>
4560
where
4661
Self: Storage;
62+
#[cfg(any(
63+
feature = "portable-atomic",
64+
all(feature = "mpmc_large", target_has_atomic = "ptr"),
65+
all(not(feature = "mpmc_large"), target_has_atomic = "8")
66+
))]
4767
/// Convert a `MpMcQueue` to a `MpMcQueueView`
4868
fn as_mut_mpmc_queue_view<T>(this: &mut MpMcQueueInner<T, Self>) -> &mut MpMcQueueView<T>
4969
where
@@ -68,10 +88,20 @@ pub(crate) trait SealedStorage: Sized {
6888
) -> &mut BinaryHeapView<T, K>
6989
where
7090
Self: Storage;
91+
#[cfg(any(
92+
feature = "portable-atomic",
93+
target_has_atomic = "ptr",
94+
has_atomic_load_store
95+
))]
7196
/// Convert a `Queue` to a `QueueView`
7297
fn as_queue_view<T>(this: &QueueInner<T, Self>) -> &QueueView<T>
7398
where
7499
Self: Storage;
100+
#[cfg(any(
101+
feature = "portable-atomic",
102+
target_has_atomic = "ptr",
103+
has_atomic_load_store
104+
))]
75105
/// Convert a `Queue` to a `QueueView`
76106
fn as_mut_queue_view<T>(this: &mut QueueInner<T, Self>) -> &mut QueueView<T>
77107
where
@@ -159,10 +189,20 @@ impl<const N: usize> SealedStorage for OwnedStorage<N> {
159189
) -> &mut SortedLinkedListView<T, Idx, K> {
160190
this
161191
}
192+
#[cfg(any(
193+
feature = "portable-atomic",
194+
target_has_atomic = "ptr",
195+
has_atomic_load_store
196+
))]
162197
/// Convert a `Queue` to a `QueueView`
163198
fn as_queue_view<T>(this: &QueueInner<T, Self>) -> &QueueView<T> {
164199
this
165200
}
201+
#[cfg(any(
202+
feature = "portable-atomic",
203+
target_has_atomic = "ptr",
204+
has_atomic_load_store
205+
))]
166206
/// Convert a `Queue` to a `QueueView`
167207
fn as_mut_queue_view<T>(this: &mut QueueInner<T, Self>) -> &mut QueueView<T> {
168208
this
@@ -193,10 +233,20 @@ impl<const N: usize> SealedStorage for OwnedStorage<N> {
193233
) -> &mut LinearMapView<K, V> {
194234
this
195235
}
236+
#[cfg(any(
237+
feature = "portable-atomic",
238+
all(feature = "mpmc_large", target_has_atomic = "ptr"),
239+
all(not(feature = "mpmc_large"), target_has_atomic = "8")
240+
))]
196241
/// Convert a `MpMcQueue` to a `MpMcQueueView`
197242
fn as_mpmc_queue_view<T>(this: &MpMcQueueInner<T, Self>) -> &MpMcQueueView<T> {
198243
this
199244
}
245+
#[cfg(any(
246+
feature = "portable-atomic",
247+
all(feature = "mpmc_large", target_has_atomic = "ptr"),
248+
all(not(feature = "mpmc_large"), target_has_atomic = "8")
249+
))]
200250
/// Convert a `MpMcQueue` to a `MpMcQueueView`
201251
fn as_mut_mpmc_queue_view<T>(this: &mut MpMcQueueInner<T, Self>) -> &mut MpMcQueueView<T> {
202252
this
@@ -252,10 +302,20 @@ impl SealedStorage for ViewStorage {
252302
) -> &mut SortedLinkedListView<T, Idx, K> {
253303
this
254304
}
305+
#[cfg(any(
306+
feature = "portable-atomic",
307+
target_has_atomic = "ptr",
308+
has_atomic_load_store
309+
))]
255310
/// Convert a `Queue` to a `QueueView`
256311
fn as_queue_view<T>(this: &QueueInner<T, Self>) -> &QueueView<T> {
257312
this
258313
}
314+
#[cfg(any(
315+
feature = "portable-atomic",
316+
target_has_atomic = "ptr",
317+
has_atomic_load_store
318+
))]
259319
/// Convert a `Queue` to a `QueueView`
260320
fn as_mut_queue_view<T>(this: &mut QueueInner<T, Self>) -> &mut QueueView<T> {
261321
this
@@ -286,10 +346,20 @@ impl SealedStorage for ViewStorage {
286346
) -> &mut LinearMapView<K, V> {
287347
this
288348
}
349+
#[cfg(any(
350+
feature = "portable-atomic",
351+
all(feature = "mpmc_large", target_has_atomic = "ptr"),
352+
all(not(feature = "mpmc_large"), target_has_atomic = "8")
353+
))]
289354
/// Convert a `MpMcQueue` to a `MpMcQueueView`
290355
fn as_mpmc_queue_view<T>(this: &MpMcQueueInner<T, Self>) -> &MpMcQueueView<T> {
291356
this
292357
}
358+
#[cfg(any(
359+
feature = "portable-atomic",
360+
all(feature = "mpmc_large", target_has_atomic = "ptr"),
361+
all(not(feature = "mpmc_large"), target_has_atomic = "8")
362+
))]
293363
/// Convert a `MpMcQueue` to a `MpMcQueueView`
294364
fn as_mut_mpmc_queue_view<T>(this: &mut MpMcQueueInner<T, Self>) -> &mut MpMcQueueView<T> {
295365
this

0 commit comments

Comments
 (0)