c99 and posix coverage table generator scirpts
[musl-tables] / tab_c99.sh
1 #!/bin/sh
2
3 export LC_ALL=C
4 MUSL=../musl
5
6 ( cd $MUSL; git log -n1 ) | awk '
7 BEGIN {
8         getline
9         hash = $2
10         getline
11
12         commit = "<h4>commit</h4><p>commit <a href=\"http://git.etalabs.net/cgi-bin/gitweb.cgi?p=musl;a=commit;h=" hash "\">" hash "</a>"
13         while (getline == 1)
14                 commit = commit "<br>" $0
15
16         FS = "\t"
17
18         c99 = "data/c99"
19         syms = "data/musl.syms"
20         tags = "data/musl.tags"
21
22         while (getline < syms == 1)
23                 sym[$2] = $1
24         while (getline < tags == 1) {
25                 if ($2 ~ /bits\//)
26                         s = $3 " "
27                 else
28                         s = "<a href=\"http://git.etalabs.net/cgi-bin/gitweb.cgi?p=musl;a=blob;f=include/" $2 ";hb=" hash "#l" $4 "\">" $3 "</a> "
29                 kind[$1] = kind[$1] $3
30                 kindstr[$1] = kindstr[$1] s
31         }
32
33         legend = "<h4>legend</h4><ul><li>status: musl implementation status summary<ul>"
34         legend = legend "<li>(empty) - implemented"
35         legend = legend "<li>nosym - prototype found in include files (see decl) but not in libc.a (see sym)"
36         legend = legend "<li>nodecl - symbol is in libc.a but not declared in a public header"
37         legend = legend "<li>missing - neither in include files (see decl) nor in libc.a (see sym)"
38         legend = legend "</ul><li>sym: external symbol kind as found by `nm libc.a` (symbol kind only reported once)<ul>"
39 #       legend = legend "<li>A - symbol value is absolute"
40 #       legend = legend "<li>B - symbol is in the uninitialized data section (known as BSS)"
41         legend = legend "<li>C - symbol is common (uninitialized data)"
42         legend = legend "<li>D - symbol is in the initialized data section"
43 #       legend = legend "<li>G - symbol is in the initialized data section for small objects"
44 #       legend = legend "<li>I - indirect reference to another symbol"
45 #       legend = legend "<li>N - debugging symbol"
46         legend = legend "<li>R - symbol is in the read only data section"
47 #       legend = legend "<li>S - symbol is in the uninitialized data section for small objects"
48         legend = legend "<li>T - symbol is in the text section"
49 #       legend = legend "<li>U - undefined symbol"
50         legend = legend "<li>V - weak object"
51         legend = legend "<li>W - weak symbol"
52         legend = legend "</ul><li>decl: kind of declaration as found by `ctags -R include` (every occurance is reported, arch specific definitions are not linked)<ul>"
53         legend = legend "<li>d - macro definition"
54         legend = legend "<li>t - typedef"
55         legend = legend "<li>s - struct declaration"
56         legend = legend "<li>u - union declaration"
57         legend = legend "<li>p - function prototype"
58         legend = legend "<li>x - external and forward variable declaration"
59         legend = legend "</ul></ul>"
60
61         print "<h3>musl vs c99 api</h3>"
62         print commit
63         print legend
64         print "<h4>table</h4><table border=1><tr><th colspan=3>musl<th colspan=4>c99<tr><th>status<th>sym<th>decl<th>name<th>header<th>proto<th>section"
65         nodecl = nosym = missing = 0
66         while (getline < c99 == 1) {
67                 s = "<tr><td>"
68                 if (sym[$1] && kind[$1]) {
69                         s = s "&#160;"
70                 } else if (sym[$1]) {
71                         s = s "nodecl"
72                         nodecl++
73                 } else if (kind[$1] ~ /[dtsu]/) {
74                         s = s "&#160;"
75                 } else if (kind[$1]) {
76                         s = s "nosym"
77                         nosym++
78                 } else {
79                         s = s "missing"
80                         missing++
81                 }
82                 s = s "<td>" sym[$1]
83                 if (!sym[$1])
84                         s = s "&#160;"
85                 s = s "<td>" kindstr[$1]
86                 if (!kind[$1])
87                         s = s "&#160;"
88
89                 s = s "<td>" $1
90                 s = s "<td>" $3
91                 if ($2)
92                         s = s "<td>" $2
93                 else
94                         s = s "<td>&#160;"
95                 s = s "<td>" $4
96                 print s
97         }
98         print "</table>"
99         print "<h4>stats</h4><ul><li>missing: " missing "<li>nosym: " nosym "<li>nodecl: " nodecl "</ul>"
100 }' >tab_c99.html