Skip to content

Commit

Permalink
std::alloc: checking if the alignment is, at least, a word size.
Browse files Browse the repository at this point in the history
so we do not error (at least on solarish systems) in that case.
close rust-langGH-124787
  • Loading branch information
devnexen committed May 8, 2024
1 parent c3202af commit cbd9055
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion library/std/src/sys/pal/unix/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ cfg_if::cfg_if! {
// [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=138579
// [4]: https://chromium.googlesource.com/chromium/src/base/+/master/
// /memory/aligned_memory.cc
libc::memalign(layout.align(), layout.size()) as *mut u8
//
// We purpose use the higher alignment so we have it at least
// a proper word size value guaranteed.
let align = layout.align().max(create::mem::size_of::<usize>());
libc::memalign(align, layout.size()) as *mut u8
}
} else if #[cfg(target_os = "wasi")] {
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/doc/embedded-book
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/doc/rust-by-example

0 comments on commit cbd9055

Please sign in to comment.