Skip to content

Commit

Permalink
fix program test stubs (solana-labs#11956)
Browse files Browse the repository at this point in the history
* fix program tset stubs

* nudge
  • Loading branch information
jackcmay authored Sep 1, 2020
1 parent 2de7768 commit 0ed360b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
1 change: 1 addition & 0 deletions ci/nits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
20 changes: 3 additions & 17 deletions sdk/src/program_stubs.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down

0 comments on commit 0ed360b

Please sign in to comment.