fn main() {
unsafe {
do str::as_c_str(~"The answer is %d.\n") |c| {
let a = 42;
asm!("mov $0, %rdi\n\t\
mov $1, %rsi\n\t\
xorl %eax, %eax\n\t\
call _printf"
:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn libc_rsqrt(f: &f32) -> f32 { | |
| 1.0/f32::sqrt(*f) | |
| } | |
| fn llvm_rsqrt(f: &f32) -> f32 { | |
| 1.0/core::unstable::intrinsics::sqrtf32(*f) | |
| } | |
| fn asm_rsqrt(f: &f32) -> f32 { | |
| let mut b = &0.0f32; | |
| unsafe { | |
| asm!("rsqrtss ($0), %xmm0\n\t\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Point { | |
| x: int, | |
| y: int | |
| } | |
| trait Positioned { | |
| fn x(&self)-> int; | |
| fn y(&self)-> int; | |
| fn setX(&mut self, int); | |
| fn setY(&mut self, int); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Parent; | |
| impl Parent { | |
| fn new_child<'a>(&'a self) -> Child<'a> { | |
| Child { | |
| parent: self | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; ModuleID = 'rust.rc' | |
| target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" | |
| target triple = "x86_64-unknown-linux-gnu" | |
| %tydesc = type { i64, i64, void ({}*, i8*)*, void ({}*, i8*)*, void ({}*, i8*)*, void ({}*, i8*)* } | |
| %enum.ValidUsage = type { i64, i64, [0 x i8] } | |
| %enum.Action = type { i64, void (%enum.ValidUsage*, { i64, %tydesc*, i8*, i8*, i8 }*, { { i64, i64, [0 x i8] }**, i64 }*)*, [16 x i8] } | |
| %str_slice = type { i8*, i64 } | |
| %enum.UsageSource = type { i64, %str_slice, [0 x i8] } | |
| %"enum.std::libc::types::common::c95::c_void[#1]" = type {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn find_fn(ccx: @mut CrateContext, fn_id: ast::node_id) -> Option<codemap::span> { | |
| match ccx.tcx.def_map.find(&fn_id) { | |
| Some(&ast::def_fn(def_id, _)) => { | |
| if ast_util::is_local(def_id) { | |
| match ccx.tcx.items.find(&def_id.node) { | |
| Some(&ast_map::node_item(item, _)) => { | |
| match item.node { | |
| ast::item_fn(*) => Some(item.span), | |
| _ => None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let b = test_nd_dr(8, 3); | |
| assert_eq!(b, 2); | |
| } | |
| fn test_nd_dr(n: i8, d: i8) -> i8 { | |
| let separate_div_rem = (n / d, n % d); | |
| let combined_div_rem = n.div_rem(&d); | |
| let (_, b) = separate_div_rem; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::cell::Cell; | |
| use std::rt::io::net::tcp::TcpListener; | |
| use std::rt::io::net::ip::Ipv4; | |
| use std::rt::io::{Listener, Writer}; | |
| fn main() { | |
| let mut listener = TcpListener::bind(Ipv4(0, 0, 0, 0, 6767)) | |
| .expect("Unable to bind to 0.0.0.0:6767"); | |
| loop { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(macro_rules)] | |
| extern crate collections; | |
| use collections::HashMap; | |
| // A macro to easily create and populate hash maps | |
| macro_rules! hashmap( | |
| { $($key:expr => $value:expr),+ } => { | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -> % gdb --args x86_64-unknown-linux-gnu/stage2/bin/rustc --cfg stage2 -O --cfg debug -Z no-debug-borrows --target=arm-linux-androideabi --android-cross-path=/scratch/laden/android-dev/standalone -D warnings --out-dir x86_64-unknown-linux-gnu/stage2/lib/rustc/arm-linux-androideabi/lib /scratch/laden/rust/src/libstd/std.rs GNU gdb (GDB) 7.4.1-debian | |
| Copyright (C) 2012 Free Software Foundation, Inc. | |
| License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> | |
| This is free software: you are free to change and redistribute it. | |
| There is NO WARRANTY, to the extent permitted by law. Type "show copying" | |
| and "show warranty" for details. | |
| This GDB was configured as "x86_64-linux-gnu". | |
| For bug reporting instructions, please see: | |
| <http://www.gnu.org/software/gdb/bugs/>... | |
| Reading symbols from /export/scratch/laden/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc...(no debugging symbols found)...done. |
OlderNewer