Skip to content

Instantly share code, notes, and snippets.

@xxuejie
xxuejie / solarize.sh
Created September 18, 2012 18:45 — forked from codeforkjeff/solarize.sh
shell script for setting gnome-terminal color palette to use Solarized theme
#!/bin/sh
#
# Shell script that configures gnome-terminal to use solarized theme
# colors. Written for Ubuntu 11.10, untested on anything else.
#
# Solarized theme: http://ethanschoonover.com/solarized
#
# Adapted from these sources:
# https://gist.github.com/1280177
# http://xorcode.com/guides/solarized-vim-eclipse-ubuntu/
@xxuejie
xxuejie / va-args-bug.c
Created November 13, 2012 01:58
va_arg bug of emscripten
#include <stdio.h>
#include <stdarg.h>
typedef struct type_a {
union {
double f;
void *p;
int i;
short sym;
} value;
@xxuejie
xxuejie / clang.out
Created November 21, 2012 22:43
Stack manipulation setjmp with emscripten
$ clang stack-manipulation.c
$ ./a.out
Entering stack_manipulate_func, level: 0
Setjmp normal execution path, level: 0
Entering stack_manipulate_func, level: 1
Perform longjmp at level 1
Setjmp error execution path, level: 0
Exiting stack_manipulate_func, level: 0
@xxuejie
xxuejie / clang++.out
Created November 21, 2012 23:02
setjmp/longjmp workaround using C++ exceptions
$ clang++ stack-manipulation-exception.cc
$ ./a.out
Entering stack_manipulate_func, level: 0
Normal execution path, level: 0
Entering stack_manipulate_func, level: 1
Throws exception at level 1
Error execution path, level: 0
Exiting stack_manipulate_func, level: 0
@xxuejie
xxuejie / clang.out
Created December 7, 2012 22:49
setjmp does not restore local variables
$ clang setjmp-test.c
$ ./a.out
setjmp normal execution path, level: 0, prev_jmp: 0x0
setjmp normal execution path, level: 1, prev_jmp: 0x7fff5df345f0
level is 2, perform longjmp!
setjmp exception execution path, level: 1, prev_jmp: 0x7fff5df345f0
prev_jmp is not empty, continue with longjmp!
setjmp exception execution path, level: 0, prev_jmp: 0x0
Exiting setjmp function, level: 0, prev_jmp: 0x0
@xxuejie
xxuejie / clang++.out
Created December 7, 2012 23:16
c++ exception also does not restore local variables
$ clang++ setjmp-cpp-test.cc
$ ./a.out
setjmp normal execution path, level: 0, prev_jmp: -1
setjmp normal execution path, level: 1, prev_jmp: 0
level is 2, perform longjmp!
setjmp exception execution path, level: 1, prev_jmp: 0
prev_jmp is not empty, continue with longjmp!
setjmp exception execution path, level: 0, prev_jmp: -1
Exiting setjmp function, level: 0, prev_jmp: -1
@xxuejie
xxuejie / clang.out
Created December 8, 2012 03:37
Cannot call longjmp twice on the same jmp_buf
$ clang setjmp-twice.c
$ ./a.out
Normal execution path of first function!
Exception execution path of first function!
Exception execution path of first function!
Calling longjmp the second time!
@xxuejie
xxuejie / clang-O2.out
Created December 8, 2012 23:27
setjmp testcase compiled with -O2 option
$ clang -O2 setjmp-twice.c
$ ./a.out
Normal execution path of first function!
Exception execution path of first function!
Exception execution path of first function!
Calling longjmp the second time!
@xxuejie
xxuejie / cc.rb
Created December 12, 2012 17:54
wrapper for creating node-powered js "binaries" with emcc
#!/usr/bin/env ruby
# %% -*- ruby -*-
# This script adds a wrapper to emcc: when the value of -o option is an
# executable file without extensions(such as mrbc), we would first use
# emcc to generate a .js file, then adds a "#!/usr/bin/env node" line at
# the top, finally removes the extension and mark the file mode as
# executable to pretend creating a binary file.
WEBRUBY_ROOT = File.join(File.dirname(__FILE__), '..')
@xxuejie
xxuejie / asmjs-test.c
Created January 1, 2013 18:19
js->c calling bugs in ASM_JS mode
#include <stdio.h>
#include <emscripten/emscripten.h>
void EMSCRIPTEN_KEEPALIVE c_func_calling_from_js() {
printf("This is a c function calling from js!");
}
extern void js_func();