diff options
author | Andrea Fioraldi <andreafioraldi@gmail.com> | 2022-01-26 21:44:07 +0100 |
---|---|---|
committer | Andrea Fioraldi <andreafioraldi@gmail.com> | 2022-01-26 21:44:07 +0100 |
commit | 08c39c15522fc1765ab6fcff03a02bb5f9d4f230 (patch) | |
tree | b109bff0e52224fe2b3594204973d3a42b88c0f2 /custom_mutators/rust | |
parent | f75535807a19cb7b3696fc0a701b97e994184502 (diff) | |
download | afl++-08c39c15522fc1765ab6fcff03a02bb5f9d4f230.tar.gz |
fix cfg in macro_rules in rust custom mutator
Diffstat (limited to 'custom_mutators/rust')
-rw-r--r-- | custom_mutators/rust/custom_mutator/src/lib.rs | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/custom_mutators/rust/custom_mutator/src/lib.rs b/custom_mutators/rust/custom_mutator/src/lib.rs index 013d3769..83ecbd9a 100644 --- a/custom_mutators/rust/custom_mutator/src/lib.rs +++ b/custom_mutators/rust/custom_mutator/src/lib.rs @@ -358,6 +358,36 @@ pub mod wrappers { } } +/// An exported macro to defined afl_custom_init meant for insternal usage +#[cfg(feature = "afl_internals")] +#[macro_export] +macro_rules! _define_afl_custom_init { + ($mutator_type:ty) => { + #[no_mangle] + pub extern "C" fn afl_custom_init( + afl: ::std::option::Option<&'static $crate::afl_state>, + seed: ::std::os::raw::c_uint, + ) -> *const ::std::os::raw::c_void { + $crate::wrappers::afl_custom_init_::<$mutator_type>(afl, seed as u32) + } + } +} + +/// An exported macro to defined afl_custom_init meant for insternal usage +#[cfg(not(feature = "afl_internals"))] +#[macro_export] +macro_rules! _define_afl_custom_init { + ($mutator_type:ty) => { + #[no_mangle] + pub extern "C" fn afl_custom_init( + _afl: *const ::std::os::raw::c_void, + seed: ::std::os::raw::c_uint, + ) -> *const ::std::os::raw::c_void { + $crate::wrappers::afl_custom_init_::<$mutator_type>(seed as u32) + } + } +} + /// exports the given Mutator as a custom mutator as the C interface that AFL++ expects. /// It is not possible to call this macro multiple times, because it would define the custom mutator symbols multiple times. /// # Example @@ -381,23 +411,7 @@ pub mod wrappers { #[macro_export] macro_rules! export_mutator { ($mutator_type:ty) => { - #[cfg(feature = "afl_internals")] - #[no_mangle] - pub extern "C" fn afl_custom_init( - afl: ::std::option::Option<&'static $crate::afl_state>, - seed: ::std::os::raw::c_uint, - ) -> *const ::std::os::raw::c_void { - $crate::wrappers::afl_custom_init_::<$mutator_type>(afl, seed as u32) - } - - #[cfg(not(feature = "afl_internals"))] - #[no_mangle] - pub extern "C" fn afl_custom_init( - _afl: *const ::std::os::raw::c_void, - seed: ::std::os::raw::c_uint, - ) -> *const ::std::os::raw::c_void { - $crate::wrappers::afl_custom_init_::<$mutator_type>(seed as u32) - } + $crate::_define_afl_custom_init!($mutator_type); #[no_mangle] pub unsafe extern "C" fn afl_custom_fuzz_count( |