2003-05-21 00:25:31 +04:00
|
|
|
# $NetBSD: genlintstub.awk,v 1.7 2003/05/20 20:25:31 kristerw Exp $
|
2001-05-16 02:23:09 +04:00
|
|
|
#
|
|
|
|
# Copyright 2001 Wasabi Systems, Inc.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Written by Perry E. Metzger for Wasabi Systems, Inc.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
# 3. All advertising materials mentioning features or use of this software
|
|
|
|
# must display the following acknowledgement:
|
|
|
|
# This product includes software developed for the NetBSD Project by
|
|
|
|
# Wasabi Systems, Inc.
|
|
|
|
# 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
|
|
|
# or promote products derived from this software without specific prior
|
|
|
|
# written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
|
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
|
|
|
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
|
|
|
|
# This awk script is used by kernel Makefiles to construct C lint
|
|
|
|
# stubs automatically from properly formatted comments in .S files. In
|
|
|
|
# general, a .S file should have a special comment for anything with
|
|
|
|
# something like an ENTRY designation. The special formats are:
|
|
|
|
#
|
2002-10-23 04:11:00 +04:00
|
|
|
# /* LINTSTUB: Empty */
|
2002-10-23 04:10:30 +04:00
|
|
|
# This is used as an indicator that the file contains no stubs at
|
|
|
|
# all. It generates a /* LINTED */ comment to quiet lint.
|
|
|
|
#
|
2001-05-16 02:23:09 +04:00
|
|
|
# /* LINTSTUB: Func: type function(args) */
|
2001-05-16 07:58:14 +04:00
|
|
|
# type must be void, int or long. A return is faked up for ints and longs.
|
2001-05-16 02:23:09 +04:00
|
|
|
#
|
|
|
|
# /* LINTSTUB: Var: type variable, variable; */
|
|
|
|
# This is often appropriate for assembly bits that the rest of the
|
|
|
|
# kernel has declared as char * and such, like various bits of
|
|
|
|
# trampoline code.
|
|
|
|
#
|
2001-05-16 08:17:04 +04:00
|
|
|
# /* LINTSTUB: include foo */
|
|
|
|
# Turns into a literal `#include foo' line in the source. Useful for
|
|
|
|
# making sure the stubs are checked against system prototypes like
|
|
|
|
# systm.h, cpu.h, etc., and to make sure that various types are
|
|
|
|
# properly declared.
|
|
|
|
#
|
2001-05-16 02:32:02 +04:00
|
|
|
# /* LINTSTUB: Ignore */
|
|
|
|
# This is used as an indicator to humans (and possible future
|
|
|
|
# automatic tools) that the entry is only used internally by other .S
|
|
|
|
# files and does not need a stub. You want this so you know you
|
|
|
|
# haven't just forgotten to put a stub in for something and you are
|
|
|
|
# *deliberately* ignoring it.
|
2001-05-16 02:23:09 +04:00
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
printf "/* DO NOT EDIT! DO NOT EDIT! DO NOT EDIT! */\n";
|
|
|
|
printf "/* DO NOT EDIT! DO NOT EDIT! DO NOT EDIT! */\n";
|
|
|
|
printf "/* This file was automatically generated. */\n";
|
2003-05-21 00:25:31 +04:00
|
|
|
printf "/* see genlintstub.awk for details. */\n";
|
2001-05-16 02:23:09 +04:00
|
|
|
printf "/* This file was automatically generated. */\n";
|
|
|
|
printf "/* DO NOT EDIT! DO NOT EDIT! DO NOT EDIT! */\n";
|
|
|
|
printf "/* DO NOT EDIT! DO NOT EDIT! DO NOT EDIT! */\n";
|
2001-05-16 08:17:04 +04:00
|
|
|
printf "\n\n";
|
2001-05-16 02:23:09 +04:00
|
|
|
}
|
|
|
|
|
2002-10-23 04:10:30 +04:00
|
|
|
/^\/\* LINTSTUB: Empty.*\*\/[ \t]*$/ {
|
|
|
|
printf "/* LINTED (empty translation unit) */\n";
|
|
|
|
next;
|
|
|
|
}
|
2001-05-16 02:23:09 +04:00
|
|
|
|
|
|
|
/^\/\* LINTSTUB: Func:.*\)[ \t]*[;]?[ \t]+\*\/[ \t]*$/ {
|
2001-05-16 07:58:14 +04:00
|
|
|
if (($4 == "int") || ($4 == "long"))
|
2001-05-16 02:23:09 +04:00
|
|
|
retflag = 1;
|
|
|
|
else if ($4 == "void")
|
|
|
|
retflag = 0;
|
|
|
|
else {
|
|
|
|
printf "ERROR: %s: type is not int or void\n", $4 > "/dev/stderr";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
print "/* ARGSUSED */";
|
|
|
|
for (i = 4; i < NF; i++) {
|
|
|
|
if (i != (NF - 1))
|
|
|
|
printf "%s ", $i;
|
|
|
|
else {
|
|
|
|
sub(";$", "", $i);
|
|
|
|
printf "%s\n", $i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print "{";
|
|
|
|
if (retflag)
|
|
|
|
print "\treturn(0);"
|
|
|
|
print "}\n";
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/^\/\* LINTSTUB: Func:/ {
|
|
|
|
printf "ERROR: bad function declaration: %s\n", $0 > "/dev/stderr";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/^\/\* LINTSTUB: Var:.*[ \t]+\*\/[ \t]*$/ {
|
|
|
|
for (i = 4; i < NF; i++) {
|
|
|
|
if (i != (NF - 1))
|
|
|
|
printf "%s ", $i;
|
|
|
|
else {
|
|
|
|
gsub(";$", "", $i);
|
|
|
|
printf "%s;\n\n", $i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/^\/\* LINTSTUB: Var:/ {
|
|
|
|
printf "ERROR: bad variable declaration: %s\n", $0 > "/dev/stderr";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
2001-05-16 08:17:04 +04:00
|
|
|
/^\/\* LINTSTUB: include[ \t]+.*\*\/[ \t]*$/ {
|
|
|
|
printf "#include %s\n", $4;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2001-05-16 02:32:02 +04:00
|
|
|
/^\/\* LINTSTUB: Ignore.*\*\/[ \t]*$/ { next; }
|
2001-05-16 02:23:09 +04:00
|
|
|
|
2001-05-16 02:32:02 +04:00
|
|
|
/^\/\* LINTSTUB: Ignore/ {
|
2001-05-16 02:23:09 +04:00
|
|
|
printf "ERROR: bad ignore declaration: %s\n", $0 > "/dev/stderr";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/^\/\* LINTSTUBS:/ {
|
|
|
|
printf "ERROR: LINTSTUB, not LINTSTUBS: %s\n", $0 > "/dev/stderr";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/^\/\* LINTSTUB:/ {
|
|
|
|
printf "ERROR: bad declaration: %s\n", $0 > "/dev/stderr";
|
|
|
|
exit 1;
|
|
|
|
}
|