Skip to content

Commit

Permalink
docs: GlobalAlloc: Make example only require 4096-aligned static
Browse files Browse the repository at this point in the history
Alignments > 4k are not supported,
  rust-lang#70022
  rust-lang#70144

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
  • Loading branch information
ijackson committed Jul 21, 2021
1 parent 07e11e8 commit 03d7001
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/core/src/alloc/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use crate::ptr;
/// };
///
/// const ARENA_SIZE: usize = 128 * 1024;
/// #[repr(C, align(131072))] // 131072 == ARENA_SIZE.
/// const MAX_SUPPORTED_ALIGN: usize = 4096;
/// #[repr(C, align(4096))] // 4096 == MAX_SUPPORTED_ALIGN
/// struct SimpleAllocator {
/// arena: UnsafeCell<[u8; ARENA_SIZE]>,
/// remaining: AtomicUsize, // we allocate from the top, counting down
Expand All @@ -53,8 +54,7 @@ use crate::ptr;
/// // So we can safely use a mask to ensure alignment without worrying about UB.
/// let align_mask_to_round_down = !(align - 1);
///
/// if align > ARENA_SIZE {
/// // align may be > size !
/// if align > MAX_SUPPORTED_ALIGN {
/// return null_mut();
/// }
///
Expand Down

0 comments on commit 03d7001

Please sign in to comment.