makelintstub revision 1.9
11.1Scgd#!/bin/sh - 21.9Sthorpej# $NetBSD: makelintstub,v 1.9 2002/09/14 03:14:15 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.2Sthorpej #ifdef __STDC__ 691.2Sthorpej #include <stdarg.h> 701.2Sthorpej #else 711.2Sthorpej #include <varargs.h> 721.2Sthorpej #endif 731.2Sthorpej 741.2Sthorpej __EOF__ 751.2Sthorpej} 761.2Sthorpej 771.2Sthorpejsyscall_stub() 781.2Sthorpej{ 791.2Sthorpej 801.4Smycroft syscalldump="$1" 811.2Sthorpej syscallname="$2" 821.2Sthorpej funcname="$3" 831.2Sthorpej 841.4Smycroft arglist="` 851.4Smycroft sed -e 'ta 861.4Smycroft :a 871.9Sthorpej s,^/\* syscall: \"'"$syscallname"'\" ,, 881.4Smycroft tb 891.4Smycroft d 901.4Smycroft :b 911.4Smycroft s, \*/$,,' $syscalldump 921.4Smycroft `" 931.2Sthorpej 941.2Sthorpej eval set -f -- "$arglist" 951.2Sthorpej 961.4Smycroft if [ $# -lt 3 ]; then 971.2Sthorpej echo syscall $syscallname not found! 1>&2 981.2Sthorpej exit 1 991.2Sthorpej fi 1001.1Scgd 1011.4Smycroft shift # kill "ret:" 1021.4Smycroft returntype=$1; shift 1031.4Smycroft shift # kill "args:" 1041.2Sthorpej 1051.2Sthorpej cat <<- __EOF__ 1061.2Sthorpej /*ARGSUSED*/ 1071.2Sthorpej $returntype 1081.2Sthorpej __EOF__ 1091.2Sthorpej 1101.2Sthorpej # do ANSI C function header 1111.5Smycroft echo "#ifdef __STDC__" 1121.2Sthorpej 1131.9Sthorpej echo "$funcname(" 1141.5Smycroft first=yes; i=1 1151.5Smycroft for arg; do 1161.5Smycroft if [ $first = yes ]; then 1171.5Smycroft first=no 1181.5Smycroft else 1191.9Sthorpej echo ", " 1201.2Sthorpej fi 1211.5Smycroft case "$arg" in 1221.9Sthorpej "...") echo "...";; 1231.9Sthorpej *) echo "$arg arg$i"; i=$(($i + 1));; 1241.5Smycroft esac 1251.5Smycroft done 1261.9Sthorpej if [ $first = yes ]; then 1271.9Sthorpej echo "void" 1281.9Sthorpej fi 1291.5Smycroft echo ")" 1301.1Scgd 1311.5Smycroft # do K&R C function header 1321.5Smycroft echo "#else" 1331.1Scgd 1341.9Sthorpej echo "$funcname(" 1351.5Smycroft first=yes; i=1 1361.5Smycroft for arg; do 1371.5Smycroft if [ $first = yes ]; then 1381.5Smycroft first=no 1391.5Smycroft else 1401.9Sthorpej echo ", " 1411.2Sthorpej fi 1421.5Smycroft case "$arg" in 1431.9Sthorpej "...") echo "va_alist";; 1441.9Sthorpej *) echo "arg$i"; i=$(($i + 1));; 1451.5Smycroft esac 1461.2Sthorpej done 1471.2Sthorpej echo ")" 1481.2Sthorpej i=1 1491.5Smycroft for arg; do 1501.5Smycroft case "$arg" in 1511.5Smycroft "...") echo " va_dcl";; 1521.5Smycroft *) echo " $arg arg$i;"; i=$(($i + 1));; 1531.5Smycroft esac 1541.2Sthorpej done 1551.1Scgd 1561.2Sthorpej # do function body 1571.5Smycroft echo "#endif" 1581.5Smycroft 1591.2Sthorpej echo "{" 1601.2Sthorpej if [ "$returntype" != "void" ]; then 1611.2Sthorpej echo " return (($returntype)0);" 1621.2Sthorpej fi 1631.2Sthorpej echo "}" 1641.2Sthorpej} 1651.2Sthorpej 1661.2Sthorpejtrailer() 1671.2Sthorpej{ 1681.2Sthorpej 1691.2Sthorpej cat <<- __EOF__ 1701.2Sthorpej /* END */ 1711.2Sthorpej __EOF__ 1721.2Sthorpej} 1731.2Sthorpej 1741.2Sthorpejset -- `getopt no:ps: $*` 1751.2Sthorpej 1761.2Sthorpejpflag=NO 1771.2Sthorpejnflag=NO 1781.2Sthorpejoarg="" 1791.2Sthorpejsyscallhdr=/usr/include/sys/syscall.h 1801.4Smycroftsyscalldump=/tmp/makelintstub.$$ 1811.2Sthorpej 1821.9Sthorpejif test "x${CPP}" = "x"; then 1831.9Sthorpej usage 1841.9Sthorpejfi 1851.9Sthorpej 1861.2Sthorpejif test $? -ne 0; then 1871.2Sthorpej usage 1881.2Sthorpejfi 1891.2Sthorpejfor i; do 1901.2Sthorpej case "$i" in 1911.2Sthorpej -n) nflag=YES; shift;; 1921.2Sthorpej -o) oarg=$2; shift; shift;; 1931.2Sthorpej -p) pflag=YES; shift;; 1941.2Sthorpej -s) syscallhdr=$2; shift; shift;; 1951.2Sthorpej --) shift; break;; 1961.2Sthorpej esac 1971.1Scgddone 1981.1Scgd 1991.2Sthorpejif [ $pflag = YES ] && [ $nflag = YES ]; then 2001.2Sthorpej echo "$0: -n flag and -p flag may not be used together" 2011.2Sthorpej echo "" 2021.2Sthorpej usage 2031.2Sthorpejfi 2041.2Sthorpej 2051.2Sthorpejif [ "X$oarg" != "X" ]; then 2061.2Sthorpej exec > $oarg 2071.2Sthorpejfi 2081.2Sthorpej 2091.4Smycrofttrap "rm -f $syscalldump" 0 1 2 15 2101.4Smycroft 2111.2Sthorpejheader 2121.9Sthorpejprintf '#include "'"$syscallhdr"'"' | ${CPP} -C >$syscalldump 2131.2Sthorpejfor syscall; do 2141.8Stv fnname=${syscall%.S} 2151.2Sthorpej if [ $pflag = YES ]; then 2161.4Smycroft scname=${fnname#_} 2171.2Sthorpej else 2181.2Sthorpej scname=$fnname 2191.1Scgd fi 2201.4Smycroft syscall_stub $syscalldump $scname $fnname 2211.2Sthorpej echo "" 2221.1Scgddone 2231.2Sthorpejtrailer 2241.1Scgd 2251.1Scgdexit 0 226