Skip to content

Instantly share code, notes, and snippets.

fn main(args: [str]) {
if vec::len(args) != 2u {
let usage = #fmt("Usage: %s <elem_count>\n", args[0]);
io::stderr().write_str(usage);
os::set_exit_status(-1);
ret;
}
let count = option::get(int::from_str(args[1]));
let rng = rand::seeded_rng(rand::seed());
impl of item for itemtag {
fn item() -> itemdoc {
alt self {
doc::modtag(doc) { doc.item }
doc::nmodtag(doc) { doc.item }
doc::fntag(doc) { doc.item }
doc::consttag(doc) { doc.item }
doc::enumtag(doc) { doc.item }
doc::restag(doc) { doc.item }
doc::ifacetag(doc) { doc.item }
% dtrace -Se -n 'syscall::mmap:entry /arg3 & 0x1000 == 0/ {}'
DIFO 0x0x7fcd92611400 returns D type (integer) (size 8)
OFF OPCODE INSTRUCTION
00: 29010901 ldgs DT_VAR(265), %r1 ! DT_VAR(265) = "arg3"
01: 25000002 setx DT_INTEGER[0], %r2 ! 0x0
02: 03010201 and %r1, %r2, %r1
03: 23000001 ret %r1
NAME ID KND SCP FLAG TYPE
d := make([][]int, len(s)+1)
for i, _ := range d {
d[i] = make([]int, len(t)+1)
}
llvm[2]: Compiling APFloat.cpp for Release+Asserts build
/private/tmp/homebrew-rust-0.3.1-5J9j/rust-0.3.1/src/llvm/lib/Support/APFloat.cpp:1: error: bad value (native) for -march= switch
/private/tmp/homebrew-rust-0.3.1-5J9j/rust-0.3.1/src/llvm/lib/Support/APFloat.cpp:1: error: bad value (native) for -mtune= switch
rm: /private/tmp/homebrew-rust-0.3.1-5J9j/rust-0.3.1/llvm/x86_64-apple-darwin/lib/Support/Release+Asserts/APFloat.d.tmp: No such file or directory
make[2]: *** [/private/tmp/homebrew-rust-0.3.1-5J9j/rust-0.3.1/llvm/x86_64-apple-darwin/lib/Support/Release+Asserts/APFloat.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all] Error 1
$ rustc main.rs
main.rs:22:7: 22:16 warning: unused variable: `prev_fib`
main.rs:22 let (prev_fib, curr_fib) = (curr_fib, curr_fib+prev_fib);
^~~~~~~~~
main.rs:22:17: 22:26 warning: unused variable: `curr_fib`
main.rs:22 let (prev_fib, curr_fib) = (curr_fib, curr_fib+prev_fib);
^~~~~~~~~
$ ./configure --llvm-root=/usr/local
...
configure:
configure: using custom LLVM at /usr/local
configure:
configure: found ok version of LLVM: 3.1
<areece> I've asked a couple of times but wanted to ask a different group: does rust use a custom llvm or can it be linked against the latest llvm release?
<pcwalton> areece: it's custom
<areece> (alternatively, how do I ask the mailing list)
...
<pcwalton> depends on some GC changes that we haven't upstreamed
<areece> pcwalton: so how will it fail if I don't use the custom llvm?
<areece> will it just subtly fail eventually?
<areece> because it builds successfully
<bstrie> it might not fail at all if gc isn't enabled
<pcwalton> if you don't use the GC I think it might well work
# dtrace -n 'tick-10msec /pid == $pid/ { @stacks[ustack()] = count(); }' -c "bin/debug/run_subdivide models/stegosaurus.obj"
dtrace: description 'tick-10msec ' matched 1 probe
dtrace: error on enabled probe ID 1 (ID 212808: profile:::tick-10msec): invalid address (0x7fff51a82650) in action #2
dtrace: error on enabled probe ID 1 (ID 212808: profile:::tick-10msec): invalid address (0x10e30b680) in action #2
dtrace: error on enabled probe ID 1 (ID 212808: profile:::tick-10msec): invalid address (0x7fff51a82650) in action #2
dtrace: error on enabled probe ID 1 (ID 212808: profile:::tick-10msec): invalid address (0x10e30b680) in action #2
dtrace: error on enabled probe ID 1 (ID 212808: profile:::tick-10msec): invalid address (0x7fff51a82650) in action #2
...
@awreece
awreece / timeTrack.go
Created October 16, 2012 04:11
Use the runtime.Caller() function!
func timeTrack(start time.Time) {
elapsed := time.Since(start)
fname := ""
pc, _, _, ok := runtime.Caller(1);
if ok {
fname = runtime.FuncForPC(pc).Name()
}
fmt.Printf("Function %s took %v\n", fname, elapsed);
}