fix program test stubs (#11956)

* fix program tset stubs

* nudge
This commit is contained in:
Jack May 2020-08-31 21:48:16 -07:00 committed by GitHub
parent 2de7768f41
commit 0ed360b5e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 17 deletions

View File

@ -26,6 +26,7 @@ declare print_free_tree=(
':runtime/src/**.rs'
':sdk/bpf/rust/rust-utils/**.rs'
':sdk/**.rs'
':^sdk/src/program_stubs.rs'
':programs/**.rs'
':^**bin**.rs'
':^**bench**.rs'

View File

@ -1,38 +1,24 @@
//! @brief Syscall stubs when building for non-BPF targets
#![cfg(feature = "program")]
#[cfg(not(target_arch = "bpf"))]
fn print_line_to_stdout(_message: &str) {
#[cfg(not(feature = "program"))]
{
use std::io::{self, Write};
io::stdout()
.write_all(format!("{}\n", _message).as_bytes())
.unwrap();
io::stdout().flush().unwrap();
}
}
#[cfg(not(target_arch = "bpf"))]
#[no_mangle]
/// # Safety
pub unsafe fn sol_log_(message: *const u8, length: u64) {
let slice = std::slice::from_raw_parts(message, length as usize);
let string = std::str::from_utf8(&slice).unwrap();
print_line_to_stdout(string);
println!("{}", string);
}
#[cfg(not(target_arch = "bpf"))]
#[no_mangle]
pub fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) {
print_line_to_stdout(&format!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5));
println!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5);
}
#[cfg(not(target_arch = "bpf"))]
#[no_mangle]
pub fn sol_invoke_signed_rust() {
print_line_to_stdout("sol_invoke_signed_rust()");
println!("sol_invoke_signed_rust()");
}
#[macro_export]