Skip to content

Commit b164398

Browse files
committed
---
yaml --- r: 81662 b: refs/heads/master c: cb7756a h: refs/heads/master v: v3
1 parent a59e8d9 commit b164398

File tree

18 files changed

+1090
-147
lines changed

18 files changed

+1090
-147
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9621156fc3814edaef6acafc06827e5aa87c9bdd
2+
refs/heads/master: cb7756a81d3cbc48e79ffaa1a1f9d4934b581166
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/src/librustc/middle/trans/base.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,11 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
24422442
unsafe {
24432443
llvm::LLVMPositionBuilderAtEnd(bld, llbb);
24442444

2445+
let crate_map = ccx.crate_map;
2446+
let opaque_crate_map = do "crate_map".with_c_str |buf| {
2447+
llvm::LLVMBuildPointerCast(bld, crate_map, Type::i8p().to_ref(), buf)
2448+
};
2449+
24452450
let (start_fn, args) = if use_start_lang_item {
24462451
let start_def_id = match ccx.tcx.lang_items.require(StartFnLangItem) {
24472452
Ok(id) => id,
@@ -2464,7 +2469,8 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
24642469
C_null(Type::opaque_box(ccx).ptr_to()),
24652470
opaque_rust_main,
24662471
llvm::LLVMGetParam(llfn, 0),
2467-
llvm::LLVMGetParam(llfn, 1)
2472+
llvm::LLVMGetParam(llfn, 1),
2473+
opaque_crate_map
24682474
]
24692475
};
24702476
(start_fn, args)
@@ -2473,7 +2479,8 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
24732479
let args = ~[
24742480
C_null(Type::opaque_box(ccx).ptr_to()),
24752481
llvm::LLVMGetParam(llfn, 0 as c_uint),
2476-
llvm::LLVMGetParam(llfn, 1 as c_uint)
2482+
llvm::LLVMGetParam(llfn, 1 as c_uint),
2483+
opaque_crate_map
24772484
];
24782485

24792486
(rust_main, args)
@@ -2652,8 +2659,6 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
26522659
let path = vec::append((*pth).clone(), [path_name(ni.ident)]);
26532660
foreign::register_foreign_item_fn(ccx, abis, &path, ni)
26542661
}
2655-
ast::foreign_item_static(*) if attr::contains_name(ni.attrs, "crate_map")
2656-
=> ccx.crate_map,
26572662
ast::foreign_item_static(*) => {
26582663
let ident = foreign::link_name(ccx, ni);
26592664
let g = do ident.with_c_str |buf| {

trunk/src/librustc/middle/typeck/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
402402
bound_lifetime_names: opt_vec::Empty,
403403
inputs: ~[
404404
ty::mk_int(),
405-
ty::mk_imm_ptr(tcx, ty::mk_imm_ptr(tcx, ty::mk_u8()))
405+
ty::mk_imm_ptr(tcx, ty::mk_imm_ptr(tcx, ty::mk_u8())),
406+
ty::mk_imm_ptr(tcx, ty::mk_u8())
406407
],
407408
output: ty::mk_int()
408409
}

trunk/src/libstd/rt/crate_map.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ use vec;
1616
use hashmap::HashSet;
1717
use container::MutableSet;
1818

19-
extern {
20-
#[cfg(not(stage0))]
21-
#[crate_map]
22-
static CRATE_MAP: CrateMap;
23-
}
24-
25-
pub struct ModEntry {
19+
pub struct ModEntry{
2620
name: *c_char,
2721
log_level: *mut u32
2822
}
@@ -40,11 +34,6 @@ struct CrateMap {
4034
children: [*CrateMap, ..1]
4135
}
4236

43-
#[cfg(not(stage0))]
44-
pub fn get_crate_map() -> *CrateMap {
45-
&'static CRATE_MAP as *CrateMap
46-
}
47-
4837
unsafe fn version(crate_map: *CrateMap) -> i32 {
4938
match (*crate_map).version {
5039
1 => return 1,

trunk/src/libstd/rt/io/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ pub use self::net::ip::IpAddr;
260260
pub use self::net::tcp::TcpListener;
261261
pub use self::net::tcp::TcpStream;
262262
pub use self::net::udp::UdpStream;
263+
pub use self::pipe::PipeStream;
264+
pub use self::pipe::UnboundPipeStream;
265+
pub use self::process::Process;
263266

264267
// Some extension traits that all Readers and Writers get.
265268
pub use self::extensions::ReaderUtil;
@@ -269,6 +272,12 @@ pub use self::extensions::WriterByteConversions;
269272
/// Synchronous, non-blocking file I/O.
270273
pub mod file;
271274

275+
/// Synchronous, in-memory I/O.
276+
pub mod pipe;
277+
278+
/// Child process management.
279+
pub mod process;
280+
272281
/// Synchronous, non-blocking network I/O.
273282
pub mod net;
274283

trunk/src/libstd/rt/io/pipe.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Synchronous, in-memory pipes.
12+
//!
13+
//! Currently these aren't particularly useful, there only exists bindings
14+
//! enough so that pipes can be created to child processes.
15+
16+
use prelude::*;
17+
use super::{Reader, Writer};
18+
use rt::io::{io_error, read_error, EndOfFile};
19+
use rt::local::Local;
20+
use rt::rtio::{RtioPipe, RtioPipeObject, IoFactoryObject, IoFactory};
21+
use rt::rtio::RtioUnboundPipeObject;
22+
23+
pub struct PipeStream(RtioPipeObject);
24+
pub struct UnboundPipeStream(~RtioUnboundPipeObject);
25+
26+
impl PipeStream {
27+
/// Creates a new pipe initialized, but not bound to any particular
28+
/// source/destination
29+
pub fn new() -> Option<UnboundPipeStream> {
30+
let pipe = unsafe {
31+
let io: *mut IoFactoryObject = Local::unsafe_borrow();
32+
(*io).pipe_init(false)
33+
};
34+
match pipe {
35+
Ok(p) => Some(UnboundPipeStream(p)),
36+
Err(ioerr) => {
37+
io_error::cond.raise(ioerr);
38+
None
39+
}
40+
}
41+
}
42+
43+
pub fn bind(inner: RtioPipeObject) -> PipeStream {
44+
PipeStream(inner)
45+
}
46+
}
47+
48+
impl Reader for PipeStream {
49+
fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
50+
match (**self).read(buf) {
51+
Ok(read) => Some(read),
52+
Err(ioerr) => {
53+
// EOF is indicated by returning None
54+
if ioerr.kind != EndOfFile {
55+
read_error::cond.raise(ioerr);
56+
}
57+
return None;
58+
}
59+
}
60+
}
61+
62+
fn eof(&mut self) -> bool { fail!() }
63+
}
64+
65+
impl Writer for PipeStream {
66+
fn write(&mut self, buf: &[u8]) {
67+
match (**self).write(buf) {
68+
Ok(_) => (),
69+
Err(ioerr) => {
70+
io_error::cond.raise(ioerr);
71+
}
72+
}
73+
}
74+
75+
fn flush(&mut self) { fail!() }
76+
}

0 commit comments

Comments
 (0)