Skip to content

Commit 03d7001

Browse files
committed
docs: GlobalAlloc: Make example only require 4096-aligned static
Alignments > 4k are not supported, #70022 #70144 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
1 parent 07e11e8 commit 03d7001

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/core/src/alloc/global.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ use crate::ptr;
3030
/// };
3131
///
3232
/// const ARENA_SIZE: usize = 128 * 1024;
33-
/// #[repr(C, align(131072))] // 131072 == ARENA_SIZE.
33+
/// const MAX_SUPPORTED_ALIGN: usize = 4096;
34+
/// #[repr(C, align(4096))] // 4096 == MAX_SUPPORTED_ALIGN
3435
/// struct SimpleAllocator {
3536
/// arena: UnsafeCell<[u8; ARENA_SIZE]>,
3637
/// remaining: AtomicUsize, // we allocate from the top, counting down
@@ -53,8 +54,7 @@ use crate::ptr;
5354
/// // So we can safely use a mask to ensure alignment without worrying about UB.
5455
/// let align_mask_to_round_down = !(align - 1);
5556
///
56-
/// if align > ARENA_SIZE {
57-
/// // align may be > size !
57+
/// if align > MAX_SUPPORTED_ALIGN {
5858
/// return null_mut();
5959
/// }
6060
///

0 commit comments

Comments
 (0)