Skip to content

Instantly share code, notes, and snippets.

View luqmana's full-sized avatar

Luqman Aden luqmana

View GitHub Profile
laden@corn-syrup [06:23:13] [/scratch/laden/rust/build] [issue-3678-wrappers-be-gone-2]
-> % RUST_LOG=rustc=1,rustc::middle::trans::foreign 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
foo.rs:10:6: 10:7 warning: unused variable: `x` [-W unused-variable (default)]
foo.rs:10 fn mm(x: &TestNode) {}
^
rust: ~"add_clean([block 7fcfe42937b0], **{i64, *tydesc, *i8, *i8, {*{i64, *tydesc, *i8, *i8, {i64, i64, [i8 x 0]}}, *{i64, *tydesc, *i8, *i8, {i64, i64, [i8 x 0]}}, *{i64, *tydesc, *i8, *i8, {i64, i64, [{*{i64, *tydesc, *i8, *i8, {*{i64, *tydesc, *i8, *i8, {i64, i64, [i8 x 0]}}, *{i64, *tydesc, *i8, *i8, {i64, i64, [i8 x 0]}}, *{i64, *tydesc, *i8, *i8, {i64, i64, [{*{i64, *tydesc, *i8, *i8, {*{i64, *tydesc, *i8, *i8, {i64, i64, [i8 x 0]}},
~"register_foreign_item_fn(abis=\"C\", path=[cmath, c_float_utils, ceil], foreign_item.id=153330)"
~"trans_native_call(callee_ty=extern \"C\" unsafe fn(f32) -> f32, llfn=*fn(Float) -> Float, llretptr=*Float)"
~"argument 0, llarg_rust=Float, rust_indirect=false, arg_ty=Float"
~"llarg_rust=*Float (after indirection)"
~"llarg_rust=*Float (after casting)"
~"argument 0, llarg_foreign=Float"
~"llretptr=*Float"
~"llforeign_retval=Float"
~"llrust_ret_ty=Float"
~"llforeign_ret_ty=Float"
@luqmana
luqmana / rj.rs
Last active December 21, 2015 06:28
extern mod sdl;
use std::libc::{c_int, c_void};
use std::rt::comm;
use std::rt::io::extensions::*;
use std::rt::io::io_error;
use std::rt::io::net::ip::{IpAddr, Ipv4Addr, Port, SocketAddr};
use std::rt::io::net::tcp::TcpStream;
use std::task;
use std::vec;
#[simd]
struct F(f32, f32);
static A: F = F(2.0, 3.5);
fn main() {
}
@luqmana
luqmana / foo.c
Created September 19, 2013 18:58
extern int foobar __attribute__((weak));
int main(int argc, char *argv[]) {
return foobar;
}
@luqmana
luqmana / build
Last active December 24, 2015 05:09
-> % rustc foo.rs --lib -Z extra-debug-info
-> % ls
foo.c foo.rs libfoo-102129e09d96658-0.0.so
-> % gcc foo.c -g -L. -lfoo-102129e09d96658-0.0 -o foo
-> % LD_LIBRARY_PATH=. ./foo
[1] 30770 segmentation fault LD_LIBRARY_PATH=. ./foo
@luqmana
luqmana / rotl.rs
Last active December 27, 2015 21:09
#![feature(asm, macro_rules)]
use std::mem;
fn rotl(val: u64, shift: u8) -> u64 {
let sz = mem::size_of_val(&val);
(val << shift) | (val >> (sz * 8 - shift as uint))
}
@luqmana
luqmana / gist:2d688d81fed84caba0a6
Created May 2, 2014 05:16
Ident Server in Rust

Simple Ident Server in Rust

This is a quick example of a simple TCP server written (mostly) in Rust which implements RFC 1413. It has a bit of networking, regex, and FFI.

All code examples have been written against a recent build from git: rustc 0.11-pre (9f484e6 2014-04-30 15:46:47 -0700)

To start off, how about we flesh out the general structure a little:

Or what the hell do #![no_start], #![no_main], #[lang = "start"], #[start], and #[main] do?

Crate Attributes:

#![no_start]

Disable automatically linking in the native crate and thus the default start lang item.

Which means you'll probably need one of: #![no_main], #![lang = “start”] or #[start] instead