makelintstub revision 1.15
11.1Scgd#!/bin/sh - 21.15Schristos# $NetBSD: makelintstub,v 1.15 2003/09/30 22:30:16 christos 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.14Ssalo# 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.13Sthorpej #include <sys/sa.h> 581.3Sfvdl #include <ufs/ufs/dinode.h> 591.2Sthorpej #include <ufs/lfs/lfs.h> 601.2Sthorpej #include <sys/resource.h> 611.2Sthorpej #include <sys/poll.h> 621.2Sthorpej #include <sys/uio.h> 631.2Sthorpej #include <sys/ipc.h> 641.2Sthorpej #include <sys/msg.h> 651.2Sthorpej #include <sys/sem.h> 661.2Sthorpej #include <sys/shm.h> 671.2Sthorpej #include <sys/timex.h> 681.2Sthorpej #include <sys/socket.h> 691.10Sjdolecek #include <sys/event.h> 701.2Sthorpej #ifdef __STDC__ 711.2Sthorpej #include <stdarg.h> 721.2Sthorpej #else 731.2Sthorpej #include <varargs.h> 741.2Sthorpej #endif 751.2Sthorpej 761.2Sthorpej __EOF__ 771.2Sthorpej} 781.2Sthorpej 791.2Sthorpejsyscall_stub() 801.2Sthorpej{ 811.2Sthorpej 821.4Smycroft syscalldump="$1" 831.2Sthorpej syscallname="$2" 841.2Sthorpej funcname="$3" 851.2Sthorpej 861.4Smycroft arglist="` 871.4Smycroft sed -e 'ta 881.4Smycroft :a 891.9Sthorpej s,^/\* syscall: \"'"$syscallname"'\" ,, 901.4Smycroft tb 911.4Smycroft d 921.4Smycroft :b 931.4Smycroft s, \*/$,,' $syscalldump 941.4Smycroft `" 951.2Sthorpej 961.2Sthorpej eval set -f -- "$arglist" 971.2Sthorpej 981.4Smycroft if [ $# -lt 3 ]; then 991.2Sthorpej echo syscall $syscallname not found! 1>&2 1001.2Sthorpej exit 1 1011.2Sthorpej fi 1021.1Scgd 1031.4Smycroft shift # kill "ret:" 1041.4Smycroft returntype=$1; shift 1051.4Smycroft shift # kill "args:" 1061.2Sthorpej 1071.2Sthorpej cat <<- __EOF__ 1081.2Sthorpej /*ARGSUSED*/ 1091.2Sthorpej $returntype 1101.2Sthorpej __EOF__ 1111.2Sthorpej 1121.2Sthorpej # do ANSI C function header 1131.5Smycroft echo "#ifdef __STDC__" 1141.2Sthorpej 1151.9Sthorpej echo "$funcname(" 1161.5Smycroft first=yes; i=1 1171.5Smycroft for arg; do 1181.5Smycroft if [ $first = yes ]; then 1191.5Smycroft first=no 1201.5Smycroft else 1211.9Sthorpej echo ", " 1221.2Sthorpej fi 1231.5Smycroft case "$arg" in 1241.9Sthorpej "...") echo "...";; 1251.9Sthorpej *) echo "$arg arg$i"; i=$(($i + 1));; 1261.5Smycroft esac 1271.5Smycroft done 1281.9Sthorpej if [ $first = yes ]; then 1291.9Sthorpej echo "void" 1301.9Sthorpej fi 1311.5Smycroft echo ")" 1321.1Scgd 1331.5Smycroft # do K&R C function header 1341.5Smycroft echo "#else" 1351.1Scgd 1361.9Sthorpej echo "$funcname(" 1371.5Smycroft first=yes; i=1 1381.5Smycroft for arg; do 1391.5Smycroft if [ $first = yes ]; then 1401.5Smycroft first=no 1411.5Smycroft else 1421.9Sthorpej echo ", " 1431.2Sthorpej fi 1441.5Smycroft case "$arg" in 1451.9Sthorpej "...") echo "va_alist";; 1461.9Sthorpej *) echo "arg$i"; i=$(($i + 1));; 1471.5Smycroft esac 1481.2Sthorpej done 1491.2Sthorpej echo ")" 1501.2Sthorpej i=1 1511.5Smycroft for arg; do 1521.5Smycroft case "$arg" in 1531.5Smycroft "...") echo " va_dcl";; 1541.5Smycroft *) echo " $arg arg$i;"; i=$(($i + 1));; 1551.5Smycroft esac 1561.2Sthorpej done 1571.1Scgd 1581.2Sthorpej # do function body 1591.5Smycroft echo "#endif" 1601.5Smycroft 1611.2Sthorpej echo "{" 1621.2Sthorpej if [ "$returntype" != "void" ]; then 1631.2Sthorpej echo " return (($returntype)0);" 1641.2Sthorpej fi 1651.2Sthorpej echo "}" 1661.2Sthorpej} 1671.2Sthorpej 1681.2Sthorpejtrailer() 1691.2Sthorpej{ 1701.2Sthorpej 1711.2Sthorpej cat <<- __EOF__ 1721.2Sthorpej /* END */ 1731.2Sthorpej __EOF__ 1741.2Sthorpej} 1751.2Sthorpej 1761.2Sthorpejset -- `getopt no:ps: $*` 1771.2Sthorpej 1781.2Sthorpejpflag=NO 1791.2Sthorpejnflag=NO 1801.2Sthorpejoarg="" 1811.2Sthorpejsyscallhdr=/usr/include/sys/syscall.h 1821.4Smycroftsyscalldump=/tmp/makelintstub.$$ 1831.2Sthorpej 1841.9Sthorpejif test "x${CPP}" = "x"; then 1851.9Sthorpej usage 1861.9Sthorpejfi 1871.9Sthorpej 1881.2Sthorpejif test $? -ne 0; then 1891.2Sthorpej usage 1901.2Sthorpejfi 1911.2Sthorpejfor i; do 1921.2Sthorpej case "$i" in 1931.2Sthorpej -n) nflag=YES; shift;; 1941.2Sthorpej -o) oarg=$2; shift; shift;; 1951.2Sthorpej -p) pflag=YES; shift;; 1961.2Sthorpej -s) syscallhdr=$2; shift; shift;; 1971.2Sthorpej --) shift; break;; 1981.2Sthorpej esac 1991.1Scgddone 2001.1Scgd 2011.2Sthorpejif [ $pflag = YES ] && [ $nflag = YES ]; then 2021.2Sthorpej echo "$0: -n flag and -p flag may not be used together" 2031.2Sthorpej echo "" 2041.2Sthorpej usage 2051.2Sthorpejfi 2061.2Sthorpej 2071.2Sthorpejif [ "X$oarg" != "X" ]; then 2081.2Sthorpej exec > $oarg 2091.2Sthorpejfi 2101.2Sthorpej 2111.4Smycrofttrap "rm -f $syscalldump" 0 1 2 15 2121.4Smycroft 2131.2Sthorpejheader 2141.15Schristosecho "#include \"$syscallhdr\"" | ${CPP} -D_LIBC -C >$syscalldump 2151.2Sthorpejfor syscall; do 2161.8Stv fnname=${syscall%.S} 2171.2Sthorpej if [ $pflag = YES ]; then 2181.4Smycroft scname=${fnname#_} 2191.2Sthorpej else 2201.2Sthorpej scname=$fnname 2211.1Scgd fi 2221.4Smycroft syscall_stub $syscalldump $scname $fnname 2231.2Sthorpej echo "" 2241.1Scgddone 2251.2Sthorpejtrailer 2261.1Scgd 2271.1Scgdexit 0 228