no_std builds again

This commit is contained in:
Dominik Maier 2020-12-17 15:18:27 +01:00
parent 91a672c5ea
commit 2a86c89119
5 changed files with 23 additions and 14 deletions

View File

@ -55,6 +55,8 @@ use core::{
sync::atomic::{compiler_fence, Ordering},
time::Duration,
};
#[cfg(feature = "std")]
use std::{
io::{Read, Write},
net::{TcpListener, TcpStream},
@ -64,6 +66,7 @@ use std::{
use crate::utils::next_pow2;
use crate::AflError;
#[cfg(feature = "std")]
use super::shmem_translated::AflShmem;
/// We'll start off with 256 megabyte maps per fuzzer client

View File

@ -1,31 +1,29 @@
// TODO: llmp can be no_std, if we abstract away page creation
#[cfg(feature = "std")]
pub mod llmp;
#[cfg(feature = "std")]
pub mod shmem_translated;
use alloc::string::String;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::time::Duration;
use core::{marker::PhantomData, time};
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
//#[cfg(feature = "std")]
//pub mod shmem_translated;
#[cfg(feature = "std")]
use std::time::Duration;
use self::llmp::Tag;
use crate::corpus::Corpus;
use crate::executors::Executor;
use crate::feedbacks::FeedbacksTuple;
use crate::inputs::Input;
use crate::observers::ObserversTuple;
#[cfg(feature = "std")]
use crate::serde_anymap::Ptr;
use crate::utils::Rand;
use crate::AflError;
use crate::{engines::State, utils};
use self::llmp::Tag;
#[derive(Debug, Copy, Clone)]
/// Indicate if an event worked or not
pub enum BrokerEventResult {
@ -377,6 +375,8 @@ where
message,
phantom: _,
} => {
let (_, _) = (message, severity_level);
#[cfg(feature = "std")]
println!("[LOG {}]: {}", severity_level, message);
Ok(BrokerEventResult::Handled)
} //_ => Ok(BrokerEventResult::Forward),
@ -725,6 +725,7 @@ where
phantom: PhantomData<(C, E, OT, FT, I, R)>,
}
#[cfg(feature = "std")]
impl<C, E, OT, FT, I, R, ST> LlmpEventManager<C, E, OT, FT, I, R, ST>
where
C: Corpus<I, R>,

View File

@ -1,3 +1,4 @@
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::marker::PhantomData;
use num::Integer;
@ -254,7 +255,7 @@ where
pub fn with_history_map(name: &'static str, history_map: Vec<T>) -> Self {
Self {
history_map: history_map,
name: name.into(),
name: name.to_string(),
phantom: PhantomData,
}
}

View File

@ -1,5 +1,7 @@
extern crate num;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use serde::{Deserialize, Serialize};
use crate::serde_anymap::ArrayMut;
@ -186,7 +188,7 @@ where
let initial = if map.len() > 0 { map[0] } else { T::default() };
Self {
map: ArrayMut::Cptr((map.as_mut_ptr(), map.len())),
name: name.into(),
name: name.to_string(),
initial,
}
}
@ -197,7 +199,7 @@ where
let initial = if len > 0 { *map_ptr } else { T::default() };
StdMapObserver {
map: ArrayMut::Cptr((map_ptr, len)),
name: name.into(),
name: name.to_string(),
initial,
}
}

View File

@ -84,8 +84,10 @@ pub fn current_time() -> time::Duration {
/// Current time (fixed fallback for no_std)
#[cfg(not(feature = "std"))]
#[inline]
fn current_time() -> time::Duration {
self.start_time()
pub fn current_time() -> time::Duration {
// We may not have a rt clock available.
// TODO: Make it somehow plugin-able
time::Duration::from_millis(1)
}
#[cfg(feature = "std")]