makelintstub revision 1.24
11.1Scgd#!/bin/sh - 21.24Sdholland# $NetBSD: makelintstub,v 1.24 2012/02/01 05:34:40 dholland 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.21Srmind #include <sys/sched.h> 781.2Sthorpej #include <sys/timex.h> 791.2Sthorpej #include <sys/socket.h> 801.10Sjdolecek #include <sys/event.h> 811.16Stsarna #include <sys/uuid.h> 821.24Sdholland #include <sys/quotactl.h> 831.2Sthorpej #ifdef __STDC__ 841.2Sthorpej #include <stdarg.h> 851.2Sthorpej #else 861.2Sthorpej #include <varargs.h> 871.2Sthorpej #endif 881.2Sthorpej 891.2Sthorpej __EOF__ 901.2Sthorpej} 911.2Sthorpej 921.2Sthorpejsyscall_stub() 931.2Sthorpej{ 941.2Sthorpej 951.4Smycroft syscalldump="$1" 961.2Sthorpej syscallname="$2" 971.2Sthorpej funcname="$3" 981.2Sthorpej 991.17Schristos arglist="$( 1001.4Smycroft sed -e 'ta 1011.4Smycroft :a 1021.9Sthorpej s,^/\* syscall: \"'"$syscallname"'\" ,, 1031.4Smycroft tb 1041.4Smycroft d 1051.4Smycroft :b 1061.4Smycroft s, \*/$,,' $syscalldump 1071.17Schristos )" 1081.2Sthorpej 1091.2Sthorpej eval set -f -- "$arglist" 1101.2Sthorpej 1111.4Smycroft if [ $# -lt 3 ]; then 1121.2Sthorpej echo syscall $syscallname not found! 1>&2 1131.2Sthorpej exit 1 1141.2Sthorpej fi 1151.1Scgd 1161.4Smycroft shift # kill "ret:" 1171.4Smycroft returntype=$1; shift 1181.4Smycroft shift # kill "args:" 1191.2Sthorpej 1201.2Sthorpej cat <<- __EOF__ 1211.2Sthorpej /*ARGSUSED*/ 1221.2Sthorpej $returntype 1231.2Sthorpej __EOF__ 1241.2Sthorpej 1251.2Sthorpej # do ANSI C function header 1261.5Smycroft echo "#ifdef __STDC__" 1271.2Sthorpej 1281.9Sthorpej echo "$funcname(" 1291.17Schristos first=true; i=1 1301.5Smycroft for arg; do 1311.17Schristos if $first; then 1321.17Schristos first=false 1331.5Smycroft else 1341.9Sthorpej echo ", " 1351.2Sthorpej fi 1361.5Smycroft case "$arg" in 1371.9Sthorpej "...") echo "...";; 1381.9Sthorpej *) echo "$arg arg$i"; i=$(($i + 1));; 1391.5Smycroft esac 1401.5Smycroft done 1411.17Schristos if $first; then 1421.9Sthorpej echo "void" 1431.9Sthorpej fi 1441.5Smycroft echo ")" 1451.1Scgd 1461.5Smycroft # do K&R C function header 1471.5Smycroft echo "#else" 1481.1Scgd 1491.9Sthorpej echo "$funcname(" 1501.17Schristos first=true; i=1 1511.5Smycroft for arg; do 1521.17Schristos if $first; then 1531.17Schristos first=false 1541.5Smycroft else 1551.9Sthorpej echo ", " 1561.2Sthorpej fi 1571.5Smycroft case "$arg" in 1581.9Sthorpej "...") echo "va_alist";; 1591.9Sthorpej *) echo "arg$i"; i=$(($i + 1));; 1601.5Smycroft esac 1611.2Sthorpej done 1621.2Sthorpej echo ")" 1631.2Sthorpej i=1 1641.5Smycroft for arg; do 1651.5Smycroft case "$arg" in 1661.5Smycroft "...") echo " va_dcl";; 1671.5Smycroft *) echo " $arg arg$i;"; i=$(($i + 1));; 1681.5Smycroft esac 1691.2Sthorpej done 1701.1Scgd 1711.2Sthorpej # do function body 1721.5Smycroft echo "#endif" 1731.5Smycroft 1741.2Sthorpej echo "{" 1751.2Sthorpej if [ "$returntype" != "void" ]; then 1761.2Sthorpej echo " return (($returntype)0);" 1771.2Sthorpej fi 1781.2Sthorpej echo "}" 1791.2Sthorpej} 1801.2Sthorpej 1811.2Sthorpejtrailer() 1821.2Sthorpej{ 1831.2Sthorpej 1841.2Sthorpej cat <<- __EOF__ 1851.2Sthorpej /* END */ 1861.2Sthorpej __EOF__ 1871.2Sthorpej} 1881.2Sthorpej 1891.2Sthorpej 1901.17Schristospflag=false 1911.17Schristosnflag=false 1921.2Sthorpejoarg="" 1931.2Sthorpejsyscallhdr=/usr/include/sys/syscall.h 1941.4Smycroftsyscalldump=/tmp/makelintstub.$$ 1951.17SchristosPROG="$(basename "$0")" 1961.2Sthorpej 1971.17Schristosif [ -z "${CPP}" ]; then 1981.9Sthorpej usage 1991.9Sthorpejfi 2001.9Sthorpej 2011.23Slukemwhile getopts no:ps: i 2021.17Schristosdo 2031.2Sthorpej case "$i" in 2041.17Schristos n) nflag=true;; 2051.17Schristos o) oarg=$OPTARG;; 2061.17Schristos p) pflag=true;; 2071.17Schristos s) syscallhdr=$OPTARG;; 2081.17Schristos *) usage;; 2091.2Sthorpej esac 2101.1Scgddone 2111.1Scgd 2121.17Schristosshift $(expr $OPTIND - 1) 2131.17Schristos 2141.17Schristosif $pflag && $nflag 2151.17Schristosthen 2161.17Schristos echo "$PROG: -n flag and -p flag may not be used together" 1>&2 2171.2Sthorpej usage 2181.2Sthorpejfi 2191.2Sthorpej 2201.17Schristosif [ -n "$oarg" ]; then 2211.2Sthorpej exec > $oarg 2221.2Sthorpejfi 2231.2Sthorpej 2241.17Schristostrap "rm -f $syscalldump" 0 1 2 3 15 2251.4Smycroft 2261.2Sthorpejheader 2271.17Schristos 2281.17Schristosecho "#include \"$syscallhdr\"" | ${CPP} -D_LIBC -C > $syscalldump 2291.17Schristos 2301.2Sthorpejfor syscall; do 2311.8Stv fnname=${syscall%.S} 2321.17Schristos if $pflag; then 2331.4Smycroft scname=${fnname#_} 2341.2Sthorpej else 2351.2Sthorpej scname=$fnname 2361.1Scgd fi 2371.4Smycroft syscall_stub $syscalldump $scname $fnname 2381.2Sthorpej echo "" 2391.1Scgddone 2401.17Schristos 2411.2Sthorpejtrailer 2421.1Scgd 2431.1Scgdexit 0 244