Skip to content

Commit fd271ad

Browse files
committed
libcore: Remove extern mod { ... } from libcore. rs=deexterning
1 parent 88f0a10 commit fd271ad

File tree

21 files changed

+836
-638
lines changed

21 files changed

+836
-638
lines changed

src/libcore/at_vec.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,18 @@ use vec;
2323
/// Code for dealing with @-vectors. This is pretty incomplete, and
2424
/// contains a bunch of duplication from the code for ~-vectors.
2525
26-
#[abi = "cdecl"]
27-
pub extern mod rustrt {
28-
pub unsafe fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
29-
++v: **vec::raw::VecRepr,
30-
++n: libc::size_t);
26+
pub mod rustrt {
27+
use libc;
28+
use sys;
29+
use vec;
30+
31+
#[abi = "cdecl"]
32+
#[link_name = "rustrt"]
33+
pub extern {
34+
pub unsafe fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
35+
++v: **vec::raw::VecRepr,
36+
++n: libc::size_t);
37+
}
3138
}
3239

3340
/// Returns the number of elements the vector can hold without reallocating

src/libcore/cast.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[abi = "rust-intrinsic"]
12-
extern mod rusti {
13-
fn forget<T>(-x: T);
14-
fn reinterpret_cast<T, U>(&&e: T) -> U;
11+
pub mod rusti {
12+
#[abi = "rust-intrinsic"]
13+
#[link_name = "rusti"]
14+
pub extern {
15+
fn forget<T>(-x: T);
16+
fn reinterpret_cast<T, U>(&&e: T) -> U;
17+
}
1518
}
1619

1720
/// Casts the value at `src` to U. The two types must have the same length.

src/libcore/cleanup.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,14 @@ pub unsafe fn annihilate() {
218218
}
219219

220220
/// Bindings to the runtime
221-
extern mod rustrt {
222-
#[rust_stack]
223-
// FIXME (#4386): Unable to make following method private.
224-
pub unsafe fn rust_get_task() -> *c_void;
221+
pub mod rustrt {
222+
use libc::c_void;
223+
224+
#[link_name = "rustrt"]
225+
pub extern {
226+
#[rust_stack]
227+
// FIXME (#4386): Unable to make following method private.
228+
pub unsafe fn rust_get_task() -> *c_void;
229+
}
225230
}
226231

src/libcore/flate.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,23 @@ use vec;
2121

2222
#[cfg(test)] use rand;
2323

24-
extern mod rustrt {
25-
unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
26-
src_buf_len: size_t,
27-
pout_len: *size_t,
28-
flags: c_int) -> *c_void;
24+
pub mod rustrt {
25+
use libc::{c_int, c_void, size_t};
2926

30-
unsafe fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
31-
src_buf_len: size_t,
32-
pout_len: *size_t,
33-
flags: c_int) -> *c_void;
27+
#[link_name = "rustrt"]
28+
pub extern {
29+
unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
30+
src_buf_len: size_t,
31+
pout_len: *size_t,
32+
flags: c_int)
33+
-> *c_void;
34+
35+
unsafe fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
36+
src_buf_len: size_t,
37+
pout_len: *size_t,
38+
flags: c_int)
39+
-> *c_void;
40+
}
3441
}
3542

3643
const lz_none : c_int = 0x0; // Huffman-coding only.

src/libcore/gc.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,30 @@ use sys;
4848
pub use stackwalk::Word;
4949

5050
// Mirrors rust_stack.h stk_seg
51-
struct StackSegment {
51+
pub struct StackSegment {
5252
prev: *StackSegment,
5353
next: *StackSegment,
5454
end: uintptr_t,
5555
// And other fields which we don't care about...
5656
}
5757

58-
extern mod rustrt {
59-
#[rust_stack]
60-
pub unsafe fn rust_call_tydesc_glue(root: *Word,
61-
tydesc: *Word,
62-
field: size_t);
58+
pub mod rustrt {
59+
use libc::size_t;
60+
use stackwalk::Word;
61+
use super::StackSegment;
6362

64-
#[rust_stack]
65-
pub unsafe fn rust_gc_metadata() -> *Word;
63+
#[link_name = "rustrt"]
64+
pub extern {
65+
#[rust_stack]
66+
pub unsafe fn rust_call_tydesc_glue(root: *Word,
67+
tydesc: *Word,
68+
field: size_t);
6669

67-
pub unsafe fn rust_get_stack_segment() -> *StackSegment;
70+
#[rust_stack]
71+
pub unsafe fn rust_gc_metadata() -> *Word;
72+
73+
pub unsafe fn rust_get_stack_segment() -> *StackSegment;
74+
}
6875
}
6976

7077
unsafe fn bump<T, U>(ptr: *T, count: uint) -> *U {

src/libcore/io.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@ use vec;
3232
#[allow(non_camel_case_types)] // not sure what to do about this
3333
pub type fd_t = c_int;
3434

35-
#[abi = "cdecl"]
36-
extern mod rustrt {
37-
unsafe fn rust_get_stdin() -> *libc::FILE;
38-
unsafe fn rust_get_stdout() -> *libc::FILE;
39-
unsafe fn rust_get_stderr() -> *libc::FILE;
35+
pub mod rustrt {
36+
use libc;
37+
38+
#[abi = "cdecl"]
39+
#[link_name = "rustrt"]
40+
pub extern {
41+
unsafe fn rust_get_stdin() -> *libc::FILE;
42+
unsafe fn rust_get_stdout() -> *libc::FILE;
43+
unsafe fn rust_get_stderr() -> *libc::FILE;
44+
}
4045
}
4146

4247
// Reading

0 commit comments

Comments
 (0)