Skip to content

Commit 55d4afd

Browse files
committed
Remove byteorder dependency
1 parent 7285c13 commit 55d4afd

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ gimli = { version = "0.21.0", default-features = false, features = ["write"]}
1919
object = { version = "0.21.1", default-features = false, features = ["read", "std", "write"] }
2020

2121
ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
22-
byteorder = "1.2.7"
2322
indexmap = "1.0.2"
2423
cfg-if = "0.1.10"
2524
libloading = { version = "0.6.0", optional = true }

src/vtable.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,23 @@ fn build_vtable<'tcx>(
168168
}
169169

170170
fn write_usize(tcx: TyCtxt<'_>, buf: &mut [u8], idx: usize, num: u64) {
171-
use byteorder::{BigEndian, LittleEndian, WriteBytesExt};
172-
173-
let usize_size = tcx
171+
let pointer_size = tcx
174172
.layout_of(ParamEnv::reveal_all().and(tcx.types.usize))
175173
.unwrap()
176174
.size
177175
.bytes() as usize;
178-
let mut target = &mut buf[idx * usize_size..(idx + 1) * usize_size];
176+
let target = &mut buf[idx * pointer_size..(idx + 1) * pointer_size];
179177

180178
match tcx.data_layout.endian {
181-
rustc_target::abi::Endian::Little => target.write_uint::<LittleEndian>(num, usize_size),
182-
rustc_target::abi::Endian::Big => target.write_uint::<BigEndian>(num, usize_size),
179+
rustc_target::abi::Endian::Little => match pointer_size {
180+
4 => target.copy_from_slice(&(num as u32).to_le_bytes()),
181+
8 => target.copy_from_slice(&(num as u64).to_le_bytes()),
182+
_ => todo!("pointer size {} is not yet supported", pointer_size),
183+
},
184+
rustc_target::abi::Endian::Big => match pointer_size {
185+
4 => target.copy_from_slice(&(num as u32).to_be_bytes()),
186+
8 => target.copy_from_slice(&(num as u64).to_be_bytes()),
187+
_ => todo!("pointer size {} is not yet supported", pointer_size),
188+
},
183189
}
184-
.unwrap()
185190
}

0 commit comments

Comments
 (0)