File tree 3 files changed +4
-14
lines changed
3 files changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,6 @@ mod tests {
247
247
assert_eq ! ( mem:: size_of:: <E820Entry >( ) , 20 ) ;
248
248
assert_eq ! ( mem:: size_of:: <Params >( ) , 4096 ) ;
249
249
250
- assert_eq ! ( offset_of!( Params , hdr) , HEADER_START ) ;
250
+ assert_eq ! ( core :: mem :: offset_of!( Params , hdr) , HEADER_START ) ;
251
251
}
252
252
}
Original file line number Diff line number Diff line change 1
1
// SPDX-License-Identifier: Apache-2.0
2
2
// Copyright © 2019 Intel Corporation
3
3
4
- #[ macro_export]
5
- macro_rules! offset_of {
6
- ( $container: ty, $field: ident) => {
7
- #[ allow( deref_nullptr) ]
8
- unsafe {
9
- & ( * ( core:: ptr:: null( ) as * const $container) ) . $field as * const _ as usize
10
- }
11
- } ;
12
- }
13
-
14
4
#[ macro_export]
15
5
macro_rules! container_of {
16
6
( $ptr: ident, $container: ty, $field: ident) => { {
17
- ( ( $ptr as usize ) - offset_of!( $container, $field) ) as * const $container
7
+ ( ( $ptr as usize ) - core :: mem :: offset_of!( $container, $field) ) as * const $container
18
8
} } ;
19
9
}
20
10
21
11
#[ macro_export]
22
12
macro_rules! container_of_mut {
23
13
( $ptr: ident, $container: ty, $field: ident) => { {
24
- ( ( $ptr as usize ) - offset_of!( $container, $field) ) as * mut $container
14
+ ( ( $ptr as usize ) - core :: mem :: offset_of!( $container, $field) ) as * mut $container
25
15
} } ;
26
16
}
27
17
Original file line number Diff line number Diff line change 4
4
use core:: {
5
5
cell:: SyncUnsafeCell ,
6
6
ffi:: c_void,
7
- mem:: { size_of, transmute} ,
7
+ mem:: { offset_of , size_of, transmute} ,
8
8
ptr:: null_mut,
9
9
slice:: from_raw_parts,
10
10
} ;
You can’t perform that action at this time.
0 commit comments