Skip to content

Instantly share code, notes, and snippets.

View omasanori's full-sized avatar

Masanori Ogino omasanori

View GitHub Profile
@omasanori
omasanori / x86_64-gentoo-linux-musl.log
Last active March 9, 2016 00:41
An experiment for the size of hello world.
$ gcc --version | head -n1
gcc (Gentoo Hardened 4.9.3-r99 p1.2, pie-0.6.3) 4.9.3
$ gcc -dumpmachine
x86_64-gentoo-linux-musl
$ cat hello.c
#include <stdio.h>
int main(void)
{
puts("hello, world");
return 0;
top: 30
before: 30
top: #<proc 0x7feb29328de0>
before: #<proc 0x7feb29328de0>
top: #<proc 0x7feb29328a20>
before: #<proc 0x7feb29328a20>
top: #<proc 0x7feb2932baf8>
before: #<proc 0x7feb2932baf8>
top: #<proc 0x7feb2932b738>
before: #<proc 0x7feb2932b738>
$ gcc -E -v -march=native -xc /dev/null 2>&1 | grep cc1
/usr/libexec/gcc/i686-pc-linux-gnu/4.8.3/cc1 -E -quiet -v /dev/null -march=athlon-4 -mno-cx16 -mno-sahf -mno-movbe -mno-aes -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=64 -mtune=athlon -fstack-protector
@omasanori
omasanori / abvis.rb
Created January 11, 2015 07:05
An implementation of minimax and alpha-beta punning written in Ruby, with visualization using Graphviz dot language.
class Node
attr_accessor :symbol, :score, :my_turn, :children, :visited
def initialize(symbol, score, my_turn, children)
@symbol = symbol
@score = score
@my_turn = my_turn
@children = children
@visited = false
end
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
[1 of 1] Compiling Main ( dist/setup/setup.hs, dist/setup/Main.o )
Linking ./dist/setup/setup ...
Configuring purescript-0.5.1...
Building purescript-0.5.1...
Preprocessing library purescript-0.5.1...
[ 1 of 52] Compiling Language.PureScript.Parser.State ( src/Language/PureScript/Parser/State.hs, dist/build/Language/PureScript/Parser/State.o )
[ 2 of 52] Compiling Language.PureScript.CodeGen.Monad ( src/Language/PureScript/CodeGen/Monad.hs, dist/build/Language/PureScript/CodeGen/Monad.o )
[ebuild N ~] dev-lang/parrot-6.2.0:0/6.1.0 USE="gdbm gmp nls opengl pcre ssl unicode -doc -examples" 0 kB
[ebuild N ~] dev-lang/nqp-2014.03 USE="parrot -doc -java -moar" 4,929 kB
[ebuild N ~] dev-lang/rakudo-2014.03.01 USE="parrot -doc -java" 1,307 kB
[blocks B ] =dev-lang/parrot-6.2.0 ("=dev-lang/parrot-6.2.0" is blocking dev-lang/nqp-2014.03)
Total: 3 packages (3 new), Size of downloads: 6,235 kB
Conflict: 1 block (1 unsatisfied)
* Error: The above package list contains packages which cannot be
* installed at the same time on the same system.
test.c:10:27: warning: incompatible pointer types passing 'jmp_buf' (aka 'struct __jmp_buf_tag [1]') to parameter of type 'void **' [-Wincompatible-pointer-types]
(void)(__builtin_setjmp(tag.buf) ? 1 : 0);
^~~~~~~
1 warning generated.
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/tmp/test-11ca81.o: In function `jump':
test.c:(.text+0x26): undefined reference to `.LBB0_-1'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(define (reverse xs . args)
(let ((ys (if (not (null? args)) (car args) '())))
(if (null? xs)
ys
(reverse (cdr xs) (cons (car xs) ys)))))
@omasanori
omasanori / map.scm
Created February 16, 2014 09:43
A tail-recursive map function with well-known "reverse map" technique.
(define (reverse xs)
(define (rev-iter xs ys)
(if (null? xs)
ys
(rev-iter (cdr xs) (cons (car xs) ys)))) ; tail-recursive
(rev-iter xs '()))
(define (foldl f init xs)
(if (null? xs)
init
@omasanori
omasanori / main.rs
Created January 19, 2014 09:03
A study of Runtimeless Rust
// To compile:
// $ rustc --target <target environment> --lib -c -o main.o main.rs
#[no_std];
#[no_mangle]
pub fn main() {
}