8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / mdb / tools / scripts / map2linktest.sh
blob9977f162211155d119de9fe542fb1f56c8b9520c
1 #!/bin/ksh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
26 #ident "%Z%%M% %I% %E% SMI"
30 # Create dummy functions for each of the functions in the module API. We can
31 # then link a module against an object file created from the output of this
32 # script to determine whether or not that module restricts itself to the API.
33 # If the module uses functions outside of the module API, then it cannot be
34 # used as a kmdb module.
36 nawk '
37 /^[ ]*global:[ ]*$/ {
38 printing = 1;
39 next;
42 /^[ ]*local:[ ]*$/ {
43 printing = 0;
44 next;
47 # Skip blank lines and comments
48 /^$/ { next; }
49 /^[ ]*#/ { next;}
51 # Print globals only
52 printing == 0 { next; }
54 # Symbols beginning with "kmdb_" are not in the module API - they are
55 # private to kmdb.
56 $1 ~ /^kmdb_/ { next; }
58 # Symbols which have the token "variable" are seen as an int
59 $3 ~ /variable/ {
60 if (seen[$1]) {
61 next;
64 seen[$1] = 1;
66 printf("int %s = 0;\n", substr($1, 1, length($1) - 1));
67 next;
70 $1 !~ /;$/ { next; }
72 # Print everything else that we have not already seen as a function
73 # definition so we can create our filter.
75 if (seen[$1]) {
76 next;
79 seen[$1] = 1;
81 printf("void %s(void) {}\n", substr($1, 1, length($1) - 1));
86 # kmdb modules cannot have their own _init, _fini, or _info routines. By
87 # creating dummies for them here, a link against an object file created from
88 # the output of this script will fail if the module defines one of them.
90 echo "void _init(void) {}"
91 echo "void _info(void) {}"
92 echo "void _fini(void) {}"
94 # The SunStudio compiler may generate calls to _memcpy and so we
95 # need to make sure that the correct symbol exists for these calls.
97 echo "void _memcpy(void) {}"