6 awk -F'\t' '$3 ~ /^[sut]$/ {
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
23 find .
-name '*.h' |
sed 's,^\./,,' >/tmp
/m.header
26 echo '#define _GNU_SOURCE 1' >abi.cc
27 echo '#define _LARGEFILE64_SOURCE 1' >>abi.cc
28 echo '#define _FILE_OFFSET_BITS 64' >>abi.cc
29 echo '#define SYSLOG_NAMES 1' >>abi.cc
30 echo '#include <stddef.h>' >>abi.cc
31 echo '#include <sys/types.h>' >>abi.cc
34 sort /tmp
/m.header |
uniq |
awk '
35 /^sys\/(auxv|cachectl|fantotify|errno|fcntl|poll|signal|soundcard|termios)\.h$/ { printf "//" }
36 /^(stdalign|stdnoreturn|threads|wait)\.h$/ { printf "//" }
37 { print "#include <" $0 ">" }' >>abi.cc
38 echo 'typedef long long long_long; typedef long double long_double;' >>abi.cc
39 echo 'struct size{int i;}; struct align{int i;};' >>abi.cc
40 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
41 echo '#define pp(s,t) void x_##t(s t* ptr, size(*y)[sizeof(s t*)], align(*z)[__alignof__(s t*)]){}' >>abi.cc
42 sort /tmp
/m.
type |
uniq |
awk '
43 /^(once_flag|mtx_t|cnd_t|thrd_start_t|thrd_t|tss_dtor_t|tss_t)$/ ||
44 /^(struct|union) __(CODE|ptcb|siginfo|ucontext|sigjmp_buf|double_repr|float_repr|sigset_t|mbstate_t|fsid_t)$/ ||
45 /^(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 "//" }
46 { if (!sub(/ /,",")) sub(/^/,",") }
47 /,(DIR|FILE|void)$/ { print "pp(" $0 ")"; next }
48 { print "p(" $0 ")" }' >>abi.cc