13
13
//! This implementation is mmap-ing the memory of the guest into the current process.
14
14
15
15
use std:: borrow:: Borrow ;
16
- #[ cfg( unix) ]
16
+ #[ cfg( target_family = " unix" ) ]
17
17
use std:: io:: { Seek , SeekFrom } ;
18
18
use std:: ops:: Deref ;
19
19
use std:: result;
@@ -28,24 +28,24 @@ use crate::guest_memory::{
28
28
use crate :: volatile_memory:: { VolatileMemory , VolatileSlice } ;
29
29
use crate :: { AtomicAccess , Bytes , ReadVolatile , WriteVolatile } ;
30
30
31
- #[ cfg( all( not( feature = "xen" ) , unix) ) ]
31
+ #[ cfg( all( not( feature = "xen" ) , target_family = " unix" ) ) ]
32
32
mod unix;
33
33
34
- #[ cfg( all( feature = "xen" , unix) ) ]
34
+ #[ cfg( all( feature = "xen" , target_family = " unix" ) ) ]
35
35
pub ( crate ) mod xen;
36
36
37
- #[ cfg( windows) ]
37
+ #[ cfg( target_family = " windows" ) ]
38
38
mod windows;
39
39
40
- #[ cfg( all( not( feature = "xen" ) , unix) ) ]
40
+ #[ cfg( all( not( feature = "xen" ) , target_family = " unix" ) ) ]
41
41
pub use unix:: { Error as MmapRegionError , MmapRegion , MmapRegionBuilder } ;
42
42
43
- #[ cfg( all( feature = "xen" , unix) ) ]
43
+ #[ cfg( all( feature = "xen" , target_family = " unix" ) ) ]
44
44
pub use xen:: { Error as MmapRegionError , MmapRange , MmapRegion , MmapXenFlags } ;
45
45
46
- #[ cfg( windows) ]
46
+ #[ cfg( target_family = " windows" ) ]
47
47
pub use std:: io:: Error as MmapRegionError ;
48
- #[ cfg( windows) ]
48
+ #[ cfg( target_family = " windows" ) ]
49
49
pub use windows:: MmapRegion ;
50
50
51
51
/// A `Bitmap` that can be created starting from an initial size.
@@ -80,7 +80,7 @@ pub enum Error {
80
80
}
81
81
82
82
// TODO: use this for Windows as well after we redefine the Error type there.
83
- #[ cfg( unix) ]
83
+ #[ cfg( target_family = " unix" ) ]
84
84
/// Checks if a mapping of `size` bytes fits at the provided `file_offset`.
85
85
///
86
86
/// For a borrowed `FileOffset` and size, this function checks whether the mapping does not
@@ -1042,7 +1042,7 @@ mod tests {
1042
1042
let gm_list = [ gm, gm_backed_by_file] ;
1043
1043
for gm in gm_list. iter ( ) {
1044
1044
let addr = GuestAddress ( 0x1010 ) ;
1045
- let mut file = if cfg ! ( unix) {
1045
+ let mut file = if cfg ! ( target_family = " unix" ) {
1046
1046
File :: open ( Path :: new ( "/dev/zero" ) ) . unwrap ( )
1047
1047
} else {
1048
1048
File :: open ( Path :: new ( "c:\\ Windows\\ system32\\ ntoskrnl.exe" ) ) . unwrap ( )
@@ -1051,7 +1051,7 @@ mod tests {
1051
1051
gm. read_exact_volatile_from ( addr, & mut file, mem:: size_of :: < u32 > ( ) )
1052
1052
. unwrap ( ) ;
1053
1053
let value: u32 = gm. read_obj ( addr) . unwrap ( ) ;
1054
- if cfg ! ( unix) {
1054
+ if cfg ! ( target_family = " unix" ) {
1055
1055
assert_eq ! ( value, 0 ) ;
1056
1056
} else {
1057
1057
assert_eq ! ( value, 0x0090_5a4d ) ;
@@ -1060,7 +1060,7 @@ mod tests {
1060
1060
let mut sink = vec ! [ 0 ; mem:: size_of:: <u32 >( ) ] ;
1061
1061
gm. write_all_volatile_to ( addr, & mut sink. as_mut_slice ( ) , mem:: size_of :: < u32 > ( ) )
1062
1062
. unwrap ( ) ;
1063
- if cfg ! ( unix) {
1063
+ if cfg ! ( target_family = " unix" ) {
1064
1064
assert_eq ! ( sink, vec![ 0 ; mem:: size_of:: <u32 >( ) ] ) ;
1065
1065
} else {
1066
1066
assert_eq ! ( sink, vec![ 0x4d , 0x5a , 0x90 , 0x00 ] ) ;
@@ -1179,7 +1179,7 @@ mod tests {
1179
1179
// used for the backing file. Refer to Microsoft docs here:
1180
1180
// https://docs.microsoft.com/en-us/windows/desktop/api/memoryapi/nf-memoryapi-mapviewoffile
1181
1181
#[ test]
1182
- #[ cfg( unix) ]
1182
+ #[ cfg( target_family = " unix" ) ]
1183
1183
fn test_retrieve_offset_from_fd_backing_memory_region ( ) {
1184
1184
let f = TempFile :: new ( ) . unwrap ( ) . into_file ( ) ;
1185
1185
f. set_len ( 0x1400 ) . unwrap ( ) ;
0 commit comments