Suppress cast_ptr_alignment clippy errors.
These are only used in places that use `write_unaligned`, so it's ok that the pointer might be misaligned.
This commit is contained in:
@@ -84,6 +84,7 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
|
|||||||
|
|
||||||
fn put2(&mut self, x: u16) {
|
fn put2(&mut self, x: u16) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||||
write_unaligned(self.data.offset(self.offset) as *mut u16, x);
|
write_unaligned(self.data.offset(self.offset) as *mut u16, x);
|
||||||
}
|
}
|
||||||
self.offset += 2;
|
self.offset += 2;
|
||||||
@@ -91,6 +92,7 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
|
|||||||
|
|
||||||
fn put4(&mut self, x: u32) {
|
fn put4(&mut self, x: u32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||||
write_unaligned(self.data.offset(self.offset) as *mut u32, x);
|
write_unaligned(self.data.offset(self.offset) as *mut u32, x);
|
||||||
}
|
}
|
||||||
self.offset += 4;
|
self.offset += 4;
|
||||||
@@ -98,6 +100,7 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
|
|||||||
|
|
||||||
fn put8(&mut self, x: u64) {
|
fn put8(&mut self, x: u64) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||||
write_unaligned(self.data.offset(self.offset) as *mut u64, x);
|
write_unaligned(self.data.offset(self.offset) as *mut u64, x);
|
||||||
}
|
}
|
||||||
self.offset += 8;
|
self.offset += 8;
|
||||||
|
|||||||
@@ -238,14 +238,17 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
|
|||||||
match reloc {
|
match reloc {
|
||||||
Reloc::Abs4 => {
|
Reloc::Abs4 => {
|
||||||
// TODO: Handle overflow.
|
// TODO: Handle overflow.
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||||
unsafe { write_unaligned(at as *mut u32, what as u32) };
|
unsafe { write_unaligned(at as *mut u32, what as u32) };
|
||||||
}
|
}
|
||||||
Reloc::Abs8 => {
|
Reloc::Abs8 => {
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||||
unsafe { write_unaligned(at as *mut u64, what as u64) };
|
unsafe { write_unaligned(at as *mut u64, what as u64) };
|
||||||
}
|
}
|
||||||
Reloc::X86PCRel4 => {
|
Reloc::X86PCRel4 => {
|
||||||
// TODO: Handle overflow.
|
// TODO: Handle overflow.
|
||||||
let pcrel = ((what as isize) - (at as isize)) as i32;
|
let pcrel = ((what as isize) - (at as isize)) as i32;
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||||
unsafe { write_unaligned(at as *mut i32, pcrel) };
|
unsafe { write_unaligned(at as *mut i32, pcrel) };
|
||||||
}
|
}
|
||||||
Reloc::X86GOTPCRel4 |
|
Reloc::X86GOTPCRel4 |
|
||||||
@@ -295,9 +298,11 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
|
|||||||
match reloc {
|
match reloc {
|
||||||
Reloc::Abs4 => {
|
Reloc::Abs4 => {
|
||||||
// TODO: Handle overflow.
|
// TODO: Handle overflow.
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||||
unsafe { write_unaligned(at as *mut u32, what as u32) };
|
unsafe { write_unaligned(at as *mut u32, what as u32) };
|
||||||
}
|
}
|
||||||
Reloc::Abs8 => {
|
Reloc::Abs8 => {
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||||
unsafe { write_unaligned(at as *mut u64, what as u64) };
|
unsafe { write_unaligned(at as *mut u64, what as u64) };
|
||||||
}
|
}
|
||||||
Reloc::X86PCRel4 |
|
Reloc::X86PCRel4 |
|
||||||
|
|||||||
Reference in New Issue
Block a user