v1.1.14 update
[musl-tables] / abi_type.sh
1 #!/bin/sh
2
3 export LC_ALL=C
4
5 ALL='
6 aarch64
7 arm
8 i386
9 microblaze
10 mips
11 or1k
12 powerpc
13 sh
14 x32
15 x86_64
16 '
17 ARCH="${ARCH:-$ALL}"
18
19 # install headers to T.$arch
20 for arch in $ARCH
21 do
22
23 {
24 awk -F'\t' '$3 ~ /^[sutSUT]$/ {
25         print $1
26 }' data/musl.generic.decls data/musl.$arch.decls
27 echo 'function_pointer
28 object_pointer
29 char
30 short
31 int
32 long
33 long_long
34 float
35 double
36 long_double
37 wchar_t
38 bool'
39 } |sort |uniq >/tmp/m.$arch.type
40
41 awk -F'\t' '{print $2}' data/musl.generic.decls |sort |uniq >/tmp/m.header
42
43 echo '
44 #define _GNU_SOURCE 1
45 #define _FILE_OFFSET_BITS 64
46 #define SYSLOG_NAMES 1
47 #include <stddef.h>
48 #include <sys/types.h>
49 ' >abi_type.$arch.cc
50
51 awk '
52 /^sys\/(cachectl|fantotify|errno|fcntl|io|kd|poll|reg|signal|soundcard|termios|vt)\.h$/ { printf "//" }
53 /^(wait)\.h$/ { printf "//" }
54 { w=0 }
55 /^(stdalign|stdnoreturn|threads)\.h$/ { w=1 }
56 {
57         if(w) print "#ifndef __GLIBC__"
58         print "#include <" $0 ">"
59         if(w) print "#endif"
60 }' /tmp/m.header >>abi_type.$arch.cc
61
62 echo '
63 typedef long long long_long;
64 typedef long double long_double;
65 typedef void *object_pointer;
66 typedef void (*function_pointer)();
67 struct size {char c;};
68 struct align {char c;};
69 struct incomplete {char c;};
70 #define T(s,t) void x_##t(s t x, s t* ptr, size(*y)[sizeof(s t)], align(*z)[__alignof__(s t)]){}
71 #define P(s,t) void x_##t(incomplete x, s t* ptr, incomplete y, incomplete z){}
72 #ifdef __GLIBC__
73 #define M(x)
74 #else
75 #define M(x) x
76 #endif
77 ' >>abi_type.$arch.cc
78
79 awk '
80 /^(struct|union) __(CODE|ptcb|siginfo|ucontext|sigjmp_buf|double_repr|float_repr|sigset_t|mbstate_t|fsid_t|locale_struct)$/ ||
81 /^(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 "//" }
82 { if (!sub(/ /,",")) sub(/^/,",") }
83 /,(once_flag|mtx_t|cnd_t|thrd_start_t|thrd_t|tss_dtor_t|tss_t)$/ { print "M(T(" $0 "))"; next}
84 /,(DIR|FILE)$/ { print "P(" $0 ")"; next }
85 { print "T(" $0 ")" }' /tmp/m.$arch.type >>abi_type.$arch.cc
86 done
87
88 #$CXX -S -o - abi_type.cc |sed -n 's/^\(_Z.*\):/\1/p' |$CXXFILT |sed '
89 #s/^x_\([^(]*\)(\(.*\))/\1: \2/
90 #s/floatcomplex /float _Complex/g
91 #s/doublecomplex /double _Complex/g
92 #' >data/musl.abi_type