File tree Expand file tree Collapse file tree 6 files changed +352
-277
lines changed Expand file tree Collapse file tree 6 files changed +352
-277
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,26 @@ jobs:
244
244
- name : run Miri tests
245
245
run : just miri cordyceps
246
246
247
+ # run no-atomics target tests
248
+ cordyceps_no_atomics_compat :
249
+ needs : changed_paths
250
+ if : needs.changed_paths.outputs.should_skip != 'true' || !fromJSON(needs.changed_paths.outputs.paths_result).cordyceps.should_skip
251
+ runs-on : ubuntu-latest
252
+ name : no-atomics compat (cordyceps)
253
+ steps :
254
+ - name : install rust toolchain
255
+ run : rustup show
256
+ - uses : actions/checkout@v4
257
+ - name : run check
258
+ # we add the target HERE instead of in the 'install rust toolchain' step
259
+ # because we need the `rust-toolchain.toml` file to be checked out, otherwise
260
+ # the target is only added for `stable`. We could also add this to the
261
+ # `targets` item in the toolchain file, but that would be a waste for all
262
+ # other tests.
263
+ run : |
264
+ rustup target add thumbv6m-none-eabi
265
+ cargo check -p cordyceps --target thumbv6m-none-eabi
266
+
247
267
# ## maitake ###
248
268
249
269
# test with `--no-default-features`
@@ -313,6 +333,7 @@ jobs:
313
333
- docs
314
334
- cordyceps_loom
315
335
- cordyceps_miri
336
+ - cordyceps_no_atomics_compat
316
337
- maitake_no_default_features
317
338
- maitake_loom
318
339
- maitake_miri
Original file line number Diff line number Diff line change @@ -86,6 +86,21 @@ than owning those values.
86
86
* must* be pinned in memory; they may not move (or be dropped) while linked
87
87
into an intrusive collection.
88
88
89
+ ## Compatibility
90
+
91
+ Rudimentary support for targets without CAS (Compare and Swap) atomics, such as
92
+ Cortex-M0+/` thumbv6m-none-eabi ` , is provided, however not all structures and
93
+ features may be available.
94
+
95
+ CAS atomic support is automatically detected with ` cfg(target_has_atomic = "ptr") ` ,
96
+ which notes that a [ platform has support] for both load/store operations as well
97
+ as support for CAS atomics.
98
+
99
+ No crate-level features are necessary to enable/disable structures that require
100
+ CAS atomics.
101
+
102
+ [ platform has support ] : https://doc.rust-lang.org/reference/conditional-compilation.html#r-cfg.target_has_atomic
103
+
89
104
## about the name
90
105
91
106
In keeping with Mycelium's fungal naming theme, _ Cordyceps_ is a genus of
Original file line number Diff line number Diff line change 34
34
//! [`MpscQueue`]s can be used to efficiently share data from multiple
35
35
//! concurrent producers with a consumer.
36
36
//!
37
+ //! This structure is only available if the target supports CAS (Compare and
38
+ //! Swap) atomics.
39
+ //!
37
40
//! - **[`SortedList`]: a mutable, singly-linked list, with elements stored
38
41
//! in sorted order.**
39
42
//!
71
74
//! A [`TransferStack`] can be used to efficiently transfer ownership of
72
75
//! resources from multiple producers to a consumer, such as for reuse or
73
76
//! cleanup.
77
+ //!
78
+ //! This structure is only available if the target supports CAS (Compare and
79
+ //! Swap) atomics.
74
80
#[ cfg( feature = "alloc" ) ]
75
81
extern crate alloc;
76
82
#[ cfg( test) ]
@@ -80,18 +86,33 @@ extern crate std;
80
86
pub ( crate ) mod util;
81
87
82
88
pub mod list;
83
- pub mod mpsc_queue;
84
89
pub mod sorted_list;
85
90
pub mod stack;
86
91
87
92
#[ doc( inline) ]
88
93
pub use list:: List ;
89
94
#[ doc( inline) ]
90
- pub use mpsc_queue:: MpscQueue ;
91
- #[ doc( inline) ]
92
95
pub use sorted_list:: { SortedList , SortedListIter } ;
93
96
#[ doc( inline) ]
94
- pub use stack:: { Stack , TransferStack } ;
97
+ pub use stack:: Stack ;
98
+
99
+ //
100
+ // The following items are only available if we have atomics
101
+ //
102
+ #[ cfg( target_has_atomic = "ptr" ) ]
103
+ pub mod mpsc_queue;
104
+
105
+ #[ cfg( target_has_atomic = "ptr" ) ]
106
+ pub use has_cas_atomics:: * ;
107
+
108
+ #[ cfg( target_has_atomic = "ptr" ) ]
109
+ mod has_cas_atomics {
110
+ #[ doc( inline) ]
111
+ pub use crate :: mpsc_queue:: MpscQueue ;
112
+
113
+ #[ doc( inline) ]
114
+ pub use crate :: stack:: TransferStack ;
115
+ }
95
116
96
117
pub ( crate ) mod loom;
97
118
Original file line number Diff line number Diff line change @@ -21,6 +21,18 @@ use core::{
21
21
ptr:: { self , NonNull } ,
22
22
} ;
23
23
24
+ macro_rules! feature {
25
+ (
26
+ #![ $meta: meta]
27
+ $( $item: item) *
28
+ ) => {
29
+ $(
30
+ #[ cfg( $meta) ]
31
+ $item
32
+ ) *
33
+ }
34
+ }
35
+
24
36
/// A multi-producer, single-consumer (MPSC) queue, implemented using a
25
37
/// lock-free [intrusive] singly-linked list.
26
38
///
You can’t perform that action at this time.
0 commit comments