summaryrefslogtreecommitdiff
path: root/nacl/cpucycles/do
blob: efc063ded64e7d0957dd00d5412b1e6c37aef015 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh -e

okabi | (
  while read abi
  do

    rm -f cpucycles.o cpucycles.h
    
    (
      case "$abi" in
        ppc*)
          echo powerpccpuinfo
          echo powerpcmacos
	  ;;
        amd64*)
          echo amd64tscfreq
          echo amd64cpuinfo
          echo amd64cpuspeed
	  ;;
        x86*)
          echo x86tscfreq
          echo x86cpuinfo
          echo x86cpuspeed
          echo x86estimate
	  ;;
	cell*)
          echo celllinux
	  ;;
	sparc*)
          echo sparccpuinfo
          echo sparc32cpuinfo
	  ;;
	mips*)
          echo mips
	  ;;
	hppa*)
          echo hppapstat
	  ;;
	alpha*)
          echo alpha
	  ;;
	sgi*)
          echo sgi
	  ;;
	arm*)
	  echo cortex
          echo dev4ns
	  ;;
      esac

      echo amd64tscfreq
      echo amd64cpuinfo
      echo amd64cpuspeed
      echo x86tscfreq
      echo x86cpuinfo
      echo x86cpuspeed
      echo x86estimate
      echo ia64cpuinfo
      echo powerpccpuinfo
      echo powerpcmacos
      echo celllinux
      echo sparccpuinfo
      echo sparc32cpuinfo
      echo mips
      echo hppapstat
      echo alpha
      echo sgi
      echo cortex
      echo dev4ns
      echo monotoniccpuinfo
      echo monotonic
      echo gettimeofday
    ) | (
      while read n
      do
        okc-$abi | (
          while read c
          do
            echo "=== `date` === Trying $n.c with $c..." >&2
            rm -f test cpucycles-impl.o cpucycles-impl.h cpucycles-impl.c
            cp $n.c cpucycles-impl.c || continue
            cp $n.h cpucycles-impl.h || continue
            $c -c cpucycles-impl.c || continue
            $c -o test test.c cpucycles-impl.o || continue
            ./test || continue
            echo "=== `date` === Success. Using $n.c." >&2
            mkdir -p lib/$abi
            mv cpucycles-impl.o lib/$abi/cpucycles.o
            mkdir -p include/$abi
            mv cpucycles-impl.h include/$abi/cpucycles.h
            exit 0
          done
          exit 111
        ) && exit 0
      done
      exit 111
    ) || (
      echo ===== Giving up. >&2
      rm -f test cpucycles-impl.o cpucycles-impl.h cpucycles-impl.c
      exit 111
    ) || exit 0

  done
  exit 0
) || exit 111