Skip to content

Instantly share code, notes, and snippets.

View olsonjeffery's full-sized avatar
💭
:3

Jeff Olson olsonjeffery

💭
:3
View GitHub Profile
@olsonjeffery
olsonjeffery / down-the-rabbit-hole.md
Last active December 24, 2015 07:59
RFC: Well-defined boundaries between bare-metal rust and "the runtime"

Executive summary

  • Radical re-org of the std lib layout. Tease out stuff that lives in librustc that should be in the std lib (all small-r-runtime functionality to include TLS, malloc, fail!(), etc etc etc .. i don't have a great grasp on what all this includes)
  • Global re-evaluation of patterns/practices used in libstd and better understanding of rules/implications of coupling any given language/library feature to any given aspect/level of the holistic concept of "the runtime"
  • getting libuv-coupling out of libstd is the ultimate goal.. but a lot of other stuff shakes out as well, when taken to its logical conclusion
  • Add a nort {} block annotation, akin to unsafe {}, where the compiler can guarantee that some arbitrary set of "small-to-big-R runtime" functionality is not used. What this arbitrary set is: Not sure.

How things are, today

  • libuv is a submodule of mozilla/rust, built and statically linked into librt
@olsonjeffery
olsonjeffery / bleh.rs
Created September 23, 2013 18:46
hm.
trait Foo { fn bar(&self) -> bool; }
struct A;
impl Foo for A { fn bar(&self) -> bool { true } }
struct B;
impl Foo for B { fn bar(&self) -> bool { false } }
let a = A; let b = B; let v = ~[&a as &Foo, &b as &Foo];
fn rmdir(&self) {
let p = self.get_path().to_str();
match suppressed_stat(|| self.stat()) {
Some(s) => {
match s.is_dir {
true => rmdir(self.get_path()),
false => {
let ioerr = IoError {
kind: MismatchedFileTypeForOperation,
desc: fmt!("%s is not a directory", p),
@olsonjeffery
olsonjeffery / sleepyport.rs
Last active December 22, 2015 17:19
time for bed, old man!
use std::rt::comm;
use std::rt::io::timer::Timer;
use std::cell::Cell;
trait SleepyPort<T: Send> {
fn recv_timeout(self, msecs: u64) -> Option<T>;
}
impl<T: Send> SleepyPort<T> for comm::PortOne<T> {
fn recv_timeout(self, msecs: u64) -> Option<T> {
@olsonjeffery
olsonjeffery / sketch.rs
Last active December 21, 2015 17:59
my pitch for FileInfo
pub trait FileInfo<'self> {
// stat/info-related methods
fn stat(&self) -> FileStat;
fn path(&self) -> Path;
fn exists(&self) -> bool;
// note that all of these involve opening/creating filestreams and they
// consume the FileInfo in the process
fn open(self, mode: FileMode, access: FileAccess) -> FileStream'
fn create(self); // implies a certain overload of open() above
to_str().to_c_str().with_ref(...)
@olsonjeffery
olsonjeffery / git log
Created August 8, 2013 18:19
make install
jeff@mbp:~/src/rust/build$ VERBOSE=1 make install
cfg: build triple x86_64-unknown-linux-gnu
cfg: host triples x86_64-unknown-linux-gnu
cfg: target triples x86_64-unknown-linux-gnu
cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE)
cfg: enabling more debugging (CFG_ENABLE_DEBUG)
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: os for x86_64-unknown-linux-gnu is unknown-linux-gnu
cfg: disabling C++ optimization (CFG_DISABLE_OPTIMIZE_CXX)
@olsonjeffery
olsonjeffery / gdb
Created August 7, 2013 03:54
error..
running 1 test
[New Thread 0x7ffff5225700 (LWP 20307)]
[New Thread 0x7ffff460a700 (LWP 20308)]
[New Thread 0x7fffef3fd700 (LWP 20309)]
[New Thread 0x7fffee7e2700 (LWP 20310)]
STREAM FUTURE FROM CONNECT: {state: Pending()}
BEFORE RESOLVING ret_future: {state: Pending()}
AFTER RESOLVING ret_future: Err({kind: ConnectionRefused, desc: "connection refused", detail: None})
failed to async connect: {kind: ConnectionRefused, desc: "connection refused", detail: None}
AFTER COND RAISE
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffe4cc3700 (LWP 7875)]
0x00007ffff617e425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0 0x00007ffff617e425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff6181b8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff705d15c in upcall_call_shim_on_c_stack (args=0x7fffe4cc2008, fn_ptr=0x698010 <abort__c_stack_shim>) at /home/jeff/src/rust/src/rt/rust_upcall.cpp:78
#3 0x000000000055f581 in libc::funcs::c95::stdlib::abort::_3951cf1a412d1f90::_0$x2e8$x2dpre ()
#4 0x00000000005086c0 in rt::util::abort::_0cb6664c2aeff9f::_0$x2e8$x2dpre ()
#5 0x000000000078300c in rt::aio::net::tcp::__extensions__::connect::anon::expr_fn_62736 ()
pub fn connect(addr: IpAddr) -> Future<Option<TcpStreamAsync>> {
unsafe {
let (ret_future, ret_promise) = pair();
rtdebug!("borrowing io to connect");
let io = Local::unsafe_borrow::<IoFactoryObject>();
rtdebug!("about to connect");
let p_cell = Cell::new(ret_promise);
(*io).tcp_connect_async(addr,
|connect_result| {
let ret_promise = p_cell.take();