Skip to content

Commit

Permalink
Fix compilation for armv7-unknown-linux-gnueabihf target
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Oct 6, 2023
1 parent a433e27 commit 4ccc99f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changes/armv7-unknown-linux-gnueabihf-compatibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stronghold-runtime": patch
---

Fixed compilation for armv7-unknown-linux-gnueabihf target.
10 changes: 6 additions & 4 deletions engine/runtime/src/memories/frag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ where

let default_page_size = 0x1000i64;

#[allow(clippy::useless_conversion)]
let pagesize = nix::unistd::sysconf(nix::unistd::SysconfVar::PAGE_SIZE)
.unwrap_or(Some(default_page_size))
.unwrap_or(Some(default_page_size.try_into().unwrap()))
.unwrap() as usize;

info!("Using page size {}", pagesize);
Expand Down Expand Up @@ -257,7 +258,7 @@ where
return Err(MemoryError::Allocation("Memory mapping failed".to_string()));
}

#[cfg(any(target_os = "macos"))]
#[cfg(target_os = "macos")]
{
// on linux this isn't required to commit memory
let error = libc::madvise(&mut addr as *mut usize as *mut libc::c_void, size, libc::MADV_WILLNEED);
Expand Down Expand Up @@ -374,8 +375,9 @@ where
// pick a default, if system api call is not successful
let default_page_size = 0x1000i64;

#[allow(clippy::useless_conversion)]
let _pagesize = nix::unistd::sysconf(nix::unistd::SysconfVar::PAGE_SIZE)
.unwrap_or(Some(default_page_size))
.unwrap_or(Some(default_page_size.try_into().unwrap()))
.unwrap() as usize;

// We allocate a sufficiently "large" chunk of memory. A random
Expand Down Expand Up @@ -420,7 +422,7 @@ where

#[cfg(any(target_os = "linux", target_os = "macos"))]
fn dealloc(frag: &mut Frag<T>) -> Result<(), Self::Error> {
dealloc_direct(frag.info.0 as *mut libc::c_void)
dealloc_direct(frag.info.0)
}

#[cfg(target_os = "windows")]
Expand Down

0 comments on commit 4ccc99f

Please sign in to comment.