Skip to content

Instantly share code, notes, and snippets.

RUSTC = rustc
CC = gcc
AR = ar
test: test.rs ffi.o
$(RUSTC) $< -L . -o $@
ffi.o: ffi.c
$(CC) -fPIC -c $< -o $@
CC = gcc
RUSTC = rustc
BINDGEN = bindgen
test: test.rs hello.rs libhello.so
$(RUSTC) $< -L . -o $@
hello.rs: hello.h
$(BINDGEN) -l hello $< -o $@
@crabtw
crabtw / Makefile
Last active December 17, 2015 16:19
clang arm cross compiler
BIN = arm-linux-gnueabihf-clang
SRC = arm_linux_gnueabihf.ml
LIB = unix.cmxa
all: $(BIN)
$(BIN): $(SRC)
ocamlopt -o $@ $(LIB) $<
@crabtw
crabtw / report.rb
Last active December 15, 2015 18:29
require 'write_xlsx'
x = [[
['aaa', 'In Progress', '2013/4/15', 'High'],
['456', 'Done, New'],
['789', 'Done, New'],
]]
wb = WriteXLSX.new('report.xlsx')
ws = wb.add_worksheet
diff --git a/configure b/configure
index a58a0a6..08d6298 100755
--- a/configure
+++ b/configure
@@ -308,8 +308,6 @@ case $CFG_OSTYPE in
esac
-if [ -z "$CFG_CPUTYPE" ]
-then
/* automatically generated by rust-bindgen */
use core::libc::*;
pub type __int8_t = c_schar;
pub type __uint8_t = c_uchar;
pub type __int16_t = c_short;
pub type __uint16_t = c_ushort;
pub type __int32_t = c_int;
pub type __uint32_t = c_uint;
pub type __int64_t = c_long;
@crabtw
crabtw / cmake.scan.sh
Created March 26, 2013 05:35
cross scan-build wrappers
#!/bin/sh
TARGET="mips-unknown-linux-uclibc"
TOOLCHAIN_PATH="$HOME/x-tools/$TARGET"
SYSROOT="$HOME/sysroot/$TARGET"
SCAN_BUILD_DIR="$HOME/src/llvm-svn/tools/clang/tools/scan-build"
SCAN_BUILD_CC="$HOME/bin/$TARGET-clang"
SCAN_BUILD_CXX="$HOME/bin/$TARGET-clang++"
SCAN_BUILD_OUT="analysis"
pub struct _XGC {
pub ext_data: *XExtData,
pub gid: GContext,
}
pub type GC = *_XGC;
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+-----------------------------------------------------------------------------------------------+
| | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| two's complement integer | --- | --- | --- | --- | --- | --- | --- | --- |
| | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256 |
+-----------------------------------------------------------------------------------------------+
float temp_decode(int16_t temp) {
int16_t hi = temp & 0xff00;
int16_t lo = temp & 0x00ff;
return (hi + lo) / 256.0;
}