File tree Expand file tree Collapse file tree 3 files changed +21
-18
lines changed Expand file tree Collapse file tree 3 files changed +21
-18
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,8 @@ use std::{
77
88use crate :: Allocator ;
99
10- // Only 64-bit little-endian platforms are supported at present
11- const IS_SUPPORTED_PLATFORM : bool =
12- cfg ! ( all( target_pointer_width = "64" , target_endian = "little" ) ) ;
13-
1410const TWO_GIB : usize = 1 << 31 ;
15- // `1 << 32`.
16- // We use `IS_SUPPORTED_PLATFORM as usize * 32` to avoid compilation failure on 32-bit platforms.
17- const FOUR_GIB : usize = 1 << ( IS_SUPPORTED_PLATFORM as usize * 32 ) ;
11+ const FOUR_GIB : usize = 1 << 32 ;
1812
1913// What we ideally want is an allocation 2 GiB in size, aligned on 4 GiB.
2014// But system allocator on Mac OS refuses allocations with 4 GiB alignment.
@@ -61,15 +55,7 @@ pub struct FixedSizeAllocator {
6155
6256impl FixedSizeAllocator {
6357 /// Create a new [`FixedSizeAllocator`].
64- ///
65- /// # Panics
66- /// Panics if not a 64-bit little-endian platform.
6758 pub fn new ( ) -> Self {
68- assert ! (
69- IS_SUPPORTED_PLATFORM ,
70- "Fixed size allocators are only supported on 64-bit little-endian platforms"
71- ) ;
72-
7359 // Allocate block of memory.
7460 // SAFETY: Layout does not have zero size.
7561 let alloc_ptr = unsafe { System . alloc ( ALLOC_LAYOUT ) } ;
Original file line number Diff line number Diff line change 2121//!
2222//! * `fixed_size` - Makes [`AllocatorPool`] create large fixed-size allocators, instead of
2323//! flexibly-sized ones.
24+ //! Only supported on 64-bit little-endian platforms at present.
2425//! Usage of this feature is not advisable, and it will be removed as soon as we're able to.
2526//!
2627//! * `disable_fixed_size` - Disables `fixed_size` feature.
@@ -36,7 +37,13 @@ mod allocator_api2;
3637mod boxed;
3738mod clone_in;
3839mod convert;
39- #[ cfg( all( feature = "fixed_size" , not( feature = "disable_fixed_size" ) ) ) ]
40+ // Fixed size allocators are only supported on 64-bit little-endian platforms at present
41+ #[ cfg( all(
42+ feature = "fixed_size" ,
43+ not( feature = "disable_fixed_size" ) ,
44+ target_pointer_width = "64" ,
45+ target_endian = "little"
46+ ) ) ]
4047mod fixed_size;
4148#[ cfg( feature = "from_raw_parts" ) ]
4249mod from_raw_parts;
Original file line number Diff line number Diff line change @@ -73,7 +73,12 @@ impl Drop for AllocatorGuard<'_> {
7373 }
7474}
7575
76- #[ cfg( any( not( feature = "fixed_size" ) , feature = "disable_fixed_size" ) ) ]
76+ #[ cfg( not( all(
77+ feature = "fixed_size" ,
78+ not( feature = "disable_fixed_size" ) ,
79+ target_pointer_width = "64" ,
80+ target_endian = "little"
81+ ) ) ) ]
7782mod wrapper {
7883 use crate :: Allocator ;
7984
@@ -105,7 +110,12 @@ mod wrapper {
105110 }
106111}
107112
108- #[ cfg( all( feature = "fixed_size" , not( feature = "disable_fixed_size" ) ) ) ]
113+ #[ cfg( all(
114+ feature = "fixed_size" ,
115+ not( feature = "disable_fixed_size" ) ,
116+ target_pointer_width = "64" ,
117+ target_endian = "little"
118+ ) ) ]
109119mod wrapper {
110120 use crate :: {
111121 Allocator ,
You can’t perform that action at this time.
0 commit comments