makelintstub revision 1.8
11.1Scgd#!/bin/sh - 21.8Stv# $NetBSD: makelintstub,v 1.8 2001/11/13 18:39:10 tv 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.1Scgd exit 1 411.2Sthorpej} 421.1Scgd 431.2Sthorpejheader() 441.2Sthorpej{ 451.1Scgd 461.2Sthorpej cat <<- __EOF__ 471.2Sthorpej /* 481.2Sthorpej * THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT. 491.2Sthorpej */ 501.2Sthorpej 511.2Sthorpej #include <sys/param.h> 521.2Sthorpej #include <sys/time.h> 531.2Sthorpej #include <sys/mount.h> 541.2Sthorpej #include <sys/stat.h> 551.3Sfvdl #include <ufs/ufs/dinode.h> 561.2Sthorpej #include <ufs/lfs/lfs.h> 571.2Sthorpej #include <sys/resource.h> 581.2Sthorpej #include <sys/poll.h> 591.2Sthorpej #include <sys/uio.h> 601.2Sthorpej #include <sys/ipc.h> 611.2Sthorpej #include <sys/msg.h> 621.2Sthorpej #include <sys/sem.h> 631.2Sthorpej #include <sys/shm.h> 641.2Sthorpej #include <sys/timex.h> 651.2Sthorpej #include <sys/socket.h> 661.2Sthorpej #ifdef __STDC__ 671.2Sthorpej #include <stdarg.h> 681.2Sthorpej #else 691.2Sthorpej #include <varargs.h> 701.2Sthorpej #endif 711.2Sthorpej 721.2Sthorpej __EOF__ 731.2Sthorpej} 741.2Sthorpej 751.2Sthorpejsyscall_stub() 761.2Sthorpej{ 771.2Sthorpej 781.4Smycroft syscalldump="$1" 791.2Sthorpej syscallname="$2" 801.2Sthorpej funcname="$3" 811.2Sthorpej 821.4Smycroft arglist="` 831.4Smycroft sed -e 'ta 841.4Smycroft :a 851.4Smycroft s,^/\* syscall: "'"$syscallname"'" ,, 861.4Smycroft tb 871.4Smycroft d 881.4Smycroft :b 891.4Smycroft s, \*/$,,' $syscalldump 901.4Smycroft `" 911.2Sthorpej 921.2Sthorpej eval set -f -- "$arglist" 931.2Sthorpej 941.4Smycroft if [ $# -lt 3 ]; then 951.2Sthorpej echo syscall $syscallname not found! 1>&2 961.2Sthorpej exit 1 971.2Sthorpej fi 981.1Scgd 991.4Smycroft shift # kill "ret:" 1001.4Smycroft returntype=$1; shift 1011.4Smycroft shift # kill "args:" 1021.2Sthorpej 1031.2Sthorpej cat <<- __EOF__ 1041.2Sthorpej /*ARGSUSED*/ 1051.2Sthorpej $returntype 1061.2Sthorpej __EOF__ 1071.2Sthorpej 1081.2Sthorpej # do ANSI C function header 1091.5Smycroft echo "#ifdef __STDC__" 1101.2Sthorpej 1111.5Smycroft echo -n "$funcname(" 1121.5Smycroft first=yes; i=1 1131.5Smycroft for arg; do 1141.5Smycroft if [ $first = yes ]; then 1151.5Smycroft first=no 1161.5Smycroft else 1171.5Smycroft echo -n ", " 1181.2Sthorpej fi 1191.5Smycroft case "$arg" in 1201.5Smycroft "...") echo -n "...";; 1211.5Smycroft *) echo -n "$arg arg$i"; i=$(($i + 1));; 1221.5Smycroft esac 1231.5Smycroft done 1241.5Smycroft echo ")" 1251.1Scgd 1261.5Smycroft # do K&R C function header 1271.5Smycroft echo "#else" 1281.1Scgd 1291.2Sthorpej echo -n "$funcname(" 1301.5Smycroft first=yes; i=1 1311.5Smycroft for arg; do 1321.5Smycroft if [ $first = yes ]; then 1331.5Smycroft first=no 1341.5Smycroft else 1351.2Sthorpej echo -n ", " 1361.2Sthorpej fi 1371.5Smycroft case "$arg" in 1381.5Smycroft "...") echo -n "va_alist";; 1391.5Smycroft *) echo -n "arg$i"; i=$(($i + 1));; 1401.5Smycroft esac 1411.2Sthorpej done 1421.2Sthorpej echo ")" 1431.2Sthorpej i=1 1441.5Smycroft for arg; do 1451.5Smycroft case "$arg" in 1461.5Smycroft "...") echo " va_dcl";; 1471.5Smycroft *) echo " $arg arg$i;"; i=$(($i + 1));; 1481.5Smycroft esac 1491.2Sthorpej done 1501.1Scgd 1511.2Sthorpej # do function body 1521.5Smycroft echo "#endif" 1531.5Smycroft 1541.2Sthorpej echo "{" 1551.2Sthorpej if [ "$returntype" != "void" ]; then 1561.2Sthorpej echo " return (($returntype)0);" 1571.2Sthorpej fi 1581.2Sthorpej echo "}" 1591.2Sthorpej} 1601.2Sthorpej 1611.2Sthorpejtrailer() 1621.2Sthorpej{ 1631.2Sthorpej 1641.2Sthorpej cat <<- __EOF__ 1651.2Sthorpej /* END */ 1661.2Sthorpej __EOF__ 1671.2Sthorpej} 1681.2Sthorpej 1691.2Sthorpejset -- `getopt no:ps: $*` 1701.2Sthorpej 1711.2Sthorpejpflag=NO 1721.2Sthorpejnflag=NO 1731.2Sthorpejoarg="" 1741.2Sthorpejsyscallhdr=/usr/include/sys/syscall.h 1751.4Smycroftsyscalldump=/tmp/makelintstub.$$ 1761.2Sthorpej 1771.2Sthorpejif test $? -ne 0; then 1781.2Sthorpej usage 1791.2Sthorpejfi 1801.2Sthorpejfor i; do 1811.2Sthorpej case "$i" in 1821.2Sthorpej -n) nflag=YES; shift;; 1831.2Sthorpej -o) oarg=$2; shift; shift;; 1841.2Sthorpej -p) pflag=YES; shift;; 1851.2Sthorpej -s) syscallhdr=$2; shift; shift;; 1861.2Sthorpej --) shift; break;; 1871.2Sthorpej esac 1881.1Scgddone 1891.1Scgd 1901.2Sthorpejif [ $pflag = YES ] && [ $nflag = YES ]; then 1911.2Sthorpej echo "$0: -n flag and -p flag may not be used together" 1921.2Sthorpej echo "" 1931.2Sthorpej usage 1941.2Sthorpejfi 1951.2Sthorpej 1961.2Sthorpejif [ "X$oarg" != "X" ]; then 1971.2Sthorpej exec > $oarg 1981.2Sthorpejfi 1991.2Sthorpej 2001.4Smycrofttrap "rm -f $syscalldump" 0 1 2 15 2011.4Smycroft 2021.2Sthorpejheader 2031.4Smycroftprintf '#include "'"$syscallhdr"'"' | cpp -C >$syscalldump 2041.2Sthorpejfor syscall; do 2051.8Stv fnname=${syscall%.S} 2061.2Sthorpej if [ $pflag = YES ]; then 2071.4Smycroft scname=${fnname#_} 2081.2Sthorpej else 2091.2Sthorpej scname=$fnname 2101.1Scgd fi 2111.4Smycroft syscall_stub $syscalldump $scname $fnname 2121.2Sthorpej echo "" 2131.1Scgddone 2141.2Sthorpejtrailer 2151.1Scgd 2161.1Scgdexit 0 217