summaryrefslogtreecommitdiff
path: root/src/macros.rs
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2021-04-04 08:39:05 -0600
committerAlan Somers <asomers@gmail.com>2021-04-04 08:39:05 -0600
commit987c8a607b7b5b12660efeb50376ccce6b17e9a6 (patch)
treeb084ae56e100fcadae36acce9cbac1dc91d3d24a /src/macros.rs
parent6af11c1e70b02e1af36fdc339238d3a117fd3a94 (diff)
downloadnix-987c8a607b7b5b12660efeb50376ccce6b17e9a6.zip
Use memoffset::offset_of instead of homegrown macro
The homegrown macro was fine in 2016, but at some point it technically became UB. The memoffset crate does the same thing, but avoids UB when using rustc 1.51.0 or later. Fixes #1415
Diffstat (limited to 'src/macros.rs')
-rw-r--r--src/macros.rs13
1 files changed, 0 insertions, 13 deletions
diff --git a/src/macros.rs b/src/macros.rs
index feb02ea7..7d6ac8df 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -203,16 +203,3 @@ macro_rules! libc_enum {
}
};
}
-
-/// A Rust version of the familiar C `offset_of` macro. It returns the byte
-/// offset of `field` within struct `ty`
-#[cfg(not(target_os = "redox"))]
-macro_rules! offset_of {
- ($ty:ty, $field:ident) => {{
- // Safe because we don't actually read from the dereferenced pointer
- #[allow(unused_unsafe)] // for when the macro is used in an unsafe block
- unsafe {
- &(*(ptr::null() as *const $ty)).$field as *const _ as usize
- }
- }}
-}