makelintstub revision 1.17
11.1Scgd#!/bin/sh - 21.17Schristos# $NetBSD: makelintstub,v 1.17 2006/06/18 14:28:12 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.17Schristoscat << _EOF 1>&2 401.17SchristosUsage: $PROG [-n|-p] [-o filename] object ... 411.17Schristos The CPP environment variable must be set 421.17Schristos to the path to the C preprocessor. 431.17Schristos_EOF 441.1Scgd exit 1 451.2Sthorpej} 461.1Scgd 471.2Sthorpejheader() 481.2Sthorpej{ 491.1Scgd 501.2Sthorpej cat <<- __EOF__ 511.2Sthorpej /* 521.2Sthorpej * THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT. 531.2Sthorpej */ 541.2Sthorpej 551.2Sthorpej #include <sys/param.h> 561.2Sthorpej #include <sys/time.h> 571.2Sthorpej #include <sys/mount.h> 581.2Sthorpej #include <sys/stat.h> 591.13Sthorpej #include <sys/sa.h> 601.3Sfvdl #include <ufs/ufs/dinode.h> 611.2Sthorpej #include <ufs/lfs/lfs.h> 621.2Sthorpej #include <sys/resource.h> 631.2Sthorpej #include <sys/poll.h> 641.2Sthorpej #include <sys/uio.h> 651.2Sthorpej #include <sys/ipc.h> 661.2Sthorpej #include <sys/msg.h> 671.2Sthorpej #include <sys/sem.h> 681.2Sthorpej #include <sys/shm.h> 691.2Sthorpej #include <sys/timex.h> 701.2Sthorpej #include <sys/socket.h> 711.10Sjdolecek #include <sys/event.h> 721.16Stsarna #include <sys/uuid.h> 731.2Sthorpej #ifdef __STDC__ 741.2Sthorpej #include <stdarg.h> 751.2Sthorpej #else 761.2Sthorpej #include <varargs.h> 771.2Sthorpej #endif 781.2Sthorpej 791.2Sthorpej __EOF__ 801.2Sthorpej} 811.2Sthorpej 821.2Sthorpejsyscall_stub() 831.2Sthorpej{ 841.2Sthorpej 851.4Smycroft syscalldump="$1" 861.2Sthorpej syscallname="$2" 871.2Sthorpej funcname="$3" 881.2Sthorpej 891.17Schristos arglist="$( 901.4Smycroft sed -e 'ta 911.4Smycroft :a 921.9Sthorpej s,^/\* syscall: \"'"$syscallname"'\" ,, 931.4Smycroft tb 941.4Smycroft d 951.4Smycroft :b 961.4Smycroft s, \*/$,,' $syscalldump 971.17Schristos )" 981.2Sthorpej 991.2Sthorpej eval set -f -- "$arglist" 1001.2Sthorpej 1011.4Smycroft if [ $# -lt 3 ]; then 1021.2Sthorpej echo syscall $syscallname not found! 1>&2 1031.2Sthorpej exit 1 1041.2Sthorpej fi 1051.1Scgd 1061.4Smycroft shift # kill "ret:" 1071.4Smycroft returntype=$1; shift 1081.4Smycroft shift # kill "args:" 1091.2Sthorpej 1101.2Sthorpej cat <<- __EOF__ 1111.2Sthorpej /*ARGSUSED*/ 1121.2Sthorpej $returntype 1131.2Sthorpej __EOF__ 1141.2Sthorpej 1151.2Sthorpej # do ANSI C function header 1161.5Smycroft echo "#ifdef __STDC__" 1171.2Sthorpej 1181.9Sthorpej echo "$funcname(" 1191.17Schristos first=true; i=1 1201.5Smycroft for arg; do 1211.17Schristos if $first; then 1221.17Schristos first=false 1231.5Smycroft else 1241.9Sthorpej echo ", " 1251.2Sthorpej fi 1261.5Smycroft case "$arg" in 1271.9Sthorpej "...") echo "...";; 1281.9Sthorpej *) echo "$arg arg$i"; i=$(($i + 1));; 1291.5Smycroft esac 1301.5Smycroft done 1311.17Schristos if $first; then 1321.9Sthorpej echo "void" 1331.9Sthorpej fi 1341.5Smycroft echo ")" 1351.1Scgd 1361.5Smycroft # do K&R C function header 1371.5Smycroft echo "#else" 1381.1Scgd 1391.9Sthorpej echo "$funcname(" 1401.17Schristos first=true; i=1 1411.5Smycroft for arg; do 1421.17Schristos if $first; then 1431.17Schristos first=false 1441.5Smycroft else 1451.9Sthorpej echo ", " 1461.2Sthorpej fi 1471.5Smycroft case "$arg" in 1481.9Sthorpej "...") echo "va_alist";; 1491.9Sthorpej *) echo "arg$i"; i=$(($i + 1));; 1501.5Smycroft esac 1511.2Sthorpej done 1521.2Sthorpej echo ")" 1531.2Sthorpej i=1 1541.5Smycroft for arg; do 1551.5Smycroft case "$arg" in 1561.5Smycroft "...") echo " va_dcl";; 1571.5Smycroft *) echo " $arg arg$i;"; i=$(($i + 1));; 1581.5Smycroft esac 1591.2Sthorpej done 1601.1Scgd 1611.2Sthorpej # do function body 1621.5Smycroft echo "#endif" 1631.5Smycroft 1641.2Sthorpej echo "{" 1651.2Sthorpej if [ "$returntype" != "void" ]; then 1661.2Sthorpej echo " return (($returntype)0);" 1671.2Sthorpej fi 1681.2Sthorpej echo "}" 1691.2Sthorpej} 1701.2Sthorpej 1711.2Sthorpejtrailer() 1721.2Sthorpej{ 1731.2Sthorpej 1741.2Sthorpej cat <<- __EOF__ 1751.2Sthorpej /* END */ 1761.2Sthorpej __EOF__ 1771.2Sthorpej} 1781.2Sthorpej 1791.2Sthorpej 1801.17Schristospflag=false 1811.17Schristosnflag=false 1821.2Sthorpejoarg="" 1831.2Sthorpejsyscallhdr=/usr/include/sys/syscall.h 1841.4Smycroftsyscalldump=/tmp/makelintstub.$$ 1851.17SchristosPROG="$(basename "$0")" 1861.2Sthorpej 1871.17Schristosif [ -z "${CPP}" ]; then 1881.9Sthorpej usage 1891.9Sthorpejfi 1901.9Sthorpej 1911.17Schristoswhile getopts no:ps: i 1921.17Schristosdo 1931.2Sthorpej case "$i" in 1941.17Schristos n) nflag=true;; 1951.17Schristos o) oarg=$OPTARG;; 1961.17Schristos p) pflag=true;; 1971.17Schristos s) syscallhdr=$OPTARG;; 1981.17Schristos *) usage;; 1991.2Sthorpej esac 2001.1Scgddone 2011.1Scgd 2021.17Schristosshift $(expr $OPTIND - 1) 2031.17Schristos 2041.17Schristosif $pflag && $nflag 2051.17Schristosthen 2061.17Schristos echo "$PROG: -n flag and -p flag may not be used together" 1>&2 2071.2Sthorpej usage 2081.2Sthorpejfi 2091.2Sthorpej 2101.17Schristosif [ -n "$oarg" ]; then 2111.2Sthorpej exec > $oarg 2121.2Sthorpejfi 2131.2Sthorpej 2141.17Schristostrap "rm -f $syscalldump" 0 1 2 3 15 2151.4Smycroft 2161.2Sthorpejheader 2171.17Schristos 2181.17Schristosecho "#include \"$syscallhdr\"" | ${CPP} -D_LIBC -C > $syscalldump 2191.17Schristos 2201.2Sthorpejfor syscall; do 2211.8Stv fnname=${syscall%.S} 2221.17Schristos if $pflag; then 2231.4Smycroft scname=${fnname#_} 2241.2Sthorpej else 2251.2Sthorpej scname=$fnname 2261.1Scgd fi 2271.4Smycroft syscall_stub $syscalldump $scname $fnname 2281.2Sthorpej echo "" 2291.1Scgddone 2301.17Schristos 2311.2Sthorpejtrailer 2321.1Scgd 2331.1Scgdexit 0 234