about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2014-02-16 20:16:23 -0800
committerBrian Anderson <banderson@mozilla.com>2014-02-23 01:47:05 -0800
commit96b299e1f08e2b6bbb8c03dfaa2881898dc6a0cb (patch)
tree836bd4e6e477f86e60765aa6be467947c667c356 /src/libstd
parent3e57808a01407be24a35f69148d20b76341b162f (diff)
downloadrust-96b299e1f08e2b6bbb8c03dfaa2881898dc6a0cb.tar.gz
rust-96b299e1f08e2b6bbb8c03dfaa2881898dc6a0cb.zip
std: Remove unstable::lang
Put the lonely lang items here closer to the code they are calling.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/rt/local_heap.rs19
-rw-r--r--src/libstd/rt/unwind.rs18
-rw-r--r--src/libstd/unstable/lang.rs52
-rw-r--r--src/libstd/unstable/mod.rs2
4 files changed, 36 insertions, 55 deletions
diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs
index 4ff25a34210..29b3dcaa4f2 100644
--- a/src/libstd/rt/local_heap.rs
+++ b/src/libstd/rt/local_heap.rs
@@ -276,6 +276,14 @@ impl Drop for MemoryRegion {
     }
 }
 
+
+#[cfg(not(test))]
+#[lang="malloc"]
+#[inline]
+pub unsafe fn local_malloc_(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 {
+    local_malloc(drop_glue, size, align)
+}
+
 #[inline]
 pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 {
     // FIXME: Unsafe borrow for speed. Lame.
@@ -288,7 +296,16 @@ pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *
     }
 }
 
-// A little compatibility function
+#[cfg(not(test))]
+#[lang="free"]
+#[inline]
+pub unsafe fn local_free_(ptr: *u8) {
+    local_free(ptr)
+}
+
+// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
+// inside a landing pad may corrupt the state of the exception handler. If a
+// problem occurs, call exit instead.
 #[inline]
 pub unsafe fn local_free(ptr: *u8) {
     // FIXME: Unsafe borrow for speed. Lame.
diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs
index 16d677b5ff2..b9459aed582 100644
--- a/src/libstd/rt/unwind.rs
+++ b/src/libstd/rt/unwind.rs
@@ -376,6 +376,24 @@ pub mod eabi {
     }
 }
 
+#[cold]
+#[lang="fail_"]
+#[cfg(not(test))]
+pub fn fail_(expr: *u8, file: *u8, line: uint) -> ! {
+    begin_unwind_raw(expr, file, line);
+}
+
+#[cold]
+#[lang="fail_bounds_check"]
+#[cfg(not(test))]
+pub fn fail_bounds_check(file: *u8, line: uint, index: uint, len: uint) -> ! {
+    use c_str::ToCStr;
+
+    let msg = format!("index out of bounds: the len is {} but the index is {}",
+                      len as uint, index as uint);
+    msg.with_c_str(|buf| fail_(buf as *u8, file, line))
+}
+
 /// This is the entry point of unwinding for things like lang items and such.
 /// The arguments are normally generated by the compiler, and need to
 /// have static lifetimes.
diff --git a/src/libstd/unstable/lang.rs b/src/libstd/unstable/lang.rs
deleted file mode 100644
index 8818cb0d270..00000000000
--- a/src/libstd/unstable/lang.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Runtime calls emitted by the compiler.
-
-use c_str::CString;
-use libc::c_char;
-use cast;
-use option::Some;
-
-#[cold]
-#[lang="fail_"]
-pub fn fail_(expr: *u8, file: *u8, line: uint) -> ! {
-    ::rt::begin_unwind_raw(expr, file, line);
-}
-
-#[cold]
-#[lang="fail_bounds_check"]
-pub fn fail_bounds_check(file: *u8, line: uint, index: uint, len: uint) -> ! {
-    let msg = format!("index out of bounds: the len is {} but the index is {}",
-                      len as uint, index as uint);
-
-    let file_str = match unsafe { CString::new(file as *c_char, false) }.as_str() {
-        // This transmute is safe because `file` is always stored in rodata.
-        Some(s) => unsafe { cast::transmute::<&str, &'static str>(s) },
-        None    => "file wasn't UTF-8 safe"
-    };
-
-    ::rt::begin_unwind(msg, file_str, line)
-}
-
-#[lang="malloc"]
-#[inline]
-pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 {
-    ::rt::local_heap::local_malloc(drop_glue, size, align)
-}
-
-// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
-// inside a landing pad may corrupt the state of the exception handler. If a
-// problem occurs, call exit instead.
-#[lang="free"]
-#[inline]
-pub unsafe fn local_free(ptr: *u8) {
-    ::rt::local_heap::local_free(ptr);
-}
diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs
index 9f37bfcddb9..1a4862fd733 100644
--- a/src/libstd/unstable/mod.rs
+++ b/src/libstd/unstable/mod.rs
@@ -17,8 +17,6 @@ pub mod dynamic_lib;
 
 pub mod finally;
 pub mod simd;
-#[cfg(not(test))]
-pub mod lang;
 pub mod sync;
 pub mod mutex;
 pub mod stack;