makelintstub revision 1.12
11.1Scgd#!/bin/sh - 21.12Sthorpej# $NetBSD: makelintstub,v 1.12 2002/11/11 00:54:57 thorpej Exp $ 31.1Scgd# 41.7Scgd# Copyright (c) 1996, 1997 Christopher G. Demetriou 51.7Scgd# All rights reserved. 61.7Scgd# 71.1Scgd# Redistribution and use in source and binary forms, with or without 81.1Scgd# modification, are permitted provided that the following conditions 91.1Scgd# are met: 101.1Scgd# 1. Redistributions of source code must retain the above copyright 111.1Scgd# notice, this list of conditions and the following disclaimer. 121.1Scgd# 2. Redistributions in binary form must reproduce the above copyright 131.1Scgd# notice, this list of conditions and the following disclaimer in the 141.1Scgd# documentation and/or other materials provided with the distribution. 151.1Scgd# 3. All advertising materials mentioning features or use of this software 161.1Scgd# must display the following acknowledgement: 171.7Scgd# This product includes software developed for the 181.7Scgd# NetBSD Project. See http://www.netbsd.org/ for 191.7Scgd# information about NetBSD. 201.1Scgd# 4. The name of the author may not be used to endorse or promote products 211.7Scgd# derived from this software without specific prior written permission. 221.7Scgd# 231.1Scgd# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 241.1Scgd# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 251.1Scgd# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 261.1Scgd# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 271.1Scgd# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 281.1Scgd# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 291.1Scgd# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 301.1Scgd# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 311.1Scgd# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 321.1Scgd# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 331.7Scgd# 341.7Scgd# <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>> 351.1Scgd 361.2Sthorpejusage() 371.2Sthorpej{ 381.2Sthorpej 391.2Sthorpej echo "usage: $0 [-n|-p] [-o filename] object ..." 401.9Sthorpej echo " The CPP environment variable must be set" 411.9Sthorpej echo " to the path to the C preprocessor." 421.1Scgd exit 1 431.2Sthorpej} 441.1Scgd 451.2Sthorpejheader() 461.2Sthorpej{ 471.1Scgd 481.2Sthorpej cat <<- __EOF__ 491.2Sthorpej /* 501.2Sthorpej * THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT. 511.2Sthorpej */ 521.2Sthorpej 531.2Sthorpej #include <sys/param.h> 541.2Sthorpej #include <sys/time.h> 551.2Sthorpej #include <sys/mount.h> 561.2Sthorpej #include <sys/stat.h> 571.3Sfvdl #include <ufs/ufs/dinode.h> 581.2Sthorpej #include <ufs/lfs/lfs.h> 591.2Sthorpej #include <sys/resource.h> 601.2Sthorpej #include <sys/poll.h> 611.2Sthorpej #include <sys/uio.h> 621.2Sthorpej #include <sys/ipc.h> 631.2Sthorpej #include <sys/msg.h> 641.2Sthorpej #include <sys/sem.h> 651.2Sthorpej #include <sys/shm.h> 661.2Sthorpej #include <sys/timex.h> 671.2Sthorpej #include <sys/socket.h> 681.10Sjdolecek #include <sys/event.h> 691.2Sthorpej #ifdef __STDC__ 701.2Sthorpej #include <stdarg.h> 711.2Sthorpej #else 721.2Sthorpej #include <varargs.h> 731.2Sthorpej #endif 741.2Sthorpej 751.2Sthorpej __EOF__ 761.2Sthorpej} 771.2Sthorpej 781.2Sthorpejsyscall_stub() 791.2Sthorpej{ 801.2Sthorpej 811.4Smycroft syscalldump="$1" 821.2Sthorpej syscallname="$2" 831.2Sthorpej funcname="$3" 841.2Sthorpej 851.4Smycroft arglist="` 861.4Smycroft sed -e 'ta 871.4Smycroft :a 881.9Sthorpej s,^/\* syscall: \"'"$syscallname"'\" ,, 891.4Smycroft tb 901.4Smycroft d 911.4Smycroft :b 921.4Smycroft s, \*/$,,' $syscalldump 931.4Smycroft `" 941.2Sthorpej 951.2Sthorpej eval set -f -- "$arglist" 961.2Sthorpej 971.4Smycroft if [ $# -lt 3 ]; then 981.2Sthorpej echo syscall $syscallname not found! 1>&2 991.2Sthorpej exit 1 1001.2Sthorpej fi 1011.1Scgd 1021.4Smycroft shift # kill "ret:" 1031.4Smycroft returntype=$1; shift 1041.4Smycroft shift # kill "args:" 1051.2Sthorpej 1061.2Sthorpej cat <<- __EOF__ 1071.2Sthorpej /*ARGSUSED*/ 1081.2Sthorpej $returntype 1091.2Sthorpej __EOF__ 1101.2Sthorpej 1111.2Sthorpej # do ANSI C function header 1121.5Smycroft echo "#ifdef __STDC__" 1131.2Sthorpej 1141.9Sthorpej echo "$funcname(" 1151.5Smycroft first=yes; i=1 1161.5Smycroft for arg; do 1171.5Smycroft if [ $first = yes ]; then 1181.5Smycroft first=no 1191.5Smycroft else 1201.9Sthorpej echo ", " 1211.2Sthorpej fi 1221.5Smycroft case "$arg" in 1231.9Sthorpej "...") echo "...";; 1241.9Sthorpej *) echo "$arg arg$i"; i=$(($i + 1));; 1251.5Smycroft esac 1261.5Smycroft done 1271.9Sthorpej if [ $first = yes ]; then 1281.9Sthorpej echo "void" 1291.9Sthorpej fi 1301.5Smycroft echo ")" 1311.1Scgd 1321.5Smycroft # do K&R C function header 1331.5Smycroft echo "#else" 1341.1Scgd 1351.9Sthorpej echo "$funcname(" 1361.5Smycroft first=yes; i=1 1371.5Smycroft for arg; do 1381.5Smycroft if [ $first = yes ]; then 1391.5Smycroft first=no 1401.5Smycroft else 1411.9Sthorpej echo ", " 1421.2Sthorpej fi 1431.5Smycroft case "$arg" in 1441.9Sthorpej "...") echo "va_alist";; 1451.9Sthorpej *) echo "arg$i"; i=$(($i + 1));; 1461.5Smycroft esac 1471.2Sthorpej done 1481.2Sthorpej echo ")" 1491.2Sthorpej i=1 1501.5Smycroft for arg; do 1511.5Smycroft case "$arg" in 1521.5Smycroft "...") echo " va_dcl";; 1531.5Smycroft *) echo " $arg arg$i;"; i=$(($i + 1));; 1541.5Smycroft esac 1551.2Sthorpej done 1561.1Scgd 1571.2Sthorpej # do function body 1581.5Smycroft echo "#endif" 1591.5Smycroft 1601.2Sthorpej echo "{" 1611.2Sthorpej if [ "$returntype" != "void" ]; then 1621.2Sthorpej echo " return (($returntype)0);" 1631.2Sthorpej fi 1641.2Sthorpej echo "}" 1651.2Sthorpej} 1661.2Sthorpej 1671.2Sthorpejtrailer() 1681.2Sthorpej{ 1691.2Sthorpej 1701.2Sthorpej cat <<- __EOF__ 1711.2Sthorpej /* END */ 1721.2Sthorpej __EOF__ 1731.2Sthorpej} 1741.2Sthorpej 1751.2Sthorpejset -- `getopt no:ps: $*` 1761.2Sthorpej 1771.2Sthorpejpflag=NO 1781.2Sthorpejnflag=NO 1791.2Sthorpejoarg="" 1801.2Sthorpejsyscallhdr=/usr/include/sys/syscall.h 1811.4Smycroftsyscalldump=/tmp/makelintstub.$$ 1821.2Sthorpej 1831.9Sthorpejif test "x${CPP}" = "x"; then 1841.9Sthorpej usage 1851.9Sthorpejfi 1861.9Sthorpej 1871.2Sthorpejif test $? -ne 0; then 1881.2Sthorpej usage 1891.2Sthorpejfi 1901.2Sthorpejfor i; do 1911.2Sthorpej case "$i" in 1921.2Sthorpej -n) nflag=YES; shift;; 1931.2Sthorpej -o) oarg=$2; shift; shift;; 1941.2Sthorpej -p) pflag=YES; shift;; 1951.2Sthorpej -s) syscallhdr=$2; shift; shift;; 1961.2Sthorpej --) shift; break;; 1971.2Sthorpej esac 1981.1Scgddone 1991.1Scgd 2001.2Sthorpejif [ $pflag = YES ] && [ $nflag = YES ]; then 2011.2Sthorpej echo "$0: -n flag and -p flag may not be used together" 2021.2Sthorpej echo "" 2031.2Sthorpej usage 2041.2Sthorpejfi 2051.2Sthorpej 2061.2Sthorpejif [ "X$oarg" != "X" ]; then 2071.2Sthorpej exec > $oarg 2081.2Sthorpejfi 2091.2Sthorpej 2101.4Smycrofttrap "rm -f $syscalldump" 0 1 2 15 2111.4Smycroft 2121.2Sthorpejheader 2131.12Sthorpejecho "#include \"$syscallhdr\"" | ${CPP} -C >$syscalldump 2141.2Sthorpejfor syscall; do 2151.8Stv fnname=${syscall%.S} 2161.2Sthorpej if [ $pflag = YES ]; then 2171.4Smycroft scname=${fnname#_} 2181.2Sthorpej else 2191.2Sthorpej scname=$fnname 2201.1Scgd fi 2211.4Smycroft syscall_stub $syscalldump $scname $fnname 2221.2Sthorpej echo "" 2231.1Scgddone 2241.2Sthorpejtrailer 2251.1Scgd 2261.1Scgdexit 0 227