blob: 1a867266c19ec52d474e7f8416c614b71746ae21 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/bin/sh
echo "#ifndef COPYJIT_OPS_H" > ops.h
echo "#define COPYJIT_OPS_H" >> ops.h
echo "#ifndef COPYJIT_DECLS_H" > decls.h
echo "#define COPYJIT_DECLS_H" >> decls.h
echo "#ifndef COPYJIT_DEFNS_H" > defns.h
echo "#define COPYJIT_DEFNS_H" >> defns.h
for bin in ${1}
do
base=$(basename "${bin}")
op=${base%.*}
cp "../${bin}" "gen/${op}"
xxd -i "gen/${op}" >> ops.h
echo "void *compile_${op}(ctx_t *ctx);" >> decls.h
echo "void *compile_${op}(ctx_t *ctx)\n" \
"{\n" \
" void *pc = ctx->pc;\n" \
" memcpy(pc, gen_${op}, gen_${op}_len);\n" \
" ctx->pc += gen_${op}_len;\n" \
" return pc;\n" \
"}" >> defns.h
done
echo "#endif /* COPYJIT_OPS_H */" >> ops.h
echo "#endif /* COPYJIT_DECLS_H */" >> decls.h
echo "#endif /* COPYJIT_DEFNS_H */" >> defns.h
|