makelintstub revision 1.25
11.1Scgd#!/bin/sh - 21.25Smartin# $NetBSD: makelintstub,v 1.25 2012/02/12 01:46:05 martin 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.23SlukemUsage: $PROG [-n|-p] [-o filename] [-s syscall.h] object ... 411.22Slukem -n Create SYSCALL_NOERROR. 421.22Slukem -p Create PSEUDO_NOERROR. 431.22Slukem (also removes leading "_" on syscall name). 441.22Slukem -o filename Output to filename. 451.22Slukem -s syscall.h Header to #include instead of <sys/syscall.h>. 461.22Slukem 471.17Schristos The CPP environment variable must be set 481.17Schristos to the path to the C preprocessor. 491.17Schristos_EOF 501.1Scgd exit 1 511.2Sthorpej} 521.1Scgd 531.2Sthorpejheader() 541.2Sthorpej{ 551.1Scgd 561.2Sthorpej cat <<- __EOF__ 571.2Sthorpej /* 581.2Sthorpej * THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT. 591.2Sthorpej */ 601.2Sthorpej 611.2Sthorpej #include <sys/param.h> 621.19Srmind #include <sys/aio.h> 631.2Sthorpej #include <sys/time.h> 641.2Sthorpej #include <sys/mount.h> 651.2Sthorpej #include <sys/stat.h> 661.3Sfvdl #include <ufs/ufs/dinode.h> 671.2Sthorpej #include <ufs/lfs/lfs.h> 681.2Sthorpej #include <sys/resource.h> 691.2Sthorpej #include <sys/poll.h> 701.2Sthorpej #include <sys/uio.h> 711.2Sthorpej #include <sys/ipc.h> 721.20She #include <sys/lwpctl.h> 731.19Srmind #include <sys/mqueue.h> 741.2Sthorpej #include <sys/msg.h> 751.2Sthorpej #include <sys/sem.h> 761.2Sthorpej #include <sys/shm.h> 771.25Smartin #include <sys/spawn.h> 781.21Srmind #include <sys/sched.h> 791.2Sthorpej #include <sys/timex.h> 801.2Sthorpej #include <sys/socket.h> 811.10Sjdolecek #include <sys/event.h> 821.16Stsarna #include <sys/uuid.h> 831.24Sdholland #include <sys/quotactl.h> 841.2Sthorpej #ifdef __STDC__ 851.2Sthorpej #include <stdarg.h> 861.2Sthorpej #else 871.2Sthorpej #include <varargs.h> 881.2Sthorpej #endif 891.2Sthorpej 901.2Sthorpej __EOF__ 911.2Sthorpej} 921.2Sthorpej 931.2Sthorpejsyscall_stub() 941.2Sthorpej{ 951.2Sthorpej 961.4Smycroft syscalldump="$1" 971.2Sthorpej syscallname="$2" 981.2Sthorpej funcname="$3" 991.2Sthorpej 1001.17Schristos arglist="$( 1011.4Smycroft sed -e 'ta 1021.4Smycroft :a 1031.9Sthorpej s,^/\* syscall: \"'"$syscallname"'\" ,, 1041.4Smycroft tb 1051.4Smycroft d 1061.4Smycroft :b 1071.4Smycroft s, \*/$,,' $syscalldump 1081.17Schristos )" 1091.2Sthorpej 1101.2Sthorpej eval set -f -- "$arglist" 1111.2Sthorpej 1121.4Smycroft if [ $# -lt 3 ]; then 1131.2Sthorpej echo syscall $syscallname not found! 1>&2 1141.2Sthorpej exit 1 1151.2Sthorpej fi 1161.1Scgd 1171.4Smycroft shift # kill "ret:" 1181.4Smycroft returntype=$1; shift 1191.4Smycroft shift # kill "args:" 1201.2Sthorpej 1211.2Sthorpej cat <<- __EOF__ 1221.2Sthorpej /*ARGSUSED*/ 1231.2Sthorpej $returntype 1241.2Sthorpej __EOF__ 1251.2Sthorpej 1261.2Sthorpej # do ANSI C function header 1271.5Smycroft echo "#ifdef __STDC__" 1281.2Sthorpej 1291.9Sthorpej echo "$funcname(" 1301.17Schristos first=true; i=1 1311.5Smycroft for arg; do 1321.17Schristos if $first; then 1331.17Schristos first=false 1341.5Smycroft else 1351.9Sthorpej echo ", " 1361.2Sthorpej fi 1371.5Smycroft case "$arg" in 1381.9Sthorpej "...") echo "...";; 1391.9Sthorpej *) echo "$arg arg$i"; i=$(($i + 1));; 1401.5Smycroft esac 1411.5Smycroft done 1421.17Schristos if $first; then 1431.9Sthorpej echo "void" 1441.9Sthorpej fi 1451.5Smycroft echo ")" 1461.1Scgd 1471.5Smycroft # do K&R C function header 1481.5Smycroft echo "#else" 1491.1Scgd 1501.9Sthorpej echo "$funcname(" 1511.17Schristos first=true; i=1 1521.5Smycroft for arg; do 1531.17Schristos if $first; then 1541.17Schristos first=false 1551.5Smycroft else 1561.9Sthorpej echo ", " 1571.2Sthorpej fi 1581.5Smycroft case "$arg" in 1591.9Sthorpej "...") echo "va_alist";; 1601.9Sthorpej *) echo "arg$i"; i=$(($i + 1));; 1611.5Smycroft esac 1621.2Sthorpej done 1631.2Sthorpej echo ")" 1641.2Sthorpej i=1 1651.5Smycroft for arg; do 1661.5Smycroft case "$arg" in 1671.5Smycroft "...") echo " va_dcl";; 1681.5Smycroft *) echo " $arg arg$i;"; i=$(($i + 1));; 1691.5Smycroft esac 1701.2Sthorpej done 1711.1Scgd 1721.2Sthorpej # do function body 1731.5Smycroft echo "#endif" 1741.5Smycroft 1751.2Sthorpej echo "{" 1761.2Sthorpej if [ "$returntype" != "void" ]; then 1771.2Sthorpej echo " return (($returntype)0);" 1781.2Sthorpej fi 1791.2Sthorpej echo "}" 1801.2Sthorpej} 1811.2Sthorpej 1821.2Sthorpejtrailer() 1831.2Sthorpej{ 1841.2Sthorpej 1851.2Sthorpej cat <<- __EOF__ 1861.2Sthorpej /* END */ 1871.2Sthorpej __EOF__ 1881.2Sthorpej} 1891.2Sthorpej 1901.2Sthorpej 1911.17Schristospflag=false 1921.17Schristosnflag=false 1931.2Sthorpejoarg="" 1941.2Sthorpejsyscallhdr=/usr/include/sys/syscall.h 1951.4Smycroftsyscalldump=/tmp/makelintstub.$$ 1961.17SchristosPROG="$(basename "$0")" 1971.2Sthorpej 1981.17Schristosif [ -z "${CPP}" ]; then 1991.9Sthorpej usage 2001.9Sthorpejfi 2011.9Sthorpej 2021.23Slukemwhile getopts no:ps: i 2031.17Schristosdo 2041.2Sthorpej case "$i" in 2051.17Schristos n) nflag=true;; 2061.17Schristos o) oarg=$OPTARG;; 2071.17Schristos p) pflag=true;; 2081.17Schristos s) syscallhdr=$OPTARG;; 2091.17Schristos *) usage;; 2101.2Sthorpej esac 2111.1Scgddone 2121.1Scgd 2131.17Schristosshift $(expr $OPTIND - 1) 2141.17Schristos 2151.17Schristosif $pflag && $nflag 2161.17Schristosthen 2171.17Schristos echo "$PROG: -n flag and -p flag may not be used together" 1>&2 2181.2Sthorpej usage 2191.2Sthorpejfi 2201.2Sthorpej 2211.17Schristosif [ -n "$oarg" ]; then 2221.2Sthorpej exec > $oarg 2231.2Sthorpejfi 2241.2Sthorpej 2251.17Schristostrap "rm -f $syscalldump" 0 1 2 3 15 2261.4Smycroft 2271.2Sthorpejheader 2281.17Schristos 2291.17Schristosecho "#include \"$syscallhdr\"" | ${CPP} -D_LIBC -C > $syscalldump 2301.17Schristos 2311.2Sthorpejfor syscall; do 2321.8Stv fnname=${syscall%.S} 2331.17Schristos if $pflag; then 2341.4Smycroft scname=${fnname#_} 2351.2Sthorpej else 2361.2Sthorpej scname=$fnname 2371.1Scgd fi 2381.4Smycroft syscall_stub $syscalldump $scname $fnname 2391.2Sthorpej echo "" 2401.1Scgddone 2411.17Schristos 2421.2Sthorpejtrailer 2431.1Scgd 2441.1Scgdexit 0 245