X-Git-Url: http://nsz.repo.hu/git/?p=musl-tables;a=blobdiff_plain;f=abi_type.sh;h=50d283aceb00fda9624e42fa844d931b1707ed8c;hp=3686c57f5290609d66ec83cc918976309daa8e72;hb=HEAD;hpb=ba78abf4a6e2d5b0abfa67994481512e58597b9e diff --git a/abi_type.sh b/abi_type.sh index 3686c57..9120c3f 100755 --- a/abi_type.sh +++ b/abi_type.sh @@ -1,62 +1,96 @@ #!/bin/sh export LC_ALL=C -MUSL=${MUSL:-../musl} -awk -F'\t' '$3 ~ /^[sut]$/ { +ALL=' +aarch64 +arm +i386 +m68k +microblaze +mips +mips64 +mipsn32 +or1k +powerpc +powerpc64 +sh +x32 +x86_64 +' +ARCH="${ARCH:-$ALL}" + +# install headers to T.$arch +for arch in $ARCH +do + +{ +awk -F'\t' '$3 ~ /^[sutSUT]$/ { print $1 -}' data/musl.tags >/tmp/m.type -echo 'char' >>/tmp/m.type -echo 'short' >>/tmp/m.type -echo 'int' >>/tmp/m.type -echo 'long' >>/tmp/m.type -echo 'long_long' >>/tmp/m.type -echo 'float' >>/tmp/m.type -echo 'double' >>/tmp/m.type -echo 'long_double' >>/tmp/m.type -echo 'wchar_t' >>/tmp/m.type -echo 'bool' >>/tmp/m.type -echo 'void' >>/tmp/m.type - -( - cd $MUSL/include - find . -name '*.h' | sed 's,^\./,,' >/tmp/m.header -) - -echo '#define _GNU_SOURCE 1' >abi.cc -echo '#define _FILE_OFFSET_BITS 64' >>abi.cc -echo '#define SYSLOG_NAMES 1' >>abi.cc -echo '#include ' >>abi.cc -echo '#include ' >>abi.cc -echo '' >>abi.cc - -sort /tmp/m.header |uniq |awk ' - /^sys\/(auxv|cachectl|fantotify|errno|fcntl|kd|poll|signal|soundcard|termios|vt)\.h$/ { printf "//" } - /^(bits\/.*|stdalign|stdnoreturn|threads|wait)\.h$/ { printf "//" } - { print "#include <" $0 ">" }' >>abi.cc -echo 'typedef long long long_long; typedef long double long_double;' >>abi.cc -echo 'struct size{int i;}; struct align{int i;};' >>abi.cc -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 -echo '#define pp(s,t) void y_##t(s t* ptr, size(*y)[sizeof(s t*)], align(*z)[__alignof__(s t*)]){}' >>abi.cc +}' data/musl.generic.decls data/musl.$arch.decls +echo 'function_pointer +object_pointer +char +short +int +long +long_long +float +double +long_double +wchar_t +bool' +} |sort |uniq >/tmp/m.$arch.type + +awk -F'\t' '{print $2}' data/musl.generic.decls |sort |uniq >/tmp/m.header + +echo ' +#define _GNU_SOURCE 1 +#define _FILE_OFFSET_BITS 64 +#define SYSLOG_NAMES 1 +#include +#include +' >abi_type.$arch.cc + +awk ' +/^sys\/(cachectl|fantotify|errno|fcntl|io|kd|poll|reg|signal|soundcard|termios|vt)\.h$/ { printf "//" } +/^(wait)\.h$/ { printf "//" } +{ w=0 } +/^(stdalign|stdnoreturn|threads)\.h$/ { w=1 } +{ + if(w) print "#ifndef __GLIBC__" + print "#include <" $0 ">" + if(w) print "#endif" +}' /tmp/m.header >>abi_type.$arch.cc + echo ' +typedef long long long_long; +typedef long double long_double; +typedef void *object_pointer; +typedef void (*function_pointer)(); +struct size {char c;}; +struct align {char c;}; +struct incomplete {char c;}; +#define T(s,t) void x_##t(s t x, s t* ptr, size(*y)[sizeof(s t)], align(*z)[__alignof__(s t)]){} +#define P(s,t) void x_##t(incomplete x, s t* ptr, incomplete y, incomplete z){} #ifdef __GLIBC__ #define M(x) #else #define M(x) x #endif -' >>abi.cc +' >>abi_type.$arch.cc -sort /tmp/m.type |uniq |awk ' - /^(once_flag|mtx_t|cnd_t|thrd_start_t|thrd_t|tss_dtor_t|tss_t)$/ || - /^(struct|union) __(CODE|ptcb|siginfo|ucontext|sigjmp_buf|double_repr|float_repr|sigset_t|mbstate_t|fsid_t)$/ || - /^(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 "//" } - { if (!sub(/ /,",")) sub(/^/,",") } - /,(DIR|FILE|void)$/ { print "pp(" $0 ")"; next } - { print "p(" $0 ")" }' >>abi.cc +awk ' +/^(struct|union) __(CODE|ptcb|siginfo|ucontext|sigjmp_buf|double_repr|float_repr|sigset_t|mbstate_t|fsid_t|locale_struct)$/ || +/^(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 "//" } +{ if (!sub(/ /,",")) sub(/^/,",") } +/,(once_flag|mtx_t|cnd_t|thrd_start_t|thrd_t|tss_dtor_t|tss_t)$/ { print "M(T(" $0 "))"; next} +/,(DIR|FILE)$/ { print "P(" $0 ")"; next } +{ print "T(" $0 ")" }' /tmp/m.$arch.type >>abi_type.$arch.cc +done -#$CXX -S -o - abi.cc |sed -n 's/^\(_Z.*\):/\1/p' |$CXXFILT |sed ' +#$CXX -S -o - abi_type.cc |sed -n 's/^\(_Z.*\):/\1/p' |$CXXFILT |sed ' #s/^x_\([^(]*\)(\(.*\))/\1: \2/ -#s/^y_\([^(]*\)(\(.*\))/\1*: \2/ #s/floatcomplex /float _Complex/g #s/doublecomplex /double _Complex/g #' >data/musl.abi_type