Skip to content

Instantly share code, notes, and snippets.

View 38's full-sized avatar
🐱
🐱 🐈 😹 😸 😼

Hao Hou 38

🐱
🐱 🐈 😹 😸 😼
  • University of Utah
  • Salt Lake City, UT
  • X @haohou302
View GitHub Profile
@38
38 / the-little-typer.rkt
Last active May 19, 2022 09:20
The little typer code
#lang pie
;3-24
(claim + (-> Nat Nat Nat))
(define +
(λ(a b)
(iter-Nat a
b
(λ(almost)
(add1 almost)
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <dlfcn.h>
void compile_brainfuck_to_c(const char* program, FILE* fout)
{
fprintf(fout, "void bf_main(char* data) { char* ptr = data;");
for(;program && *program; program ++)
{
@38
38 / Makefile
Last active February 19, 2024 02:12
A Minimal LLVM JIT example for LLVM-5
jit-toy: jit-toy.cpp
clang++ -g -o $@ $^ $(shell /usr/lib/llvm-5.0/bin/llvm-config --cxxflags --ldflags --system-libs --libs core)
// 这个counter是线程安全的, 使用了 CAS 指令
#include <stdio.h>
#include <pthread.h>
volatile int counter = 0;
void counter_inc()
{
int observed;
do {
@38
38 / ts.c
Last active June 21, 2018 04:24
乱序执行实验
#include <pthread.h>
#include <stdio.h>
int x, y;
int r1, r2;
volatile int chance, complete;
typedef struct {
int mask;