update makefile
[musl-tables] / abi_func.sh
1 #!/bin/sh
2
3 export LC_ALL=C
4
5 awk -F'\t' '$3 ~ /^p$/ {
6         print $1
7 }' data/musl.generic.decls |sort |uniq >/tmp/m.funcs
8
9 echo '
10 #define _GNU_SOURCE 1
11 #define _FILE_OFFSET_BITS 64
12 ' >abi_func.cc
13
14 awk -F'\t' '$3 ~ /^p$/ {print $2}' data/musl.generic.decls |sort |uniq |awk '
15 /^sys\/io\.h$/ {print "// #include <"$0">"; next}
16 {
17         w = $0 ~ /^(sys\/cachectl|threads)\.h$/
18         if(w) print "#ifndef __GLIBC__"
19         print "#include <" $0 ">"
20         if(w) print "#endif"
21 }' >>abi_func.cc
22
23 echo '
24 #define T(x) void t_##x(__typeof(x)*p){}
25 #ifdef __GLIBC__
26 #define M(x)
27 #undef sigsetjmp
28 #define sigsetjmp __sigsetjmp
29 #else
30 #define M(x) x
31 #endif
32 ' >>abi_func.cc
33
34 awk '
35 # non-portable or ctags mistake
36 /^(iopl|ioperm|ElfW)$/ {
37         print "// "$0; next
38 }
39 # polymorphic in glibc
40 /^(index|memchr|memrchr|rindex|strcasestr|strchr|strchrnul|strlcat|strlcpy|strpbrk|strrchr|strstr|wcschr|wcspbrk|wcsrchr|wcsstr|wcswcs|wmemchr)$/ ||
41 # musl only
42 /^(__flt_rounds|__freadahead|__freadptr|__freadptrinc|__fseterr|_pthread_cleanup_pop|_pthread_cleanup_push|fgetln|getdents|gets|issetugid|posix_close)$/ ||
43 /^(_flush_cache|cachectl|cacheflush)$/ ||
44 /^(call_once|cnd_broadcast|cnd_destroy|cnd_init|cnd_signal|cnd_timedwait|cnd_wait|mtx_destroy|mtx_init|mtx_lock|mtx_timedlock|mtx_trylock|mtx_unlock|thrd_create|thrd_current|thrd_detach|thrd_equal|thrd_exit|thrd_join|thrd_sleep|thrd_yield|tss_create|tss_delete|tss_get|tss_set)$/ {
45         print "M(T(" $0 "))"; next
46 }
47 { print "T(" $0 ")" }' /tmp/m.funcs >>abi_func.cc