This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang pie | |
;3-24 | |
(claim + (-> Nat Nat Nat)) | |
(define + | |
(λ(a b) | |
(iter-Nat a | |
b | |
(λ(almost) | |
(add1 almost) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 ++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jit-toy: jit-toy.cpp | |
clang++ -g -o $@ $^ $(shell /usr/lib/llvm-5.0/bin/llvm-config --cxxflags --ldflags --system-libs --libs core) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 这个counter是线程安全的, 使用了 CAS 指令 | |
#include <stdio.h> | |
#include <pthread.h> | |
volatile int counter = 0; | |
void counter_inc() | |
{ | |
int observed; | |
do { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <pthread.h> | |
#include <stdio.h> | |
int x, y; | |
int r1, r2; | |
volatile int chance, complete; | |
typedef struct { | |
int mask; |