fix posix data (wcrtomb wrong header bug)
[musl-tables] / sizeof.sh
1 #!/bin/sh
2
3 export LC_ALL=C
4 MUSL=${MUSL:-../musl}
5
6 awk -F'\t' '$3 ~ /^[sut]$/ {
7         print $1
8 }' data/musl.tags >/tmp/m.type
9 echo 'wchar_t' >>/tmp/m.type
10
11 (
12         cd $MUSL/include
13         find . -name '*.h' | sed 's,^\./,,' >/tmp/m.header
14 )
15
16 echo '#define _GNU_SOURCE 1' >sizeof.c
17 echo '#define _LARGEFILE64_SOURCE 1' >>sizeof.c
18 echo '#define _FILE_OFFSET_BITS 64' >>sizeof.c
19 echo '#include <stddef.h>' >>sizeof.c
20 echo '#include <sys/types.h>' >>sizeof.c
21 echo '' >>sizeof.c
22
23 sort /tmp/m.header |uniq |awk '
24         /^features\.h$/ { printf "//" }
25         { print "#include <" $0 ">" }' >>sizeof.c
26 echo '#define p(x) printf("%s\\t%u\\n", #x, sizeof(x));' >>sizeof.c
27 echo 'int main(){' >>sizeof.c
28 sed 's/.*/p(&)/' /tmp/m.type |awk '
29         /p\(CODE\)/ ||
30         /p\(DIR\)/ ||
31         /p\(FILE\)/ ||
32         /p\(struct __CODE\)/ ||
33         /p\(struct __fpstate\)/ ||
34         /p\(struct __ptcb\)/ ||
35         /p\(struct __siginfo\)/ ||
36         /p\(struct __ucontext\)/ ||
37         /p\(struct in6_mutinfo\)/ ||
38         /p\(struct npttimeval\)/ { printf "//" }
39         { print }' >>sizeof.c
40 echo 'return 0;}' >>sizeof.c
41