makelintstub revision 1.19
11.1Scgd#!/bin/sh - 21.19Srmind# $NetBSD: makelintstub,v 1.19 2007/10/09 18:18:33 rmind 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.19Srmind #include <sys/aio.h> 571.2Sthorpej #include <sys/time.h> 581.2Sthorpej #include <sys/mount.h> 591.2Sthorpej #include <sys/stat.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.19Srmind #include <sys/mqueue.h> 671.2Sthorpej #include <sys/msg.h> 681.2Sthorpej #include <sys/sem.h> 691.2Sthorpej #include <sys/shm.h> 701.2Sthorpej #include <sys/timex.h> 711.2Sthorpej #include <sys/socket.h> 721.10Sjdolecek #include <sys/event.h> 731.16Stsarna #include <sys/uuid.h> 741.2Sthorpej #ifdef __STDC__ 751.2Sthorpej #include <stdarg.h> 761.2Sthorpej #else 771.2Sthorpej #include <varargs.h> 781.2Sthorpej #endif 791.2Sthorpej 801.2Sthorpej __EOF__ 811.2Sthorpej} 821.2Sthorpej 831.2Sthorpejsyscall_stub() 841.2Sthorpej{ 851.2Sthorpej 861.4Smycroft syscalldump="$1" 871.2Sthorpej syscallname="$2" 881.2Sthorpej funcname="$3" 891.2Sthorpej 901.17Schristos arglist="$( 911.4Smycroft sed -e 'ta 921.4Smycroft :a 931.9Sthorpej s,^/\* syscall: \"'"$syscallname"'\" ,, 941.4Smycroft tb 951.4Smycroft d 961.4Smycroft :b 971.4Smycroft s, \*/$,,' $syscalldump 981.17Schristos )" 991.2Sthorpej 1001.2Sthorpej eval set -f -- "$arglist" 1011.2Sthorpej 1021.4Smycroft if [ $# -lt 3 ]; then 1031.2Sthorpej echo syscall $syscallname not found! 1>&2 1041.2Sthorpej exit 1 1051.2Sthorpej fi 1061.1Scgd 1071.4Smycroft shift # kill "ret:" 1081.4Smycroft returntype=$1; shift 1091.4Smycroft shift # kill "args:" 1101.2Sthorpej 1111.2Sthorpej cat <<- __EOF__ 1121.2Sthorpej /*ARGSUSED*/ 1131.2Sthorpej $returntype 1141.2Sthorpej __EOF__ 1151.2Sthorpej 1161.2Sthorpej # do ANSI C function header 1171.5Smycroft echo "#ifdef __STDC__" 1181.2Sthorpej 1191.9Sthorpej echo "$funcname(" 1201.17Schristos first=true; i=1 1211.5Smycroft for arg; do 1221.17Schristos if $first; then 1231.17Schristos first=false 1241.5Smycroft else 1251.9Sthorpej echo ", " 1261.2Sthorpej fi 1271.5Smycroft case "$arg" in 1281.9Sthorpej "...") echo "...";; 1291.9Sthorpej *) echo "$arg arg$i"; i=$(($i + 1));; 1301.5Smycroft esac 1311.5Smycroft done 1321.17Schristos if $first; then 1331.9Sthorpej echo "void" 1341.9Sthorpej fi 1351.5Smycroft echo ")" 1361.1Scgd 1371.5Smycroft # do K&R C function header 1381.5Smycroft echo "#else" 1391.1Scgd 1401.9Sthorpej echo "$funcname(" 1411.17Schristos first=true; i=1 1421.5Smycroft for arg; do 1431.17Schristos if $first; then 1441.17Schristos first=false 1451.5Smycroft else 1461.9Sthorpej echo ", " 1471.2Sthorpej fi 1481.5Smycroft case "$arg" in 1491.9Sthorpej "...") echo "va_alist";; 1501.9Sthorpej *) echo "arg$i"; i=$(($i + 1));; 1511.5Smycroft esac 1521.2Sthorpej done 1531.2Sthorpej echo ")" 1541.2Sthorpej i=1 1551.5Smycroft for arg; do 1561.5Smycroft case "$arg" in 1571.5Smycroft "...") echo " va_dcl";; 1581.5Smycroft *) echo " $arg arg$i;"; i=$(($i + 1));; 1591.5Smycroft esac 1601.2Sthorpej done 1611.1Scgd 1621.2Sthorpej # do function body 1631.5Smycroft echo "#endif" 1641.5Smycroft 1651.2Sthorpej echo "{" 1661.2Sthorpej if [ "$returntype" != "void" ]; then 1671.2Sthorpej echo " return (($returntype)0);" 1681.2Sthorpej fi 1691.2Sthorpej echo "}" 1701.2Sthorpej} 1711.2Sthorpej 1721.2Sthorpejtrailer() 1731.2Sthorpej{ 1741.2Sthorpej 1751.2Sthorpej cat <<- __EOF__ 1761.2Sthorpej /* END */ 1771.2Sthorpej __EOF__ 1781.2Sthorpej} 1791.2Sthorpej 1801.2Sthorpej 1811.17Schristospflag=false 1821.17Schristosnflag=false 1831.2Sthorpejoarg="" 1841.2Sthorpejsyscallhdr=/usr/include/sys/syscall.h 1851.4Smycroftsyscalldump=/tmp/makelintstub.$$ 1861.17SchristosPROG="$(basename "$0")" 1871.2Sthorpej 1881.17Schristosif [ -z "${CPP}" ]; then 1891.9Sthorpej usage 1901.9Sthorpejfi 1911.9Sthorpej 1921.17Schristoswhile getopts no:ps: i 1931.17Schristosdo 1941.2Sthorpej case "$i" in 1951.17Schristos n) nflag=true;; 1961.17Schristos o) oarg=$OPTARG;; 1971.17Schristos p) pflag=true;; 1981.17Schristos s) syscallhdr=$OPTARG;; 1991.17Schristos *) usage;; 2001.2Sthorpej esac 2011.1Scgddone 2021.1Scgd 2031.17Schristosshift $(expr $OPTIND - 1) 2041.17Schristos 2051.17Schristosif $pflag && $nflag 2061.17Schristosthen 2071.17Schristos echo "$PROG: -n flag and -p flag may not be used together" 1>&2 2081.2Sthorpej usage 2091.2Sthorpejfi 2101.2Sthorpej 2111.17Schristosif [ -n "$oarg" ]; then 2121.2Sthorpej exec > $oarg 2131.2Sthorpejfi 2141.2Sthorpej 2151.17Schristostrap "rm -f $syscalldump" 0 1 2 3 15 2161.4Smycroft 2171.2Sthorpejheader 2181.17Schristos 2191.17Schristosecho "#include \"$syscallhdr\"" | ${CPP} -D_LIBC -C > $syscalldump 2201.17Schristos 2211.2Sthorpejfor syscall; do 2221.8Stv fnname=${syscall%.S} 2231.17Schristos if $pflag; then 2241.4Smycroft scname=${fnname#_} 2251.2Sthorpej else 2261.2Sthorpej scname=$fnname 2271.1Scgd fi 2281.4Smycroft syscall_stub $syscalldump $scname $fnname 2291.2Sthorpej echo "" 2301.1Scgddone 2311.17Schristos 2321.2Sthorpejtrailer 2331.1Scgd 2341.1Scgdexit 0 235