about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/alloc.rs16
-rw-r--r--src/liballoc/lib.rs1
2 files changed, 17 insertions, 0 deletions
diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs
index a6fc8d5004c..beae52726a6 100644
--- a/src/liballoc/alloc.rs
+++ b/src/liballoc/alloc.rs
@@ -26,6 +26,9 @@ extern "Rust" {
     #[allocator]
     #[rustc_allocator_nounwind]
     fn __rust_alloc(size: usize, align: usize, err: *mut u8) -> *mut u8;
+    #[cold]
+    #[rustc_allocator_nounwind]
+    fn __rust_oom(err: *const u8) -> !;
     #[rustc_allocator_nounwind]
     fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
     #[rustc_allocator_nounwind]
@@ -44,6 +47,9 @@ extern "Rust" {
     #[allocator]
     #[rustc_allocator_nounwind]
     fn __rust_alloc(size: usize, align: usize) -> *mut u8;
+    #[cold]
+    #[rustc_allocator_nounwind]
+    fn __rust_oom() -> !;
     #[rustc_allocator_nounwind]
     fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
     #[rustc_allocator_nounwind]
@@ -120,6 +126,16 @@ unsafe impl Alloc for Global {
             Err(AllocErr)
         }
     }
+
+    #[inline]
+    fn oom(&mut self) -> ! {
+        unsafe {
+            #[cfg(not(stage0))]
+            __rust_oom();
+            #[cfg(stage0)]
+            __rust_oom(&mut 0);
+        }
+    }
 }
 
 /// The allocator for unique pointers.
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index f6598fe5e89..a10820ebefd 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -97,6 +97,7 @@
 #![feature(from_ref)]
 #![feature(fundamental)]
 #![feature(lang_items)]
+#![feature(libc)]
 #![feature(needs_allocator)]
 #![feature(nonzero)]
 #![feature(optin_builtin_traits)]