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