diff --git a/input-generator/src/main.rs b/input-generator/src/main.rs index b4a6ad142..082b691f6 100644 --- a/input-generator/src/main.rs +++ b/input-generator/src/main.rs @@ -1,3 +1,5 @@ +#![feature(int_to_from_bytes)] + extern crate rand; use std::collections::BTreeSet; @@ -43,7 +45,7 @@ fn f32(rng: &mut XorShiftRng) -> Result<(), Box> { let mut f = File::create("bin/input/f32")?; for i in set { - f.write_all(&i.to_bytes())?; + f.write_all(&i.to_ne_bytes())?; } Ok(()) @@ -61,8 +63,8 @@ fn f32f32(rng: &mut XorShiftRng) -> Result<(), Box> { } i += 1; - f.write_all(&x0.to_bits().to_bytes())?; - f.write_all(&x1.to_bits().to_bytes())?; + f.write_all(&x0.to_bits().to_ne_bytes())?; + f.write_all(&x1.to_bits().to_ne_bytes())?; } Ok(()) @@ -80,8 +82,8 @@ fn f32i16(rng: &mut XorShiftRng) -> Result<(), Box> { } i += 1; - f.write_all(&x0.to_bits().to_bytes())?; - f.write_all(&x1.to_bytes())?; + f.write_all(&x0.to_bits().to_ne_bytes())?; + f.write_all(&x1.to_ne_bytes())?; } Ok(()) @@ -100,9 +102,9 @@ fn f32f32f32(rng: &mut XorShiftRng) -> Result<(), Box> { } i += 1; - f.write_all(&x0.to_bits().to_bytes())?; - f.write_all(&x1.to_bits().to_bytes())?; - f.write_all(&x2.to_bits().to_bytes())?; + f.write_all(&x0.to_bits().to_ne_bytes())?; + f.write_all(&x1.to_bits().to_ne_bytes())?; + f.write_all(&x2.to_bits().to_ne_bytes())?; } Ok(()) @@ -123,7 +125,7 @@ fn f64(rng: &mut XorShiftRng) -> Result<(), Box> { let mut f = File::create("bin/input/f64")?; for i in set { - f.write_all(&i.to_bytes())?; + f.write_all(&i.to_ne_bytes())?; } Ok(()) @@ -141,8 +143,8 @@ fn f64f64(rng: &mut XorShiftRng) -> Result<(), Box> { } i += 1; - f.write_all(&x0.to_bits().to_bytes())?; - f.write_all(&x1.to_bits().to_bytes())?; + f.write_all(&x0.to_bits().to_ne_bytes())?; + f.write_all(&x1.to_bits().to_ne_bytes())?; } Ok(()) @@ -161,9 +163,9 @@ fn f64f64f64(rng: &mut XorShiftRng) -> Result<(), Box> { } i += 1; - f.write_all(&x0.to_bits().to_bytes())?; - f.write_all(&x1.to_bits().to_bytes())?; - f.write_all(&x2.to_bits().to_bytes())?; + f.write_all(&x0.to_bits().to_ne_bytes())?; + f.write_all(&x1.to_bits().to_ne_bytes())?; + f.write_all(&x2.to_bits().to_ne_bytes())?; } Ok(()) @@ -181,8 +183,8 @@ fn f64i16(rng: &mut XorShiftRng) -> Result<(), Box> { } i += 1; - f.write_all(&x0.to_bits().to_bytes())?; - f.write_all(&x1.to_bytes())?; + f.write_all(&x0.to_bits().to_ne_bytes())?; + f.write_all(&x1.to_ne_bytes())?; } Ok(()) diff --git a/musl-generator/src/macros.rs b/musl-generator/src/macros.rs index 16ba99d64..55f779500 100644 --- a/musl-generator/src/macros.rs +++ b/musl-generator/src/macros.rs @@ -16,7 +16,7 @@ macro_rules! f32 { $fun(*x) }; - $fun.write_all(&y.to_bits().to_bytes())?; + $fun.write_all(&y.to_bits().to_ne_bytes())?; )+ } }}; @@ -40,7 +40,7 @@ macro_rules! f32f32 { $fun(*x0, *x1) }; - $fun.write_all(&y.to_bits().to_bytes())?; + $fun.write_all(&y.to_bits().to_ne_bytes())?; )+ } }}; @@ -64,7 +64,7 @@ macro_rules! f32f32f32 { $fun(*x0, *x1, *x2) }; - $fun.write_all(&y.to_bits().to_bytes())?; + $fun.write_all(&y.to_bits().to_ne_bytes())?; )+ } }}; @@ -88,7 +88,7 @@ macro_rules! f32i32 { $fun(*x0, *x1 as i32) }; - $fun.write_all(&y.to_bits().to_bytes())?; + $fun.write_all(&y.to_bits().to_ne_bytes())?; )+ } }}; @@ -112,7 +112,7 @@ macro_rules! f64 { $fun(*x) }; - $fun.write_all(&y.to_bits().to_bytes())?; + $fun.write_all(&y.to_bits().to_ne_bytes())?; )+ } }}; @@ -136,7 +136,7 @@ macro_rules! f64f64 { $fun(*x0, *x1) }; - $fun.write_all(&y.to_bits().to_bytes())?; + $fun.write_all(&y.to_bits().to_ne_bytes())?; )+ } }}; @@ -160,7 +160,7 @@ macro_rules! f64f64f64 { $fun(*x0, *x1, *x2) }; - $fun.write_all(&y.to_bits().to_bytes())?; + $fun.write_all(&y.to_bits().to_ne_bytes())?; )+ } }}; @@ -184,7 +184,7 @@ macro_rules! f64i32 { $fun(*x0, *x1 as i32) }; - $fun.write_all(&y.to_bits().to_bytes())?; + $fun.write_all(&y.to_bits().to_ne_bytes())?; )+ } }}; diff --git a/musl-generator/src/main.rs b/musl-generator/src/main.rs index 6e57e856d..4ff1ff81d 100644 --- a/musl-generator/src/main.rs +++ b/musl-generator/src/main.rs @@ -1,3 +1,5 @@ +#![feature(int_to_from_bytes)] + extern crate libm; extern crate shared; diff --git a/newlib-generator/src/macros.rs b/newlib-generator/src/macros.rs index 84315a777..c9cf8d877 100644 --- a/newlib-generator/src/macros.rs +++ b/newlib-generator/src/macros.rs @@ -6,6 +6,8 @@ macro_rules! f32 { fs::create_dir_all("math/src")?; let main = format!(" +#![feature(int_to_from_bytes)] + #![no_main] #![no_std] @@ -33,10 +35,10 @@ fn run() -> Result<(), usize> {{ let mut buf = [0; 4]; while let Ok(()) = io::Stdin.read_exact(&mut buf) {{ - let x = f32::from_bits(u32::from_bytes(buf)); + let x = f32::from_bits(u32::from_ne_bytes(buf)); let y = unsafe {{ {0}(x) }}; - io::Stdout.write_all(&y.to_bits().to_bytes())?; + io::Stdout.write_all(&y.to_bits().to_ne_bytes())?; }} Ok(()) @@ -63,7 +65,8 @@ pub fn __errno() -> *mut i32 {{ .arg("math/target/thumbv7em-none-eabi/release/math") .stdin(Stdio::piped()) .stdout(Stdio::piped()) - .spawn()?; + .spawn() + .map_err(|_| "missing qemu-arm!")?; qemu.stdin.as_mut().take().unwrap().write_all(F32)?; @@ -83,6 +86,8 @@ macro_rules! f32f32 { fs::create_dir_all("math/src")?; let main = format!(" +#![feature(int_to_from_bytes)] + #![no_main] #![no_std] @@ -112,14 +117,14 @@ fn run() -> Result<(), usize> {{ while let Ok(()) = io::Stdin.read_exact(&mut chunk) {{ let mut buf = [0; 4]; buf.copy_from_slice(&chunk[..4]); - let x0 = f32::from_bits(u32::from_bytes(buf)); + let x0 = f32::from_bits(u32::from_ne_bytes(buf)); buf.copy_from_slice(&chunk[4..]); - let x1 = f32::from_bits(u32::from_bytes(buf)); + let x1 = f32::from_bits(u32::from_ne_bytes(buf)); let y = unsafe {{ {0}(x0, x1) }}; - io::Stdout.write_all(&y.to_bits().to_bytes())?; + io::Stdout.write_all(&y.to_bits().to_ne_bytes())?; }} Ok(()) @@ -146,7 +151,8 @@ pub fn __errno() -> *mut i32 {{ .arg("math/target/thumbv7em-none-eabi/release/math") .stdin(Stdio::piped()) .stdout(Stdio::piped()) - .spawn()?; + .spawn() + .map_err(|_| "missing qemu-arm!")?; qemu.stdin.as_mut().take().unwrap().write_all(F32)?; @@ -166,6 +172,8 @@ macro_rules! f32f32f32 { fs::create_dir_all("math/src")?; let main = format!(" +#![feature(int_to_from_bytes)] + #![no_main] #![no_std] @@ -195,17 +203,17 @@ fn run() -> Result<(), usize> {{ while let Ok(()) = io::Stdin.read_exact(&mut chunk) {{ let mut buf = [0; 4]; buf.copy_from_slice(&chunk[..4]); - let x0 = f32::from_bits(u32::from_bytes(buf)); + let x0 = f32::from_bits(u32::from_ne_bytes(buf)); buf.copy_from_slice(&chunk[4..8]); - let x1 = f32::from_bits(u32::from_bytes(buf)); + let x1 = f32::from_bits(u32::from_ne_bytes(buf)); buf.copy_from_slice(&chunk[8..]); - let x2 = f32::from_bits(u32::from_bytes(buf)); + let x2 = f32::from_bits(u32::from_ne_bytes(buf)); let y = unsafe {{ {0}(x0, x1, x2) }}; - io::Stdout.write_all(&y.to_bits().to_bytes())?; + io::Stdout.write_all(&y.to_bits().to_ne_bytes())?; }} Ok(()) @@ -232,7 +240,8 @@ pub fn __errno() -> *mut i32 {{ .arg("math/target/thumbv7em-none-eabi/release/math") .stdin(Stdio::piped()) .stdout(Stdio::piped()) - .spawn()?; + .spawn() + .map_err(|_| "missing qemu-arm!")?; qemu.stdin.as_mut().take().unwrap().write_all(F32)?; diff --git a/shared/src/lib.rs b/shared/src/lib.rs index 84676f94f..6189c0daa 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(exact_chunks)] +#![feature(exact_chunks, int_to_from_bytes)] #[macro_use] extern crate lazy_static; @@ -12,7 +12,7 @@ lazy_static! { .map(|chunk| { let mut buf = [0; 4]; buf.copy_from_slice(chunk); - f32::from_bits(u32::from_le(u32::from_bytes(buf))) + f32::from_bits(u32::from_le_bytes(buf)) }) .collect() }; @@ -28,8 +28,8 @@ lazy_static! { x1.copy_from_slice(&chunk[4..]); ( - f32::from_bits(u32::from_le(u32::from_bytes(x0))), - f32::from_bits(u32::from_le(u32::from_bytes(x1))), + f32::from_bits(u32::from_le_bytes(x0)), + f32::from_bits(u32::from_le_bytes(x1)), ) }) .collect() @@ -48,9 +48,9 @@ lazy_static! { x2.copy_from_slice(&chunk[8..]); ( - f32::from_bits(u32::from_le(u32::from_bytes(x0))), - f32::from_bits(u32::from_le(u32::from_bytes(x1))), - f32::from_bits(u32::from_le(u32::from_bytes(x2))), + f32::from_bits(u32::from_le_bytes(x0)), + f32::from_bits(u32::from_le_bytes(x1)), + f32::from_bits(u32::from_le_bytes(x2)), ) }) .collect() @@ -67,8 +67,8 @@ lazy_static! { x1.copy_from_slice(&chunk[4..]); ( - f32::from_bits(u32::from_le(u32::from_bytes(x0))), - i16::from_le(i16::from_bytes(x1)) as i32, + f32::from_bits(u32::from_le_bytes(x0)), + i16::from_le(i16::from_ne_bytes(x1)) as i32, ) }) .collect() @@ -81,7 +81,7 @@ lazy_static! { .map(|chunk| { let mut buf = [0; 8]; buf.copy_from_slice(chunk); - f64::from_bits(u64::from_le(u64::from_bytes(buf))) + f64::from_bits(u64::from_le(u64::from_ne_bytes(buf))) }) .collect() }; @@ -97,8 +97,8 @@ lazy_static! { x1.copy_from_slice(&chunk[8..]); ( - f64::from_bits(u64::from_le(u64::from_bytes(x0))), - f64::from_bits(u64::from_le(u64::from_bytes(x1))), + f64::from_bits(u64::from_le(u64::from_ne_bytes(x0))), + f64::from_bits(u64::from_le(u64::from_ne_bytes(x1))), ) }) .collect() @@ -117,9 +117,9 @@ lazy_static! { x2.copy_from_slice(&chunk[16..]); ( - f64::from_bits(u64::from_le(u64::from_bytes(x0))), - f64::from_bits(u64::from_le(u64::from_bytes(x1))), - f64::from_bits(u64::from_le(u64::from_bytes(x2))), + f64::from_bits(u64::from_le(u64::from_ne_bytes(x0))), + f64::from_bits(u64::from_le(u64::from_ne_bytes(x1))), + f64::from_bits(u64::from_le(u64::from_ne_bytes(x2))), ) }) .collect() @@ -136,8 +136,8 @@ lazy_static! { x1.copy_from_slice(&chunk[8..]); ( - f64::from_bits(u64::from_le(u64::from_bytes(x0))), - i16::from_le(i16::from_bytes(x1)) as i32, + f64::from_bits(u64::from_le(u64::from_ne_bytes(x0))), + i16::from_le(i16::from_ne_bytes(x1)) as i32, ) }) .collect() @@ -155,7 +155,7 @@ macro_rules! f32 { .map(|chunk| { let mut buf = [0; 4]; buf.copy_from_slice(chunk); - f32::from_bits(u32::from_le(u32::from_bytes(buf))) + f32::from_bits(u32::from_le_bytes(buf)) }) .collect::>(); @@ -194,7 +194,7 @@ macro_rules! f32f32 { .map(|chunk| { let mut buf = [0; 4]; buf.copy_from_slice(chunk); - f32::from_bits(u32::from_le(u32::from_bytes(buf))) + f32::from_bits(u32::from_le_bytes(buf)) }) .collect::>(); @@ -235,7 +235,7 @@ macro_rules! f32f32f32 { .map(|chunk| { let mut buf = [0; 4]; buf.copy_from_slice(chunk); - f32::from_bits(u32::from_le(u32::from_bytes(buf))) + f32::from_bits(u32::from_le_bytes(buf)) }) .collect::>(); @@ -277,7 +277,7 @@ macro_rules! f32i32 { .map(|chunk| { let mut buf = [0; 4]; buf.copy_from_slice(chunk); - f32::from_bits(u32::from_le(u32::from_bytes(buf))) + f32::from_bits(u32::from_le_bytes(buf)) }) .collect::>(); @@ -318,7 +318,7 @@ macro_rules! f64 { .map(|chunk| { let mut buf = [0; 8]; buf.copy_from_slice(chunk); - f64::from_bits(u64::from_le(u64::from_bytes(buf))) + f64::from_bits(u64::from_le(u64::from_ne_bytes(buf))) }) .collect::>(); @@ -357,7 +357,7 @@ macro_rules! f64f64 { .map(|chunk| { let mut buf = [0; 8]; buf.copy_from_slice(chunk); - f64::from_bits(u64::from_le(u64::from_bytes(buf))) + f64::from_bits(u64::from_le(u64::from_ne_bytes(buf))) }) .collect::>(); @@ -398,7 +398,7 @@ macro_rules! f64f64f64 { .map(|chunk| { let mut buf = [0; 8]; buf.copy_from_slice(chunk); - f64::from_bits(u64::from_le(u64::from_bytes(buf))) + f64::from_bits(u64::from_le(u64::from_ne_bytes(buf))) }) .collect::>(); @@ -440,7 +440,7 @@ macro_rules! f64i32 { .map(|chunk| { let mut buf = [0; 8]; buf.copy_from_slice(chunk); - f64::from_bits(u64::from_le(u64::from_bytes(buf))) + f64::from_bits(u64::from_le(u64::from_ne_bytes(buf))) }) .collect::>();