Remove byteorder dependency
This commit is contained in:
parent
7285c134d1
commit
55d4afd2ba
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -317,7 +317,6 @@ name = "rustc_codegen_cranelift"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ar",
|
"ar",
|
||||||
"byteorder",
|
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
"cranelift-frontend",
|
"cranelift-frontend",
|
||||||
|
@ -19,7 +19,6 @@ gimli = { version = "0.21.0", default-features = false, features = ["write"]}
|
|||||||
object = { version = "0.21.1", default-features = false, features = ["read", "std", "write"] }
|
object = { version = "0.21.1", default-features = false, features = ["read", "std", "write"] }
|
||||||
|
|
||||||
ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
|
ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
|
||||||
byteorder = "1.2.7"
|
|
||||||
indexmap = "1.0.2"
|
indexmap = "1.0.2"
|
||||||
cfg-if = "0.1.10"
|
cfg-if = "0.1.10"
|
||||||
libloading = { version = "0.6.0", optional = true }
|
libloading = { version = "0.6.0", optional = true }
|
||||||
|
@ -168,18 +168,23 @@ fn build_vtable<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn write_usize(tcx: TyCtxt<'_>, buf: &mut [u8], idx: usize, num: u64) {
|
fn write_usize(tcx: TyCtxt<'_>, buf: &mut [u8], idx: usize, num: u64) {
|
||||||
use byteorder::{BigEndian, LittleEndian, WriteBytesExt};
|
let pointer_size = tcx
|
||||||
|
|
||||||
let usize_size = tcx
|
|
||||||
.layout_of(ParamEnv::reveal_all().and(tcx.types.usize))
|
.layout_of(ParamEnv::reveal_all().and(tcx.types.usize))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.size
|
.size
|
||||||
.bytes() as usize;
|
.bytes() as usize;
|
||||||
let mut target = &mut buf[idx * usize_size..(idx + 1) * usize_size];
|
let target = &mut buf[idx * pointer_size..(idx + 1) * pointer_size];
|
||||||
|
|
||||||
match tcx.data_layout.endian {
|
match tcx.data_layout.endian {
|
||||||
rustc_target::abi::Endian::Little => target.write_uint::<LittleEndian>(num, usize_size),
|
rustc_target::abi::Endian::Little => match pointer_size {
|
||||||
rustc_target::abi::Endian::Big => target.write_uint::<BigEndian>(num, usize_size),
|
4 => target.copy_from_slice(&(num as u32).to_le_bytes()),
|
||||||
|
8 => target.copy_from_slice(&(num as u64).to_le_bytes()),
|
||||||
|
_ => todo!("pointer size {} is not yet supported", pointer_size),
|
||||||
|
},
|
||||||
|
rustc_target::abi::Endian::Big => match pointer_size {
|
||||||
|
4 => target.copy_from_slice(&(num as u32).to_be_bytes()),
|
||||||
|
8 => target.copy_from_slice(&(num as u64).to_be_bytes()),
|
||||||
|
_ => todo!("pointer size {} is not yet supported", pointer_size),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user