update abi_* scripts
[musl-tables] / abi_func.sh
index f110f24..6c6d44a 100755 (executable)
@@ -1,37 +1,23 @@
 #!/bin/sh
 
-#set -xeu
-
 export LC_ALL=C
-#MUSL=${MUSL:-../musl}
 
 awk -F'\t' '$3 ~ /^p$/ {
        print $1
-}' data/musl.tags >/tmp/m.funcs
-awk -F'\t' '$3 ~ /^p$/ {
-       print $2
-}' data/musl.tags >/tmp/m.header
+}' data/musl.generic.decls |sort |uniq >/tmp/m.funcs
 
-echo '#define _GNU_SOURCE 1' >abi_func.cc
-echo '#define _FILE_OFFSET_BITS 64' >>abi_func.cc
-echo '#define SYSLOG_NAMES 1' >>abi_func.cc
-#echo '#include <stddef.h>' >>abi_func.cc
-#echo '#include <sys/types.h>' >>abi_func.cc
-echo '' >>abi_func.cc
+echo '
+#define _GNU_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+' >abi_func.cc
 
-sort /tmp/m.header |uniq |awk '
-#      /^sys\/(auxv|cachectl|fantotify|errno|fcntl|poll|signal|soundcard|termios)\.h$/ { printf "//" }
-#      /^(stdalign|stdnoreturn|threads|wait)\.h$/ { printf "//" }
-#      /^sys\/(cachectl)\.h$/ { printf "//" }
-#      /^(threads)\.h$/ { printf "//" }
-       { print "#include <" $0 ">" }' >>abi_func.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 x_##t(s t* ptr, size(*y)[sizeof(s t*)], align(*z)[__alignof__(s t*)]){}' >>abi.cc
+awk -F'\t' '$3 ~ /^p$/ {
+       if ($2 ~ /^(sys\/(cachectl|io)|threads)\.h$/) next
+       print "#include <" $2 ">"
+}' data/musl.generic.decls |sort |uniq >>abi_func.cc
 
-echo '#define T(x) void t_##x(__typeof(x)*p){}' >>abi_func.cc
 echo '
+#define T(x) void t_##x(__typeof(x)*p){}
 #ifdef __GLIBC__
 #define M(x)
 #undef sigsetjmp
@@ -41,15 +27,13 @@ echo '
 #endif
 ' >>abi_func.cc
 
-sort /tmp/m.funcs |uniq |awk '
-       /^(__flt_rounds|__freadahead|__freadptr|__freadptrinc|__fseterr|_flush_cache|_pthread_cleanup_pop|_pthread_cleanup_push|cachectl|cacheflush|call_once|cnd_broadcast|cnd_destroy|cnd_init|cnd_signal|cnd_timedwait|cnd_wait|fgetln|getdents|gets|index|issetugid|memchr|memrchr|mtx_destroy|mtx_init|mtx_lock|mtx_timedlock|mtx_trylock|mtx_unlock|posix_close|rindex|strcasestr|strchr|strchrnul|strlcat|strlcpy|strpbrk|strrchr|strstr|thrd_create|thrd_current|thrd_detach|thrd_equal|thrd_exit|thrd_join|thrd_sleep|thrd_yield|tss_create|tss_delete|tss_get|tss_set|wcschr|wcspbrk|wcsrchr|wcsstr|wcswcs|wmemchr)$/ {
-               print "M(T(" $0 "))"; next
-       }
-       /^(ElfW)$/ { printf "// " }
-       { print "T(" $0 ")" }' >>abi_func.cc
-
-#$CXX -S -o - abi_func.cc |sed -n 's/^\(_Z.*\):/\1/p' |$CXXFILT |sed '
-#s/(\*)/@/;s/^t_\([^(]*\)(\(.*\)@\(.*\))/\2\1\3/
-#s/floatcomplex /float _Complex/g
-#s/doublecomplex /double _Complex/g
-#' >data/musl.abi_func
+awk '
+/^(_flush_cache|cachectl|cacheflush|iopl|ioperm|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)$/ {
+       print "// "$0; next
+}
+#/^(__flt_rounds|__freadahead|__freadptr|__freadptrinc|__fseterr|_pthread_cleanup_pop|_pthread_cleanup_push|gets|issetugid|posix_close|strlcat|strlcpy)$/
+/^(__flt_rounds|__freadahead|__freadptr|__freadptrinc|__fseterr|_pthread_cleanup_pop|_pthread_cleanup_push|fgetln|getdents|gets|index|issetugid|memchr|memrchr|posix_close|rindex|strcasestr|strchr|strchrnul|strlcat|strlcpy|strpbrk|strrchr|strstr|wcschr|wcspbrk|wcsrchr|wcsstr|wcswcs|wmemchr)$/ {
+       print "M(T(" $0 "))"; next
+}
+/^(ElfW)$/ { printf "// " }
+{ print "T(" $0 ")" }' /tmp/m.funcs >>abi_func.cc