about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-04-04 18:57:48 +0200
committerSimon Sapin <simon.sapin@exyr.org>2018-04-12 22:53:21 +0200
commiteae0d468932660ca383e35bb9d8b0cb4943a82ae (patch)
tree818c14771c58c3fe97bd5d6c18bb94e30fe2064e /src/liballoc
parent96c9d225a9667bc5ffcbc1594d44c29b201e999c (diff)
downloadrust-eae0d468932660ca383e35bb9d8b0cb4943a82ae.tar.gz
rust-eae0d468932660ca383e35bb9d8b0cb4943a82ae.zip
Restore Global.oom() functionality
… now that #[global_allocator] does not define a symbol for it
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)]