summaryrefslogtreecommitdiff
path: root/calc.sh
blob: b6f8a015e17c02dc38f1c27e221961a47bdc6bbf (plain)
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
31
32
#!/bin/sh
tmp=/tmp/test_$$

cat >$tmp.c << EOS
#include <stdio.h>
#include "r600_reg.h"
int main (int argc, char *argv[]) {
long val =
EOS

if [ "x$1" = x ] ; then
  cat >>$tmp.c
else
  echo "$@" >>$tmp.c
fi
if [ "x`sed -e '$!d;s/.*\(.\)$/\1/' $tmp.c`" != "x;" ] ; then
  echo ";" >>$tmp.c
fi

cat >>$tmp.c <<EOE
printf (" = %ld = 0x%lx\n", val, val);
return 0;
}
EOE

if gcc -I. -o $tmp.out $tmp.c ; then
  $tmp.out
else
  cat $tmp.c
fi

rm -f $tmp.c $tmp.out