Unify process_alloc() and process_realloc() with PROCESS_ALLOC_MODE_REALLOC bit
[moveable_pool.git] / cpp.sh
1 #!/bin/sh -e
2 dir=$1
3 shift
4 mkdir --parents $dir
5 sed -e 's/^#include </$include </; s/^#include "rassert\.h"/$include "rassert.h"/; s/^#define DISK_/$define DISK_/; s/^#define BLOCK_/$define BLOCK_/; s/^#define UCP/$define UCP/; s/^#define TRANSFER_/$define TRANSFER_/; s/^#define POOL_ALLOC_MODE_/$define POOL_ALLOC_MODE_/; s/^#define PROCESS_TEST_TYPE_/$define PROCESS_TEST_TYPE_/' -i *.[ch]
6 for i in \
7 block_pool.c \
8 block_pool.h \
9 core.c \
10 core.h \
11 pool.c \
12 pool.h \
13 process.c \
14 process.h \
15 process_test.h \
16 process_test_gen.c \
17 process_test_run.c \
18 swap.c \
19 swap.h
20 do
21   (echo END; sed -e "/\\\\$/{s/.\\n//; N}; s/^\\/\\/#define .*//; s/\\/\\/.*/\"&\"/; s/^\\(#.*\\)\"\\(\\/\\/.*\\)\"$/\\1\\2/; s/^#.*/BEGIN '&'\\n&\\nEND/" <$i; echo BEGIN) >a.c
22   gcc "$@" -E a.c |sed -ne "/^END/,/^BEGIN/{s/\"\\(\\/\\/.*\\)\"$/\\1/; s/^BEGIN '\\(#include .*\\)'$/\\1/; p}" |grep -v '^\(BEGIN\|END\)' |./blank.py >$dir/$i
23 done
24 sed -e 's/^\$/#/' -i *.[ch] $dir/*.[ch]
25 for i in $dir/*.h
26 do
27   name=`basename $i |sed -e 'y/abcdefghijklmnopqrstuvwxyz\./ABCDEFGHIJKLMNOPQRSTUVWXYZ_/'`
28   (
29     cat <<EOF
30 #ifndef _$name
31 #define _$name 1
32
33 EOF
34     cat $i
35     cat <<EOF
36
37 #endif
38 EOF
39   ) >a.h
40   mv a.h $i
41 done
42 rm -f a.c a.h