@@ -8,10 +8,10 @@ use crate::volatile_memory::copy_slice_impl::{copy_from_volatile_slice, copy_to_
88use crate :: { VolatileMemoryError , VolatileSlice } ;
99use std:: io:: { Cursor , ErrorKind } ;
1010
11- #[ cfg( feature = "rawfd" ) ]
11+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
1212use std:: io:: Stdout ;
1313
14- #[ cfg( feature = "rawfd" ) ]
14+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
1515use std:: os:: fd:: { AsFd , AsRawFd , BorrowedFd } ;
1616
1717macro_rules! retry_eintr {
@@ -131,7 +131,7 @@ pub trait WriteVolatile {
131131
132132macro_rules! impl_read_write_volatile_for_raw_fd {
133133 ( $raw_fd_ty: ty) => {
134- #[ cfg( feature = "rawfd" ) ]
134+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
135135 impl ReadVolatile for $raw_fd_ty {
136136 fn read_volatile<B : BitmapSlice >(
137137 & mut self ,
@@ -141,7 +141,7 @@ macro_rules! impl_read_write_volatile_for_raw_fd {
141141 }
142142 }
143143
144- #[ cfg( feature = "rawfd" ) ]
144+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
145145 impl ReadVolatile for & $raw_fd_ty {
146146 fn read_volatile<B : BitmapSlice >(
147147 & mut self ,
@@ -151,7 +151,7 @@ macro_rules! impl_read_write_volatile_for_raw_fd {
151151 }
152152 }
153153
154- #[ cfg( feature = "rawfd" ) ]
154+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
155155 impl ReadVolatile for & mut $raw_fd_ty {
156156 fn read_volatile<B : BitmapSlice >(
157157 & mut self ,
@@ -161,7 +161,7 @@ macro_rules! impl_read_write_volatile_for_raw_fd {
161161 }
162162 }
163163
164- #[ cfg( feature = "rawfd" ) ]
164+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
165165 impl WriteVolatile for $raw_fd_ty {
166166 fn write_volatile<B : BitmapSlice >(
167167 & mut self ,
@@ -171,7 +171,7 @@ macro_rules! impl_read_write_volatile_for_raw_fd {
171171 }
172172 }
173173
174- #[ cfg( feature = "rawfd" ) ]
174+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
175175 impl WriteVolatile for & $raw_fd_ty {
176176 fn write_volatile<B : BitmapSlice >(
177177 & mut self ,
@@ -181,7 +181,7 @@ macro_rules! impl_read_write_volatile_for_raw_fd {
181181 }
182182 }
183183
184- #[ cfg( feature = "rawfd" ) ]
184+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
185185 impl WriteVolatile for & mut $raw_fd_ty {
186186 fn write_volatile<B : BitmapSlice >(
187187 & mut self ,
@@ -193,7 +193,7 @@ macro_rules! impl_read_write_volatile_for_raw_fd {
193193 } ;
194194}
195195
196- #[ cfg( feature = "rawfd" ) ]
196+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
197197impl WriteVolatile for Stdout {
198198 fn write_volatile < B : BitmapSlice > (
199199 & mut self ,
@@ -203,7 +203,7 @@ impl WriteVolatile for Stdout {
203203 }
204204}
205205
206- #[ cfg( feature = "rawfd" ) ]
206+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
207207impl WriteVolatile for & Stdout {
208208 fn write_volatile < B : BitmapSlice > (
209209 & mut self ,
@@ -223,7 +223,7 @@ impl_read_write_volatile_for_raw_fd!(std::os::fd::BorrowedFd<'_>);
223223/// the given [`VolatileSlice`].
224224///
225225/// Returns the numbers of bytes read.
226- #[ cfg( feature = "rawfd" ) ]
226+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
227227fn read_volatile_raw_fd (
228228 raw_fd : BorrowedFd < ' _ > ,
229229 buf : & mut VolatileSlice < impl BitmapSlice > ,
@@ -254,7 +254,7 @@ fn read_volatile_raw_fd(
254254/// data stored in the given [`VolatileSlice`].
255255///
256256/// Returns the numbers of bytes written.
257- #[ cfg( feature = "rawfd" ) ]
257+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
258258fn write_volatile_raw_fd (
259259 raw_fd : BorrowedFd < ' _ > ,
260260 buf : & VolatileSlice < impl BitmapSlice > ,
@@ -435,9 +435,9 @@ mod tests {
435435 use crate :: io:: { ReadVolatile , WriteVolatile } ;
436436 use crate :: { VolatileMemoryError , VolatileSlice } ;
437437 use std:: io:: { Cursor , ErrorKind } ;
438- #[ cfg( feature = "rawfd" ) ]
438+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
439439 use std:: io:: { Read , Seek , Write } ;
440- #[ cfg( feature = "rawfd" ) ]
440+ #[ cfg( all ( feature = "rawfd" , not ( target_os = "windows" ) ) ) ]
441441 use vmm_sys_util:: tempfile:: TempFile ;
442442
443443 // ---- Test ReadVolatile for &[u8] ----
@@ -474,7 +474,7 @@ mod tests {
474474 }
475475
476476 // ---- Test ReadVolatile for File ----
477- #[ cfg( all( feature = "rawfd" , not( miri) ) ) ]
477+ #[ cfg( all( feature = "rawfd" , not( miri) , not ( target_os = "windows" ) ) ) ]
478478 fn read_4_bytes_from_file ( source : Vec < u8 > , expected_output : [ u8 ; 5 ] ) {
479479 let mut temp_file = TempFile :: new ( ) . unwrap ( ) . into_file ( ) ;
480480 temp_file. write_all ( source. as_ref ( ) ) . unwrap ( ) ;
@@ -518,7 +518,7 @@ mod tests {
518518
519519 for ( input, output) in test_cases {
520520 read_4_bytes_to_5_byte_memory ( input. clone ( ) , output) ;
521- #[ cfg( all( feature = "rawfd" , not( miri) ) ) ]
521+ #[ cfg( all( feature = "rawfd" , not( miri) , not ( target_os = "windows" ) ) ) ]
522522 read_4_bytes_from_file ( input, output) ;
523523 }
524524 }
@@ -559,7 +559,7 @@ mod tests {
559559 }
560560
561561 // ---- Test ẂriteVolatile for File works ----
562- #[ cfg( all( feature = "rawfd" , not( miri) ) ) ]
562+ #[ cfg( all( feature = "rawfd" , not( miri) , not ( target_os = "windows" ) ) ) ]
563563 fn write_5_bytes_to_file ( mut source : Vec < u8 > ) {
564564 // Test write_volatile for File works
565565 let mut temp_file = TempFile :: new ( ) . unwrap ( ) . into_file ( ) ;
@@ -603,7 +603,7 @@ mod tests {
603603
604604 for ( input, output) in test_cases {
605605 write_4_bytes_to_5_byte_vec ( input. clone ( ) , output) ;
606- #[ cfg( all( feature = "rawfd" , not( miri) ) ) ]
606+ #[ cfg( all( feature = "rawfd" , not( miri) , not ( target_os = "windows" ) ) ) ]
607607 write_5_bytes_to_file ( input) ;
608608 }
609609 }
0 commit comments