Skip to content

Commit cbd9055

Browse files
committed
std::alloc: checking if the alignment is, at least, a word size.
so we do not error (at least on solarish systems) in that case. close rust-langGH-124787
1 parent c3202af commit cbd9055

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

library/std/src/sys/pal/unix/alloc.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ cfg_if::cfg_if! {
8787
// [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=138579
8888
// [4]: https://chromium.googlesource.com/chromium/src/base/+/master/
8989
// /memory/aligned_memory.cc
90-
libc::memalign(layout.align(), layout.size()) as *mut u8
90+
//
91+
// We purpose use the higher alignment so we have it at least
92+
// a proper word size value guaranteed.
93+
let align = layout.align().max(create::mem::size_of::<usize>());
94+
libc::memalign(align, layout.size()) as *mut u8
9195
}
9296
} else if #[cfg(target_os = "wasi")] {
9397
#[inline]

src/doc/embedded-book

0 commit comments

Comments
 (0)