Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cli/src/init/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ build-std = ["core", "alloc"]

[target.bpfel-unknown-none]
rustflags = [
"--cfg", "target_os=\"solana\"",
"--cfg", "feature=\"mem_unaligned\"",
"-C", "linker=sbpf-linker",
"-C", "panic=abort",
Expand Down
8 changes: 4 additions & 4 deletions derive/src/account/accessors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ pub(super) fn generate_accessors(
let __len = #read;
let __start = __offset + #pb;
let __bytes = &__data[__start..__start + __len];
#[cfg(target_os = "solana")]
#[cfg(any(target_os = "solana", target_arch = "bpf"))]
{ unsafe { core::str::from_utf8_unchecked(__bytes) } }
#[cfg(not(target_os = "solana"))]
#[cfg(not(any(target_os = "solana", target_arch = "bpf")))]
{ core::str::from_utf8(__bytes).expect("account string field contains invalid UTF-8") }
}
}
Expand Down Expand Up @@ -93,9 +93,9 @@ pub(super) fn generate_accessors(
let __data = unsafe { self.__view.borrow_unchecked() };
let __offset = #off_expr;
let __bytes = &__data[__offset..];
#[cfg(target_os = "solana")]
#[cfg(any(target_os = "solana", target_arch = "bpf"))]
{ unsafe { core::str::from_utf8_unchecked(__bytes) } }
#[cfg(not(target_os = "solana"))]
#[cfg(not(any(target_os = "solana", target_arch = "bpf")))]
{ core::str::from_utf8(__bytes).expect("account tail field contains invalid UTF-8") }
}
}
Expand Down
2 changes: 1 addition & 1 deletion derive/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub(crate) fn program(_attr: TokenStream, item: TokenStream) -> TokenStream {

items.push(syn::parse_quote! {
#[unsafe(no_mangle)]
#[cfg(target_os = "solana")]
#[cfg(any(target_os = "solana", target_arch = "bpf"))]
#[allow(unexpected_cfgs)]
pub unsafe extern "C" fn entrypoint(ptr: *mut u8, instruction_data: *const u8) -> u64 {
// SAFETY: Initialize bump allocator cursor. The SVM maps and zero-inits the heap
Expand Down
4 changes: 2 additions & 2 deletions lang/src/sysvars/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ macro_rules! impl_sysvar_get {
let mut var = core::mem::MaybeUninit::<Self>::uninit();
let var_addr = var.as_mut_ptr() as *mut _ as *mut u8;

#[cfg(target_os = "solana")]
#[cfg(any(target_os = "solana", target_arch = "bpf"))]
// SAFETY: `var_addr` points to `MaybeUninit<Self>` which has
// enough space. The syscall writes `length` bytes; we zero the
// trailing `$padding` bytes so the full struct is initialized.
Expand All @@ -61,7 +61,7 @@ macro_rules! impl_sysvar_get {
)
};

#[cfg(not(target_os = "solana"))]
#[cfg(not(any(target_os = "solana", target_arch = "bpf")))]
let result = {
// SAFETY: Zero-init the full struct for off-chain use.
unsafe { var_addr.write_bytes(0, core::mem::size_of::<Self>()) };
Expand Down
Loading