makelintstub revision 1.26
11.1Scgd#!/bin/sh - 21.26Schristos# $NetBSD: makelintstub,v 1.26 2016/04/03 00:48:29 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.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.26Schristos * It is generated by $PROG 601.2Sthorpej */ 611.2Sthorpej 621.2Sthorpej #include <sys/param.h> 631.19Srmind #include <sys/aio.h> 641.2Sthorpej #include <sys/time.h> 651.2Sthorpej #include <sys/mount.h> 661.2Sthorpej #include <sys/stat.h> 671.3Sfvdl #include <ufs/ufs/dinode.h> 681.2Sthorpej #include <ufs/lfs/lfs.h> 691.2Sthorpej #include <sys/resource.h> 701.2Sthorpej #include <sys/poll.h> 711.2Sthorpej #include <sys/uio.h> 721.2Sthorpej #include <sys/ipc.h> 731.26Schristos #include <sys/idtype.h> 741.20She #include <sys/lwpctl.h> 751.19Srmind #include <sys/mqueue.h> 761.2Sthorpej #include <sys/msg.h> 771.2Sthorpej #include <sys/sem.h> 781.2Sthorpej #include <sys/shm.h> 791.25Smartin #include <sys/spawn.h> 801.21Srmind #include <sys/sched.h> 811.2Sthorpej #include <sys/timex.h> 821.2Sthorpej #include <sys/socket.h> 831.10Sjdolecek #include <sys/event.h> 841.16Stsarna #include <sys/uuid.h> 851.24Sdholland #include <sys/quotactl.h> 861.2Sthorpej #ifdef __STDC__ 871.2Sthorpej #include <stdarg.h> 881.2Sthorpej #else 891.2Sthorpej #include <varargs.h> 901.2Sthorpej #endif 911.2Sthorpej 921.2Sthorpej __EOF__ 931.2Sthorpej} 941.2Sthorpej 951.2Sthorpejsyscall_stub() 961.2Sthorpej{ 971.2Sthorpej 981.4Smycroft syscalldump="$1" 991.2Sthorpej syscallname="$2" 1001.2Sthorpej funcname="$3" 1011.2Sthorpej 1021.17Schristos arglist="$( 1031.4Smycroft sed -e 'ta 1041.4Smycroft :a 1051.9Sthorpej s,^/\* syscall: \"'"$syscallname"'\" ,, 1061.4Smycroft tb 1071.4Smycroft d 1081.4Smycroft :b 1091.4Smycroft s, \*/$,,' $syscalldump 1101.17Schristos )" 1111.2Sthorpej 1121.2Sthorpej eval set -f -- "$arglist" 1131.2Sthorpej 1141.4Smycroft if [ $# -lt 3 ]; then 1151.2Sthorpej echo syscall $syscallname not found! 1>&2 1161.2Sthorpej exit 1 1171.2Sthorpej fi 1181.1Scgd 1191.4Smycroft shift # kill "ret:" 1201.4Smycroft returntype=$1; shift 1211.4Smycroft shift # kill "args:" 1221.2Sthorpej 1231.2Sthorpej cat <<- __EOF__ 1241.2Sthorpej /*ARGSUSED*/ 1251.2Sthorpej $returntype 1261.2Sthorpej __EOF__ 1271.2Sthorpej 1281.2Sthorpej # do ANSI C function header 1291.5Smycroft echo "#ifdef __STDC__" 1301.2Sthorpej 1311.9Sthorpej echo "$funcname(" 1321.17Schristos first=true; i=1 1331.5Smycroft for arg; do 1341.17Schristos if $first; then 1351.17Schristos first=false 1361.5Smycroft else 1371.9Sthorpej echo ", " 1381.2Sthorpej fi 1391.5Smycroft case "$arg" in 1401.9Sthorpej "...") echo "...";; 1411.9Sthorpej *) echo "$arg arg$i"; i=$(($i + 1));; 1421.5Smycroft esac 1431.5Smycroft done 1441.17Schristos if $first; then 1451.9Sthorpej echo "void" 1461.9Sthorpej fi 1471.5Smycroft echo ")" 1481.1Scgd 1491.5Smycroft # do K&R C function header 1501.5Smycroft echo "#else" 1511.1Scgd 1521.9Sthorpej echo "$funcname(" 1531.17Schristos first=true; i=1 1541.5Smycroft for arg; do 1551.17Schristos if $first; then 1561.17Schristos first=false 1571.5Smycroft else 1581.9Sthorpej echo ", " 1591.2Sthorpej fi 1601.5Smycroft case "$arg" in 1611.9Sthorpej "...") echo "va_alist";; 1621.9Sthorpej *) echo "arg$i"; i=$(($i + 1));; 1631.5Smycroft esac 1641.2Sthorpej done 1651.2Sthorpej echo ")" 1661.2Sthorpej i=1 1671.5Smycroft for arg; do 1681.5Smycroft case "$arg" in 1691.5Smycroft "...") echo " va_dcl";; 1701.5Smycroft *) echo " $arg arg$i;"; i=$(($i + 1));; 1711.5Smycroft esac 1721.2Sthorpej done 1731.1Scgd 1741.2Sthorpej # do function body 1751.5Smycroft echo "#endif" 1761.5Smycroft 1771.2Sthorpej echo "{" 1781.2Sthorpej if [ "$returntype" != "void" ]; then 1791.2Sthorpej echo " return (($returntype)0);" 1801.2Sthorpej fi 1811.2Sthorpej echo "}" 1821.2Sthorpej} 1831.2Sthorpej 1841.2Sthorpejtrailer() 1851.2Sthorpej{ 1861.2Sthorpej 1871.2Sthorpej cat <<- __EOF__ 1881.2Sthorpej /* END */ 1891.2Sthorpej __EOF__ 1901.2Sthorpej} 1911.2Sthorpej 1921.2Sthorpej 1931.17Schristospflag=false 1941.17Schristosnflag=false 1951.2Sthorpejoarg="" 1961.2Sthorpejsyscallhdr=/usr/include/sys/syscall.h 1971.4Smycroftsyscalldump=/tmp/makelintstub.$$ 1981.17SchristosPROG="$(basename "$0")" 1991.2Sthorpej 2001.17Schristosif [ -z "${CPP}" ]; then 2011.9Sthorpej usage 2021.9Sthorpejfi 2031.9Sthorpej 2041.23Slukemwhile getopts no:ps: i 2051.17Schristosdo 2061.2Sthorpej case "$i" in 2071.17Schristos n) nflag=true;; 2081.17Schristos o) oarg=$OPTARG;; 2091.17Schristos p) pflag=true;; 2101.17Schristos s) syscallhdr=$OPTARG;; 2111.17Schristos *) usage;; 2121.2Sthorpej esac 2131.1Scgddone 2141.1Scgd 2151.17Schristosshift $(expr $OPTIND - 1) 2161.17Schristos 2171.17Schristosif $pflag && $nflag 2181.17Schristosthen 2191.17Schristos echo "$PROG: -n flag and -p flag may not be used together" 1>&2 2201.2Sthorpej usage 2211.2Sthorpejfi 2221.2Sthorpej 2231.17Schristosif [ -n "$oarg" ]; then 2241.2Sthorpej exec > $oarg 2251.2Sthorpejfi 2261.2Sthorpej 2271.17Schristostrap "rm -f $syscalldump" 0 1 2 3 15 2281.4Smycroft 2291.2Sthorpejheader 2301.17Schristos 2311.17Schristosecho "#include \"$syscallhdr\"" | ${CPP} -D_LIBC -C > $syscalldump 2321.17Schristos 2331.2Sthorpejfor syscall; do 2341.8Stv fnname=${syscall%.S} 2351.17Schristos if $pflag; then 2361.4Smycroft scname=${fnname#_} 2371.2Sthorpej else 2381.2Sthorpej scname=$fnname 2391.1Scgd fi 2401.4Smycroft syscall_stub $syscalldump $scname $fnname 2411.2Sthorpej echo "" 2421.1Scgddone 2431.17Schristos 2441.2Sthorpejtrailer 2451.1Scgd 2461.1Scgdexit 0 247