abi.sh changes
[musl-tools.git] / abi.sh
blob3686c57f5290609d66ec83cc918976309daa8e72
1 #!/bin/sh
3 export LC_ALL=C
4 MUSL=${MUSL:-../musl}
6 awk -F'\t' '$3 ~ /^[sut]$/ {
7 print $1
8 }' data/musl.tags >/tmp/m.type
9 echo 'char' >>/tmp/m.type
10 echo 'short' >>/tmp/m.type
11 echo 'int' >>/tmp/m.type
12 echo 'long' >>/tmp/m.type
13 echo 'long_long' >>/tmp/m.type
14 echo 'float' >>/tmp/m.type
15 echo 'double' >>/tmp/m.type
16 echo 'long_double' >>/tmp/m.type
17 echo 'wchar_t' >>/tmp/m.type
18 echo 'bool' >>/tmp/m.type
19 echo 'void' >>/tmp/m.type
22 cd $MUSL/include
23 find . -name '*.h' | sed 's,^\./,,' >/tmp/m.header
26 echo '#define _GNU_SOURCE 1' >abi.cc
27 echo '#define _FILE_OFFSET_BITS 64' >>abi.cc
28 echo '#define SYSLOG_NAMES 1' >>abi.cc
29 echo '#include <stddef.h>' >>abi.cc
30 echo '#include <sys/types.h>' >>abi.cc
31 echo '' >>abi.cc
33 sort /tmp/m.header |uniq |awk '
34 /^sys\/(auxv|cachectl|fantotify|errno|fcntl|kd|poll|signal|soundcard|termios|vt)\.h$/ { printf "//" }
35 /^(bits\/.*|stdalign|stdnoreturn|threads|wait)\.h$/ { printf "//" }
36 { print "#include <" $0 ">" }' >>abi.cc
37 echo 'typedef long long long_long; typedef long double long_double;' >>abi.cc
38 echo 'struct size{int i;}; struct align{int i;};' >>abi.cc
39 echo '#define p(s,t) void x_##t(s t x, s t* ptr, size(*y)[sizeof(s t)], align(*z)[__alignof__(s t)]){}' >>abi.cc
40 echo '#define pp(s,t) void y_##t(s t* ptr, size(*y)[sizeof(s t*)], align(*z)[__alignof__(s t*)]){}' >>abi.cc
41 echo '
42 #ifdef __GLIBC__
43 #define M(x)
44 #else
45 #define M(x) x
46 #endif
47 ' >>abi.cc
49 sort /tmp/m.type |uniq |awk '
50 /^(once_flag|mtx_t|cnd_t|thrd_start_t|thrd_t|tss_dtor_t|tss_t)$/ ||
51 /^(struct|union) __(CODE|ptcb|siginfo|ucontext|sigjmp_buf|double_repr|float_repr|sigset_t|mbstate_t|fsid_t)$/ ||
52 /^(elf_fpxregset_t|struct user_fpxregs_struct|Sg_io_vec|struct ih_.*|struct ip6_hdrctl|tcp_seq|union _G_fpos64_t|struct cpu_set_t|__isoc_va_list|ns_tcp_tsig.*|ns_tsig_.*|struct ptrace_peeksiginfo_.*)$/ { printf "//" }
53 { if (!sub(/ /,",")) sub(/^/,",") }
54 /,(DIR|FILE|void)$/ { print "pp(" $0 ")"; next }
55 { print "p(" $0 ")" }' >>abi.cc
57 #$CXX -S -o - abi.cc |sed -n 's/^\(_Z.*\):/\1/p' |$CXXFILT |sed '
58 #s/^x_\([^(]*\)(\(.*\))/\1: \2/
59 #s/^y_\([^(]*\)(\(.*\))/\1*: \2/
60 #s/floatcomplex /float _Complex/g
61 #s/doublecomplex /double _Complex/g
62 #' >data/musl.abi_type