diff options
| author | Björn Steinbrink <bsteinbr@gmail.com> | 2015-03-13 03:19:30 +0100 |
|---|---|---|
| committer | Björn Steinbrink <bsteinbr@gmail.com> | 2015-03-13 03:19:30 +0100 |
| commit | 0942803f502d164883294e29238e3ac4822867ed (patch) | |
| tree | db8ccf90663de0ca953c24f896abe519148f7754 /src/liballoc | |
| parent | 49f7550a25722fbdb779eef80afa85f6d802f7e8 (diff) | |
Add an "allocator" attribute to mark functions as allocators
When this attribute is applied to a function, its return value gets the noalias attribute, which is how you tell LLVM that the function returns a "new" pointer that doesn't alias anything accessible to the caller, i.e. it acts like a memory allocator. Plain malloc doesn't need this attribute because LLVM already knows about malloc and adds the attribute itself.
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/heap.rs | 1 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 3b93171386a..f9936b7a16a 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -198,6 +198,7 @@ mod imp { extern {} extern { + #[allocator] fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void; fn je_rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void; fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t; diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 5c9a42a8a71..34c0686fe37 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -69,6 +69,7 @@ #![feature(no_std)] #![no_std] +#![feature(allocator)] #![feature(lang_items, unsafe_destructor)] #![feature(box_syntax)] #![feature(optin_builtin_traits)] |
