Skip to content

Instantly share code, notes, and snippets.

View pczarn's full-sized avatar
🇵🇱
Proland

Peter Blackson pczarn

🇵🇱
Proland
  • Poland
View GitHub Profile
@pczarn
pczarn / lazylink.rb
Last active August 29, 2015 13:57 — forked from ttscoff/lazylink.rb
enum GPIO {
GPIO0,
GPIO1,
}
static GPIO0_ADDR: *mut Regs = 0xDEADBEEF as *mut Regs;
static GPIO1_ADDR: *mut Regs = 0xBEEFDEAD as *mut Regs;
impl GPIO {
fn get_addr(self) -> *mut Regs {
@pczarn
pczarn / README.md
Last active August 29, 2015 14:01
Layout analysis of Rust's structs

Struct layout: total space occupied by padding

(including drop flags and tail padding)

total padding (bytes) number of structs
0 641
1 6
2 7
3 15
make CFG_HOST=x86_64-unknown-linux-gnu CFG_BUILD=x86_64-unknown-linux-gnu CFG_TARGET="x86_64-unknown-linux-gnu arm-linux-noeabi" rustc-stage1
make -C "`pwd`/src/compiler-rt" ProjSrcRoot="`pwd`/src/compiler-rt" ProjObjRoot="`pwd`/arm-linux-noeabi/rt/compiler-rt" CC="arm-none-eabi-gcc" AR="arm-none-eabi-ar" RANLIB="arm-none-eabi-ar s" CFLAGS="-Wall -Werror -g -fPIC -D_YUGA_LITTLE_ENDIAN=1 -D_YUGA_BIG_ENDIAN=0 -march=armv6" TargetTriple="arm-linux-noeabi" triple-builtins
cp arm-linux-noeabi/rt/compiler-rt/triple/builtins/libcompiler_rt.a arm-linux-noeabi/rt/
rustc-stage1 --target arm-linux-noeabi -O src/libcore/lib.rs
mkdir -p x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-linux-noeabi/lib/
mv libcore-c5ed6fb4-0.11.0-pre.rlib x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-linux-noeabi/lib/libcore-c5ed6fb4-0.11.0-pre.rlib
./configure CXX=i686-w64-mingw32-g++ CC=i686-w64-mingw32-g++ CFLAGS="-s -Bdynamic -shared -Wl,--kill-at -static-libstdc++ -static-libgcc" --host=i686-w64-mingw32 --prefix="/usr/i686-w64-mingw32"
@pczarn
pczarn / deps.rs
Last active March 20, 2016 07:28 — forked from alexcrichton/deps.rs
Rust: dependency graph
use std::io;
fn main() {
println!("digraph {{");
let mut input = io::stdin();
let mut lines = input.lines();
loop {
match lines.next() {
Some(line) => {
let line = line.unwrap();
let line = line.as_slice();
bits 64
global _main
section .text
_main:
sub rsp,24
mov rcx,100000000
movaps xmm0,[rel value]
movaps xmm1,[rel key]
loop: aesenc xmm0,xmm1
"time: 0.031 s gated feature checking
48.0 2.4 213248 100476
"time: 0.000 s crate injection
50.0 2.5 217344 102524
"time: 0.115 s configuration 1
60.0 2.5 323700 102964
"time: 0.016 s plugin loading
62.0 2.6 323700 105776
"time: 0.000 s plugin registration
64.0 2.6 323700 105776
@pczarn
pczarn / marpa_error_codes.md
Last active March 20, 2016 07:26
libmarpa's error codes

Libmarpa 7.3.0 failure return values, for your bindings-writing pleasure

Always succeed.

marpa_check_version
marpa_c_init
marpa_c_error
marpa_r_earley_item_warning_threshold
marpa_r_earley_item_warning_threshold_set
@pczarn
pczarn / a1.c
Last active August 29, 2015 14:12
An attempt at optimization. The code merges slices contiguous in memory.
#include "stddef.h"
#include "stdio.h"
void __attribute__ ((noinline))
print(char *state, size_t state_len) {
for(size_t i = 0; i < state_len; i++) {
printf("%d ", (int)state[i]);
}
printf("\n");
}