@@ -21,14 +21,14 @@ use std::{
2121 process:: { Child , ChildStdin , ChildStdout , Command , Stdio } ,
2222 rc:: Rc ,
2323} ;
24- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
24+ #[ cfg( not( wasi_no_threads ) ) ]
2525use std:: {
2626 sync:: mpsc:: { Receiver , Sender , SyncSender , channel, sync_channel} ,
2727 thread:: { self , JoinHandle } ,
2828} ;
2929
3030use compare:: Compare ;
31- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
31+ #[ cfg( not( wasi_no_threads ) ) ]
3232use uucore:: error:: FromIo ;
3333use uucore:: error:: UResult ;
3434
@@ -108,7 +108,7 @@ pub fn merge(
108108 let files = files
109109 . iter ( )
110110 . map ( |file| open ( file) . map ( |file| PlainMergeInput { inner : file } ) ) ;
111- #[ cfg( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ]
111+ #[ cfg( wasi_no_threads ) ]
112112 if settings. compress_prog . is_some ( ) {
113113 let _ = writeln ! (
114114 std:: io:: stderr( ) ,
@@ -132,9 +132,9 @@ fn do_merge_to_output<M: MergeInput + 'static>(
132132 settings : & GlobalSettings ,
133133 output : Output ,
134134) -> UResult < ( ) > {
135- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
135+ #[ cfg( not( wasi_no_threads ) ) ]
136136 return merge_without_limit ( files, settings) ?. write_all ( settings, output) ;
137- #[ cfg( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ]
137+ #[ cfg( wasi_no_threads ) ]
138138 return merge_without_limit_sync ( files, settings) ?. write_all ( settings, output) ;
139139}
140140
@@ -144,9 +144,9 @@ fn do_merge_to_writer<M: MergeInput + 'static>(
144144 settings : & GlobalSettings ,
145145 out : & mut impl Write ,
146146) -> UResult < ( ) > {
147- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
147+ #[ cfg( not( wasi_no_threads ) ) ]
148148 return merge_without_limit ( files, settings) ?. write_all_to ( settings, out) ;
149- #[ cfg( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ]
149+ #[ cfg( wasi_no_threads ) ]
150150 return merge_without_limit_sync ( files, settings) ?. write_all_to ( settings, out) ;
151151}
152152
@@ -208,7 +208,7 @@ pub fn merge_with_file_limit<
208208///
209209/// It is the responsibility of the caller to ensure that `files` yields only
210210/// as many files as we are allowed to open concurrently.
211- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
211+ #[ cfg( not( wasi_no_threads ) ) ]
212212fn merge_without_limit < M : MergeInput + ' static , F : Iterator < Item = UResult < M > > > (
213213 files : F ,
214214 settings : & GlobalSettings ,
@@ -273,15 +273,15 @@ fn merge_without_limit<M: MergeInput + 'static, F: Iterator<Item = UResult<M>>>(
273273 } )
274274}
275275/// The struct on the reader thread representing an input file
276- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
276+ #[ cfg( not( wasi_no_threads ) ) ]
277277struct ReaderFile < M : MergeInput > {
278278 file : M ,
279279 sender : SyncSender < Chunk > ,
280280 carry_over : Vec < u8 > ,
281281}
282282
283283/// The function running on the reader thread.
284- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
284+ #[ cfg( not( wasi_no_threads ) ) ]
285285fn reader (
286286 recycled_receiver : & Receiver < ( usize , RecycledChunk ) > ,
287287 files : & mut [ Option < ReaderFile < impl MergeInput > > ] ,
@@ -316,7 +316,7 @@ fn reader(
316316 Ok ( ( ) )
317317}
318318/// The struct on the main thread representing an input file
319- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
319+ #[ cfg( not( wasi_no_threads ) ) ]
320320pub struct MergeableFile {
321321 current_chunk : Rc < Chunk > ,
322322 line_idx : usize ,
@@ -330,20 +330,20 @@ pub struct MergeableFile {
330330struct PreviousLine {
331331 chunk : Rc < Chunk > ,
332332 line_idx : usize ,
333- #[ cfg_attr( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) , allow( dead_code) ) ]
333+ #[ cfg_attr( wasi_no_threads , allow( dead_code) ) ]
334334 file_number : usize ,
335335}
336336
337337/// Merges files together. This is **not** an iterator because of lifetime problems.
338- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
338+ #[ cfg( not( wasi_no_threads ) ) ]
339339struct FileMerger < ' a > {
340340 heap : binary_heap_plus:: BinaryHeap < MergeableFile , FileComparator < ' a > > ,
341341 request_sender : Sender < ( usize , RecycledChunk ) > ,
342342 prev : Option < PreviousLine > ,
343343 reader_join_handle : JoinHandle < UResult < ( ) > > ,
344344}
345345
346- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
346+ #[ cfg( not( wasi_no_threads ) ) ]
347347impl FileMerger < ' _ > {
348348 /// Write the merged contents to the output file.
349349 fn write_all ( self , settings : & GlobalSettings , output : Output ) -> UResult < ( ) > {
@@ -425,7 +425,7 @@ struct FileComparator<'a> {
425425 settings : & ' a GlobalSettings ,
426426}
427427
428- #[ cfg( not( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ) ]
428+ #[ cfg( not( wasi_no_threads ) ) ]
429429impl Compare < MergeableFile > for FileComparator < ' _ > {
430430 fn compare ( & self , a : & MergeableFile , b : & MergeableFile ) -> Ordering {
431431 let mut cmp = compare_by (
@@ -646,20 +646,20 @@ impl<R: Read + Send> MergeInput for PlainMergeInput<R> {
646646// Synchronous merge for targets without thread support (e.g. wasm32-wasip1).
647647// ---------------------------------------------------------------------------
648648
649- #[ cfg( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ]
649+ #[ cfg( wasi_no_threads ) ]
650650struct SyncReaderFile < M : MergeInput > {
651651 file : M ,
652652 carry_over : Vec < u8 > ,
653653}
654654
655- #[ cfg( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ]
655+ #[ cfg( wasi_no_threads ) ]
656656struct SyncMergeableFile {
657657 current_chunk : Rc < Chunk > ,
658658 line_idx : usize ,
659659 file_number : usize ,
660660}
661661
662- #[ cfg( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ]
662+ #[ cfg( wasi_no_threads ) ]
663663impl Compare < SyncMergeableFile > for FileComparator < ' _ > {
664664 fn compare ( & self , a : & SyncMergeableFile , b : & SyncMergeableFile ) -> Ordering {
665665 let mut cmp = compare_by (
@@ -676,7 +676,7 @@ impl Compare<SyncMergeableFile> for FileComparator<'_> {
676676 }
677677}
678678
679- #[ cfg( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ]
679+ #[ cfg( wasi_no_threads ) ]
680680struct SyncFileMerger < ' a , M : MergeInput > {
681681 heap : binary_heap_plus:: BinaryHeap < SyncMergeableFile , FileComparator < ' a > > ,
682682 readers : Vec < Option < SyncReaderFile < M > > > ,
@@ -685,7 +685,7 @@ struct SyncFileMerger<'a, M: MergeInput> {
685685 settings : & ' a GlobalSettings ,
686686}
687687
688- #[ cfg( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ]
688+ #[ cfg( wasi_no_threads ) ]
689689impl < M : MergeInput > SyncFileMerger < ' _ , M > {
690690 fn write_all ( self , settings : & GlobalSettings , output : Output ) -> UResult < ( ) > {
691691 let mut out = output. into_write ( ) ;
@@ -782,7 +782,7 @@ impl<M: MergeInput> SyncFileMerger<'_, M> {
782782 }
783783}
784784
785- #[ cfg( all ( target_os = "wasi" , not ( target_feature = "atomics" ) ) ) ]
785+ #[ cfg( wasi_no_threads ) ]
786786fn merge_without_limit_sync < ' a , M : MergeInput + ' static , F : Iterator < Item = UResult < M > > > (
787787 files : F ,
788788 settings : & ' a GlobalSettings ,
0 commit comments