Add SyscallStubs to enable syscall interception when building programs for non-BPF

This commit is contained in:
Michael Vines
2020-10-16 22:04:53 -07:00
committed by mergify[bot]
parent 75d62ca095
commit 9c53e1dfb2
9 changed files with 109 additions and 50 deletions

View File

@@ -204,12 +204,17 @@ impl Pubkey {
}
/// Log a `Pubkey` from a program
#[cfg(feature = "program")]
pub fn log(&self) {
extern "C" {
fn sol_log_pubkey(pubkey_addr: *const u8);
};
unsafe { sol_log_pubkey(self.as_ref() as *const _ as *const u8) };
#[cfg(all(feature = "program", target_arch = "bpf"))]
{
extern "C" {
fn sol_log_pubkey(pubkey_addr: *const u8);
};
unsafe { sol_log_pubkey(self.as_ref() as *const _ as *const u8) };
}
#[cfg(all(feature = "program", not(target_arch = "bpf")))]
crate::program_stubs::sol_log(&self.to_string());
}
}