Files
KAT/vendor/libhackrf/src/util.rs
T
KaraZajac 84b75ee6b5 Fix ARM compilation: vendor libhackrf with c_char portability fix
The upstream libhackrf v0.1.1 crate fails to compile on ARM because
c_char is u8 on ARM (not i8 like on x86). The transmute at lib.rs:102
explicitly casts &[i8] -> &[u8], but on ARM the source is already &[u8],
causing a type mismatch.

Vendored the crate at vendor/libhackrf/ with the transmute replaced by
slice::from_raw_parts with a pointer cast, which works on both
architectures. Also cleaned up transmute calls in transfer.rs.

Fixes #1
2026-03-22 11:14:41 -04:00

22 lines
457 B
Rust

use num_complex::Complex;
pub trait ToComplexI8 {
fn to_i8(self) -> Complex<i8>;
}
pub trait ToComplexF32 {
fn to_f32(self) -> Complex<f32>;
}
impl ToComplexI8 for Complex<f32> {
fn to_i8(self) -> Complex<i8> {
Complex::new((self.re * 127.0) as i8, (self.im * 127.0) as i8)
}
}
impl ToComplexF32 for Complex<i8> {
fn to_f32(self) -> Complex<f32> {
Complex::new(self.re as f32 / 127.0, self.im as f32 / 127.0)
}
}