1248693Sgleb#! /bin/sh - 2248693Sgleb# 3248693Sgleb# $FreeBSD: releng/10.2/tools/tools/shlib-compat/makesyscalls-fake.sh 248693 2013-03-25 00:31:14Z gleb $ 4248693Sgleb 5248693Sglebset -e 6248693Sgleb 7248693Sglebcase $# in 8248693Sgleb 0) echo "usage: $0 input-file <config-file>" 1>&2 9248693Sgleb exit 1 10248693Sgleb ;; 11248693Sglebesac 12248693Sgleb 13248693Sglebif [ -n "$2" -a -f "$2" ]; then 14248693Sgleb . $2 15248693Sglebfi 16248693Sgleb 17248693Sglebsed -e ' 18248693Sglebs/\$//g 19248693Sgleb:join 20248693Sgleb /\\$/{a\ 21248693Sgleb 22248693Sgleb N 23248693Sgleb s/\\\n// 24248693Sgleb b join 25248693Sgleb } 26248693Sgleb2,${ 27248693Sgleb /^#/!s/\([{}()*,]\)/ \1 /g 28248693Sgleb} 29248693Sgleb' < $1 | awk ' 30248693Sgleb BEGIN { 31248693Sgleb printf "#include <sys/param.h>\n" 32248693Sgleb printf "#include <machine/atomic.h>\n" 33248693Sgleb printf "\n" 34248693Sgleb printf "#include <sys/_semaphore.h>\n" 35248693Sgleb printf "#include <sys/aio.h>\n" 36248693Sgleb printf "#include <sys/cpuset.h>\n" 37248693Sgleb printf "#include <sys/jail.h>\n" 38248693Sgleb printf "#include <sys/linker.h>\n" 39248693Sgleb printf "#include <sys/mac.h>\n" 40248693Sgleb printf "#include <sys/module.h>\n" 41248693Sgleb printf "#include <sys/mount.h>\n" 42248693Sgleb printf "#include <sys/mqueue.h>\n" 43248693Sgleb printf "#include <sys/msg.h>\n" 44248693Sgleb printf "#include <sys/poll.h>\n" 45248693Sgleb printf "#include <sys/proc.h>\n" 46248693Sgleb printf "#include <sys/resource.h>\n" 47248693Sgleb printf "#include <sys/sem.h>\n" 48248693Sgleb printf "#include <sys/shm.h>\n" 49248693Sgleb printf "#include <sys/signal.h>\n" 50248693Sgleb printf "#include <sys/signalvar.h>\n" 51248693Sgleb printf "#include <sys/socket.h>\n" 52248693Sgleb printf "#include <sys/stat.h>\n" 53248693Sgleb printf "#include <sys/thr.h>\n" 54248693Sgleb printf "#include <sys/time.h>\n" 55248693Sgleb printf "#include <sys/timex.h>\n" 56248693Sgleb printf "#include <sys/timeffc.h>\n" 57248693Sgleb printf "#include <sys/ucontext.h>\n" 58248693Sgleb printf "#include <sys/utsname.h>\n" 59248693Sgleb printf "#include <sys/uuid.h>\n" 60248693Sgleb printf "#include <sys/wait.h>\n" 61248693Sgleb printf "\n" 62248693Sgleb printf "#ifndef _ACL_PRIVATE\n" 63248693Sgleb printf "#define _ACL_PRIVATE\n" 64248693Sgleb printf "#endif\n" 65248693Sgleb printf "#include <sys/acl.h>\n" 66248693Sgleb printf "\n" 67248693Sgleb printf "#ifndef EBUSY\n" 68248693Sgleb printf "#define errno 0\n" 69248693Sgleb printf "#define EBUSY 0\n" 70248693Sgleb printf "#endif\n" 71248693Sgleb printf "#include <sys/umtx.h>\n" 72248693Sgleb printf "\n" 73248693Sgleb # existing compat shims 74248693Sgleb printf "struct ostat;\n" 75248693Sgleb printf "struct nstat;\n" 76248693Sgleb printf "struct ostatfs;\n" 77248693Sgleb printf "struct osigaction;\n" 78248693Sgleb printf "struct osigcontext;\n" 79248693Sgleb printf "struct oaiocb;\n" 80248693Sgleb printf "union semun_old;\n" 81248693Sgleb printf "typedef unsigned int osigset_t;\n" 82248693Sgleb printf "struct msqid_ds_old;\n" 83248693Sgleb printf "struct shmid_ds_old;\n" 84248693Sgleb # TODO 85248693Sgleb printf "struct ucontext4;\n" 86248693Sgleb printf "struct sctp_sndrcvinfo;\n" 87248693Sgleb printf "\n" 88248693Sgleb } 89248693Sgleb NF < 4 || $1 !~ /^[0-9]+$/ { 90248693Sgleb next 91248693Sgleb } 92248693Sgleb $3 ~ "UNIMPL" || $3 ~ "OBSOL" || $3 ~ "NODEF" || $3 ~ "NOPROTO" || 93248693Sgleb $3 ~ "NOSTD"{ 94248693Sgleb next 95248693Sgleb } 96248693Sgleb $4 == "{" { 97248693Sgleb if ($3 ~ /COMPAT[0-9]*/) { 98248693Sgleb n = split($3, flags, /\|/) 99248693Sgleb for (i = 1; i <= n; i++) { 100248693Sgleb if (flags[i] == "COMPAT") { 101248693Sgleb $6 = "o" $6 102248693Sgleb } else if (flags[i] ~ /COMPAT[0-9]+/) { 103248693Sgleb sub(/COMPAT/, "freebsd", flags[i]) 104248693Sgleb $6 = flags[i] "_" $6 105248693Sgleb } 106248693Sgleb } 107248693Sgleb } 108248693Sgleb $6 = "__sysfake_" $6 109248693Sgleb r = "" 110248693Sgleb if ($5 != "void") 111248693Sgleb r = "0" 112248693Sgleb def = "" 113248693Sgleb impl = "" 114248693Sgleb for ( i = 5; i <= NF; i++) { 115248693Sgleb if ($i == ";") 116248693Sgleb break; 117248693Sgleb if ($i == "," || $i == ")") 118248693Sgleb impl = impl " __unused" 119248693Sgleb impl = impl " " $i 120248693Sgleb def = def " " $i 121248693Sgleb } 122248693Sgleb printf "%s;\n", def 123248693Sgleb printf "%s\n{ return %s; }\n", impl, r 124248693Sgleb next 125248693Sgleb } 126248693Sgleb { 127248693Sgleb printf "invalid line: " 128248693Sgleb print 129248693Sgleb } 130248693Sgleb' 131