This repository was archived by the owner on Aug 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +14
-13
lines changed Expand file tree Collapse file tree 4 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,6 @@ unreachable = "1.0.0"
3232default-features = false
3333version = " 0.2"
3434
35- [target .'cfg(any(target_os = "linux", target_os = "macos"))' .dependencies .mmap-alloc ]
36- version = " 0.2"
37- git = " https://github.com/fitzgen/allocators-rs"
38- branch = " new-alloc-api"
39-
4035[target .'cfg(target_os = "windows")' .dependencies .winapi ]
4136version = " 0.3"
4237features = [" memoryapi" , " synchapi" , " winbase" ]
Original file line number Diff line number Diff line change 1- use alloc:: allocator:: { Alloc , Layout } ;
21use const_init:: ConstInit ;
32use core:: alloc:: { AllocErr , Opaque } ;
43use core:: cell:: UnsafeCell ;
54use core:: ptr:: NonNull ;
65use libc;
7- use mmap_alloc:: MapAllocBuilder ;
86use memory_units:: { Bytes , Pages } ;
97
108pub ( crate ) fn alloc_pages ( pages : Pages ) -> Result < NonNull < Opaque > , AllocErr > {
119 unsafe {
1210 let bytes: Bytes = pages. into ( ) ;
13- let layout = Layout :: from_size_align_unchecked ( bytes. 0 , 1 ) ;
14-
15- MapAllocBuilder :: default ( )
16- . build ( )
17- . alloc ( layout)
11+ let addr = libc:: mmap (
12+ 0 as * mut _ ,
13+ bytes. 0 ,
14+ libc:: PROT_WRITE | libc:: PROT_READ ,
15+ libc:: MAP_ANON | libc:: MAP_PRIVATE ,
16+ -1 ,
17+ 0 ,
18+ ) ;
19+ if addr == libc:: MAP_FAILED {
20+ Err ( AllocErr )
21+ } else {
22+ NonNull :: new ( addr as * mut Opaque ) . ok_or ( AllocErr )
23+ }
1824 }
1925}
2026
Original file line number Diff line number Diff line change @@ -237,7 +237,6 @@ cfg_if! {
237237 use imp_wasm32 as imp;
238238 } else if #[ cfg( unix) ] {
239239 extern crate libc;
240- extern crate mmap_alloc;
241240 mod imp_unix;
242241 use imp_unix as imp;
243242 } else if #[ cfg( windows) ] {
Original file line number Diff line number Diff line change 5959
6060 #[ test]
6161 fn can_use_low_bits ( ) {
62+ use core:: mem;
6263 assert ! (
6364 mem:: align_of:: <* const u8 >( ) >= 0b100 ,
6465 "we rely on being able to stick tags into the lowest two bits"
You can’t perform that action at this time.
0 commit comments