makelintstub revision 1.23
11.1Scgd#!/bin/sh - 21.23Slukem# $NetBSD: makelintstub,v 1.23 2008/08/05 02:08:13 lukem 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.2Sthorpej #ifdef __STDC__ 831.2Sthorpej #include <stdarg.h> 841.2Sthorpej #else 851.2Sthorpej #include <varargs.h> 861.2Sthorpej #endif 871.2Sthorpej 881.2Sthorpej __EOF__ 891.2Sthorpej} 901.2Sthorpej 911.2Sthorpejsyscall_stub() 921.2Sthorpej{ 931.2Sthorpej 941.4Smycroft syscalldump="$1" 951.2Sthorpej syscallname="$2" 961.2Sthorpej funcname="$3" 971.2Sthorpej 981.17Schristos arglist="$( 991.4Smycroft sed -e 'ta 1001.4Smycroft :a 1011.9Sthorpej s,^/\* syscall: \"'"$syscallname"'\" ,, 1021.4Smycroft tb 1031.4Smycroft d 1041.4Smycroft :b 1051.4Smycroft s, \*/$,,' $syscalldump 1061.17Schristos )" 1071.2Sthorpej 1081.2Sthorpej eval set -f -- "$arglist" 1091.2Sthorpej 1101.4Smycroft if [ $# -lt 3 ]; then 1111.2Sthorpej echo syscall $syscallname not found! 1>&2 1121.2Sthorpej exit 1 1131.2Sthorpej fi 1141.1Scgd 1151.4Smycroft shift # kill "ret:" 1161.4Smycroft returntype=$1; shift 1171.4Smycroft shift # kill "args:" 1181.2Sthorpej 1191.2Sthorpej cat <<- __EOF__ 1201.2Sthorpej /*ARGSUSED*/ 1211.2Sthorpej $returntype 1221.2Sthorpej __EOF__ 1231.2Sthorpej 1241.2Sthorpej # do ANSI C function header 1251.5Smycroft echo "#ifdef __STDC__" 1261.2Sthorpej 1271.9Sthorpej echo "$funcname(" 1281.17Schristos first=true; i=1 1291.5Smycroft for arg; do 1301.17Schristos if $first; then 1311.17Schristos first=false 1321.5Smycroft else 1331.9Sthorpej echo ", " 1341.2Sthorpej fi 1351.5Smycroft case "$arg" in 1361.9Sthorpej "...") echo "...";; 1371.9Sthorpej *) echo "$arg arg$i"; i=$(($i + 1));; 1381.5Smycroft esac 1391.5Smycroft done 1401.17Schristos if $first; then 1411.9Sthorpej echo "void" 1421.9Sthorpej fi 1431.5Smycroft echo ")" 1441.1Scgd 1451.5Smycroft # do K&R C function header 1461.5Smycroft echo "#else" 1471.1Scgd 1481.9Sthorpej echo "$funcname(" 1491.17Schristos first=true; i=1 1501.5Smycroft for arg; do 1511.17Schristos if $first; then 1521.17Schristos first=false 1531.5Smycroft else 1541.9Sthorpej echo ", " 1551.2Sthorpej fi 1561.5Smycroft case "$arg" in 1571.9Sthorpej "...") echo "va_alist";; 1581.9Sthorpej *) echo "arg$i"; i=$(($i + 1));; 1591.5Smycroft esac 1601.2Sthorpej done 1611.2Sthorpej echo ")" 1621.2Sthorpej i=1 1631.5Smycroft for arg; do 1641.5Smycroft case "$arg" in 1651.5Smycroft "...") echo " va_dcl";; 1661.5Smycroft *) echo " $arg arg$i;"; i=$(($i + 1));; 1671.5Smycroft esac 1681.2Sthorpej done 1691.1Scgd 1701.2Sthorpej # do function body 1711.5Smycroft echo "#endif" 1721.5Smycroft 1731.2Sthorpej echo "{" 1741.2Sthorpej if [ "$returntype" != "void" ]; then 1751.2Sthorpej echo " return (($returntype)0);" 1761.2Sthorpej fi 1771.2Sthorpej echo "}" 1781.2Sthorpej} 1791.2Sthorpej 1801.2Sthorpejtrailer() 1811.2Sthorpej{ 1821.2Sthorpej 1831.2Sthorpej cat <<- __EOF__ 1841.2Sthorpej /* END */ 1851.2Sthorpej __EOF__ 1861.2Sthorpej} 1871.2Sthorpej 1881.2Sthorpej 1891.17Schristospflag=false 1901.17Schristosnflag=false 1911.2Sthorpejoarg="" 1921.2Sthorpejsyscallhdr=/usr/include/sys/syscall.h 1931.4Smycroftsyscalldump=/tmp/makelintstub.$$ 1941.17SchristosPROG="$(basename "$0")" 1951.2Sthorpej 1961.17Schristosif [ -z "${CPP}" ]; then 1971.9Sthorpej usage 1981.9Sthorpejfi 1991.9Sthorpej 2001.23Slukemwhile getopts no:ps: i 2011.17Schristosdo 2021.2Sthorpej case "$i" in 2031.17Schristos n) nflag=true;; 2041.17Schristos o) oarg=$OPTARG;; 2051.17Schristos p) pflag=true;; 2061.17Schristos s) syscallhdr=$OPTARG;; 2071.17Schristos *) usage;; 2081.2Sthorpej esac 2091.1Scgddone 2101.1Scgd 2111.17Schristosshift $(expr $OPTIND - 1) 2121.17Schristos 2131.17Schristosif $pflag && $nflag 2141.17Schristosthen 2151.17Schristos echo "$PROG: -n flag and -p flag may not be used together" 1>&2 2161.2Sthorpej usage 2171.2Sthorpejfi 2181.2Sthorpej 2191.17Schristosif [ -n "$oarg" ]; then 2201.2Sthorpej exec > $oarg 2211.2Sthorpejfi 2221.2Sthorpej 2231.17Schristostrap "rm -f $syscalldump" 0 1 2 3 15 2241.4Smycroft 2251.2Sthorpejheader 2261.17Schristos 2271.17Schristosecho "#include \"$syscallhdr\"" | ${CPP} -D_LIBC -C > $syscalldump 2281.17Schristos 2291.2Sthorpejfor syscall; do 2301.8Stv fnname=${syscall%.S} 2311.17Schristos if $pflag; then 2321.4Smycroft scname=${fnname#_} 2331.2Sthorpej else 2341.2Sthorpej scname=$fnname 2351.1Scgd fi 2361.4Smycroft syscall_stub $syscalldump $scname $fnname 2371.2Sthorpej echo "" 2381.1Scgddone 2391.17Schristos 2401.2Sthorpejtrailer 2411.1Scgd 2421.1Scgdexit 0 243