Implement Deref for PtraceFlags

This commit is contained in:
jD91mZM2
2019-07-29 08:31:21 +02:00
parent a0581db1fa
commit 51f0ef2826

View File

@@ -1,4 +1,5 @@
use bitflags::bitflags as inner_bitflags;
use core::{mem, ops::Deref, slice};
macro_rules! bitflags {
(
@@ -132,6 +133,18 @@ bitflags! {
const PTRACE_FLAG_MASK = 0x0000_0000_0000_F000;
}
}
impl Deref for PtraceFlags {
type Target = [u8];
fn deref(&self) -> &Self::Target {
// Same as to_ne_bytes but in-place
unsafe {
slice::from_raw_parts(
&self.bits as *const _ as *const u8,
mem::size_of::<u64>()
)
}
}
}
pub const SEEK_SET: usize = 0;
pub const SEEK_CUR: usize = 1;