makelintstub revision 1.1
11.1Scgd#!/bin/sh - 21.1Scgd# $NetBSD: makelintstub,v 1.1 1996/12/22 11:38:34 cgd Exp $ 31.1Scgd# 41.1Scgd# Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 51.1Scgd# 61.1Scgd# Redistribution and use in source and binary forms, with or without 71.1Scgd# modification, are permitted provided that the following conditions 81.1Scgd# are met: 91.1Scgd# 1. Redistributions of source code must retain the above copyright 101.1Scgd# notice, this list of conditions and the following disclaimer. 111.1Scgd# 2. Redistributions in binary form must reproduce the above copyright 121.1Scgd# notice, this list of conditions and the following disclaimer in the 131.1Scgd# documentation and/or other materials provided with the distribution. 141.1Scgd# 3. All advertising materials mentioning features or use of this software 151.1Scgd# must display the following acknowledgement: 161.1Scgd# This product includes software developed for the NetBSD Project 171.1Scgd# by Christopher G. Demetriou. 181.1Scgd# 4. The name of the author may not be used to endorse or promote products 191.1Scgd# derived from this software without specific prior written permission 201.1Scgd# 211.1Scgd# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 221.1Scgd# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 231.1Scgd# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 241.1Scgd# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 251.1Scgd# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 261.1Scgd# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 271.1Scgd# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 281.1Scgd# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 291.1Scgd# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 301.1Scgd# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 311.1Scgd 321.1Scgdif [ $# -lt 1 ] || [ $# -gt 2 ]; then 331.1Scgd echo "usage: $0 syscallname [funcname]" 341.1Scgd exit 1 351.1Scgdfi 361.1Scgd 371.1Scgdsyscallname="$1" 381.1Scgdif [ $# -eq 1 ]; then 391.1Scgd funcname="$syscallname" 401.1Scgdelse 411.1Scgd funcname="$2" 421.1Scgdfi 431.1Scgd 441.1Scgdarglist="`printf '#include <sys/syscall.h>' | cpp -C | \ 451.1Scgd grep '^/\* syscall: "'"$syscallname"'" ' | \ 461.1Scgd sed -e 's,^/\* syscall: ,,;s, \*/$,,'`" 471.1Scgd 481.1Scgdeval set -f -- "$arglist" 491.1Scgd 501.1Scgdif [ $# -lt 4 ]; then 511.1Scgd echo syscall $syscallname not found! 1>&2 521.1Scgd exit 1 531.1Scgdfi 541.1Scgd 551.1Scgdsyscallname=$1 561.1Scgdshift 2 # kill name and "ret:" 571.1Scgdreturntype=$1 581.1Scgdshift 2 # kill return type and "args:" 591.1Scgd 601.1Scgdcat << __EOF__ 611.1Scgd#include <sys/param.h> 621.1Scgd#include <sys/time.h> 631.1Scgd#include <sys/mount.h> 641.1Scgd#include <sys/stat.h> 651.1Scgd#include <ufs/lfs/lfs.h> 661.1Scgd#include <sys/resource.h> 671.1Scgd#include <sys/poll.h> 681.1Scgd#include <sys/uio.h> 691.1Scgd#include <sys/ipc.h> 701.1Scgd#include <sys/msg.h> 711.1Scgd#include <sys/sem.h> 721.1Scgd#include <sys/shm.h> 731.1Scgd#include <sys/timex.h> 741.1Scgd#include <sys/socket.h> 751.1Scgd#ifdef __STDC__ 761.1Scgd#include <stdarg.h> 771.1Scgd#else 781.1Scgd#include <varargs.h> 791.1Scgd#endif 801.1Scgd 811.1Scgd/*ARGSUSED*/ 821.1Scgd$returntype 831.1Scgd__EOF__ 841.1Scgd 851.1Scgdif [ "`eval echo -n \\$$#`" = "..." ]; then 861.1Scgd varargs=YES 871.1Scgd nargs=$(($# - 1)) 881.1Scgdelse 891.1Scgd varargs=NO 901.1Scgd nargs=$# 911.1Scgdfi 921.1Scgdnargswithva=$# 931.1Scgd 941.1Scgd# do ANSI C function header 951.1Scgdecho "#ifdef __STDC__" 961.1Scgd 971.1Scgdecho -n "$funcname(" 981.1Scgdi=1 991.1Scgdwhile [ $i -le $nargs ]; do 1001.1Scgd eval echo -n \""\$$i"\" 1011.1Scgd echo -n " arg$i" 1021.1Scgd if [ $i -lt $nargswithva ]; then 1031.1Scgd echo -n ", " 1041.1Scgd fi 1051.1Scgd i=$(($i + 1)) 1061.1Scgddone 1071.1Scgdif [ $varargs = YES ]; then 1081.1Scgd echo -n "..." 1091.1Scgdfi 1101.1Scgdecho ")" 1111.1Scgd 1121.1Scgd# do K&R C function header 1131.1Scgdecho "#else" 1141.1Scgd 1151.1Scgdecho -n "$funcname(" 1161.1Scgdi=1 1171.1Scgdwhile [ $i -le $nargs ]; do 1181.1Scgd echo -n "arg$i" 1191.1Scgd if [ $i -lt $nargswithva ]; then 1201.1Scgd echo -n ", " 1211.1Scgd fi 1221.1Scgd i=$(($i + 1)) 1231.1Scgddone 1241.1Scgdif [ $varargs = YES ]; then 1251.1Scgd echo -n "va_alist" 1261.1Scgdfi 1271.1Scgdecho ")" 1281.1Scgdi=1 1291.1Scgdwhile [ $i -le $nargs ]; do 1301.1Scgd eval echo -n \"" \$$i"\" 1311.1Scgd echo " arg$i;" 1321.1Scgd i=$(($i + 1)) 1331.1Scgddone 1341.1Scgdif [ $varargs = YES ]; then 1351.1Scgd echo " va_dcl" 1361.1Scgdfi 1371.1Scgd 1381.1Scgd# do function body 1391.1Scgdecho "#endif" 1401.1Scgdecho "{" 1411.1Scgdif [ "$returntype" != "void" ]; then 1421.1Scgd echo " return (($returntype)0);" 1431.1Scgdfi 1441.1Scgdecho "}" 1451.1Scgd 1461.1Scgdexit 0 147